Skip to content

Commit

Permalink
Merge pull request #701 from barry-ran/dev
Browse files Browse the repository at this point in the history
sync dev
  • Loading branch information
barry-ran authored Oct 18, 2022
2 parents e218ceb + fcd6832 commit d8f16d4
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 5 deletions.
2 changes: 2 additions & 0 deletions QtScrcpy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(QC_UTIL_SOURCES ${QC_UTIL_SOURCES}
util/mousetap/winmousetap.h
util/mousetap/winmousetap.cpp
util/winutils.h
util/winutils.cpp
)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
Expand Down
2 changes: 1 addition & 1 deletion QtScrcpy/QtScrcpyCore
8 changes: 8 additions & 0 deletions QtScrcpy/ui/dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include "videoform.h"
#include "../groupcontroller/groupcontroller.h"

#ifdef Q_OS_WIN32
#include "../util/winutils.h"
#endif

QString s_keyMapPath = "";

const QString &getKeyMapPath()
Expand Down Expand Up @@ -137,6 +141,10 @@ void Dialog::initUI()

setWindowTitle(Config::getInstance().getTitle());

#ifdef Q_OS_WIN32
WinUtils::setDarkBorderToWindow((HWND)this->winId(), true);
#endif

ui->bitRateEdit->setValidator(new QIntValidator(1, 99999, this));

ui->maxSizeBox->addItem("640");
Expand Down
28 changes: 28 additions & 0 deletions QtScrcpy/util/winutils.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#include <QDebug>
#include <Windows.h>
#include <dwmapi.h>
#pragma comment(lib, "dwmapi")

#include "winutils.h"

enum : WORD
{
DwmwaUseImmersiveDarkMode = 20,
DwmwaUseImmersiveDarkModeBefore20h1 = 19
};

WinUtils::WinUtils(){};

WinUtils::~WinUtils(){};

// Set dark border to window
// Reference: qt/qtbase.git/tree/src/plugins/platforms/windows/qwindowswindow.cpp
bool WinUtils::setDarkBorderToWindow(const HWND &hwnd, const bool &d)
{
const BOOL darkBorder = d ? TRUE : FALSE;
const bool ok = SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkMode, &darkBorder, sizeof(darkBorder)))
|| SUCCEEDED(DwmSetWindowAttribute(hwnd, DwmwaUseImmersiveDarkModeBefore20h1, &darkBorder, sizeof(darkBorder)));
if (!ok)
qWarning("%s: Unable to set dark window border.", __FUNCTION__);
return ok;
}
16 changes: 16 additions & 0 deletions QtScrcpy/util/winutils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef WINUTILS_H
#define WINUTILS_H

#include <QApplication>
#include <Windows.h>

class WinUtils
{
public:
WinUtils();
~WinUtils();

static bool setDarkBorderToWindow(const HWND &hwnd, const bool &d);
};

#endif // WINUTILS_H
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,14 @@ All the dependencies are provided and it is easy to compile.
#### Non-Arch Linux Users
1. Set up the Qt development environment with the official Qt installer or third-party tools such as [aqt](https://github.com/miurahr/aqtinstall) on the target platform.
Qt version bigger than 5.12 is required. (use MSVC 2019 on Windows)
2. Clone the project with `git clone --recurse-submodules https://barry-ran/QtScrcpy.git`
2. Clone the project with `git clone --recurse-submodules [email protected]:barry-ran/QtScrcpy.git`
3. For Windows, open CMakeLists.txt with QtCreator and compile Release
4. For Linux, directly run `./ci/linux/build_for_linux.sh "Release"`
Note: compiled artifacts are located at `output/x64/Release`

#### Arch Linux Users
1. Install packages: `base-devel cmake qt5-base qt5-multimedia qt5-x11extras` (`qtcreator` is recommended)
2. Clone the project with `git clone --recurse-submodules https://barry-ran/QtScrcpy.git`
2. Clone the project with `git clone --recurse-submodules [email protected]:barry-ran/QtScrcpy.git`
3. Run `./ci/linux/build_for_linux.sh "Release"`

### Scrcpy-Server
Expand Down
4 changes: 2 additions & 2 deletions README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -246,14 +246,14 @@ Mac OS 平台,你可以直接使用我编译好的可执行程序:
#### 非 Arch Linux
1. 使用官方 Qt Installer 或非官方工具(如 [aqt](https://github.com/miurahr/aqtinstall))在目标平台上搭建Qt开发环境。
需要 5.12 以上版本 Qt(在 Windows 上使用 MSVC 2019)
2. 克隆该项目:`git clone --recurse-submodules https://github.com/barry-ran/QtScrcpy.git`
2. 克隆该项目:`git clone --recurse-submodules git@github.com:barry-ran/QtScrcpy.git`
3. Windows 使用 QtCreator 打开项目下 CMakeLists.txt 并编译 Release
4. Linux 用终端执行 `./ci/linux/build_for_linux.sh "Release"`
注:编译结果位于 `output/x64/Release`

#### Arch Linux
1. 安装以下包:`qt5-base qt5-multimedia qt5-x11extras`(推荐安装 `qtcreator`
2. 克隆该项目:`git clone --recurse-submodules https://github.com/barry-ran/QtScrcpy.git`
2. 克隆该项目:`git clone --recurse-submodules git@github.com:barry-ran/QtScrcpy.git`
3. 用终端执行 `./ci/linux/build_for_linux.sh "Release"`
注:编译结果位于 `output/x64/Release`

Expand Down

0 comments on commit d8f16d4

Please sign in to comment.