From 748603a587755006f44ead78cbae99661ee4361f Mon Sep 17 00:00:00 2001 From: rankun Date: Mon, 16 Mar 2020 12:47:10 +0800 Subject: [PATCH] feat: add framess window --- QtScrcpy/device/device.cpp | 2 +- QtScrcpy/device/ui/videoform.cpp | 5 +- QtScrcpy/device/ui/videoform.h | 2 +- QtScrcpy/dialog.cpp | 7 +++ QtScrcpy/dialog.h | 2 + QtScrcpy/dialog.ui | 47 ++++++++++-------- QtScrcpy/res/i18n/QtScrcpy_en.qm | Bin 3739 -> 3801 bytes QtScrcpy/res/i18n/QtScrcpy_en.ts | 81 ++++++++++++++++--------------- QtScrcpy/res/i18n/QtScrcpy_zh.qm | Bin 2868 -> 2918 bytes QtScrcpy/res/i18n/QtScrcpy_zh.ts | 81 ++++++++++++++++--------------- QtScrcpy/util/config.cpp | 19 ++++++++ QtScrcpy/util/config.h | 2 + README.md | 2 +- README_zh.md | 2 +- 14 files changed, 151 insertions(+), 101 deletions(-) diff --git a/QtScrcpy/device/device.cpp b/QtScrcpy/device/device.cpp index 5cb0396..a0bda6b 100644 --- a/QtScrcpy/device/device.cpp +++ b/QtScrcpy/device/device.cpp @@ -35,7 +35,7 @@ Device::Device(DeviceParams params, QObject *parent) m_decoder = new Decoder(m_vb, this); m_fileHandler = new FileHandler(this); m_controller = new Controller(params.gameScript, this); - m_videoForm = new VideoForm(Config::getInstance().getSkin()); + m_videoForm = new VideoForm(Config::getInstance().getFramelessWindow(), Config::getInstance().getSkin()); m_videoForm->setDevice(this); } diff --git a/QtScrcpy/device/ui/videoform.cpp b/QtScrcpy/device/ui/videoform.cpp index 223897d..8fea7db 100644 --- a/QtScrcpy/device/ui/videoform.cpp +++ b/QtScrcpy/device/ui/videoform.cpp @@ -25,7 +25,7 @@ extern "C" #include "libavutil/frame.h" } -VideoForm::VideoForm(bool skin, QWidget *parent) +VideoForm::VideoForm(bool framelessWindow, bool skin, QWidget *parent) : QWidget(parent) , ui(new Ui::videoForm) , m_skin(skin) @@ -38,6 +38,9 @@ VideoForm::VideoForm(bool skin, QWidget *parent) if (m_skin) { updateStyleSheet(vertical); } + if (framelessWindow) { + setWindowFlags(windowFlags() | Qt::FramelessWindowHint); + } } VideoForm::~VideoForm() diff --git a/QtScrcpy/device/ui/videoform.h b/QtScrcpy/device/ui/videoform.h index 9de6438..c3b4fc6 100644 --- a/QtScrcpy/device/ui/videoform.h +++ b/QtScrcpy/device/ui/videoform.h @@ -17,7 +17,7 @@ class VideoForm : public QWidget { Q_OBJECT public: - explicit VideoForm(bool skin = true, QWidget *parent = 0); + explicit VideoForm(bool framelessWindow = false, bool skin = true, QWidget *parent = 0); ~VideoForm(); void staysOnTop(bool top = true); diff --git a/QtScrcpy/dialog.cpp b/QtScrcpy/dialog.cpp index 938b6d5..3aa54bb 100644 --- a/QtScrcpy/dialog.cpp +++ b/QtScrcpy/dialog.cpp @@ -98,6 +98,7 @@ void Dialog::initUI() ui->formatBox->setCurrentIndex(Config::getInstance().getRecordFormatIndex()); ui->recordPathEdt->setText(Config::getInstance().getRecordPath()); + ui->framelessCheck->setChecked(Config::getInstance().getFramelessWindow()); #ifdef Q_OS_OSX // mac need more width @@ -384,3 +385,9 @@ void Dialog::on_formatBox_activated(int index) { Config::getInstance().setRecordFormatIndex(index); } + +void Dialog::on_framelessCheck_stateChanged(int arg1) +{ + Q_UNUSED(arg1) + Config::getInstance().setFramelessWindow(ui->framelessCheck->isChecked()); +} diff --git a/QtScrcpy/dialog.h b/QtScrcpy/dialog.h index a55361f..2b871a3 100644 --- a/QtScrcpy/dialog.h +++ b/QtScrcpy/dialog.h @@ -62,6 +62,8 @@ private slots: void on_formatBox_activated(int index); + void on_framelessCheck_stateChanged(int arg1); + private: bool checkAdbRun(); void initUI(); diff --git a/QtScrcpy/dialog.ui b/QtScrcpy/dialog.ui index f22349b..9060e15 100644 --- a/QtScrcpy/dialog.ui +++ b/QtScrcpy/dialog.ui @@ -215,6 +215,22 @@ + + + + + 0 + 0 + + + + always on top + + + false + + + @@ -228,22 +244,6 @@ - - - - - 0 - 0 - - - - background record - - - false - - - @@ -260,8 +260,8 @@ - - + + 0 @@ -269,13 +269,20 @@ - always on top + background record - + false + + + + frameless + + + diff --git a/QtScrcpy/res/i18n/QtScrcpy_en.qm b/QtScrcpy/res/i18n/QtScrcpy_en.qm index d6717b1ef201fdbedf02cb18dc90591c65e9d1ac..d68f816f5ac8ea34010f9b139fa44daec994c5d3 100644 GIT binary patch delta 417 zcmbO&dsB9Th~@+a)@?Bi3|t%xY~M^77`XKr*lj`?7`P)CWHwtcFz`q*n29c8U|=_& zXe(~n$k3zd%)r3-iP7@WIR*x<97cON2L=WfO~!zu(-{~T8yI)BOk!YQFJtDuD#yUU z6U}^>YXJiT&&-LvYV{ljY{y@E=Fc2)MyDAV7;bPR%FSY6 z;5g6mk6DI+fn_15gHb921N$$|#0xA83~c{6OC!E8Ffd)!sB%e46K>_nJc6i7+9tGYhMR2FfgU?@47sTfq~@;|J}~5 z3=E7SnG6iP8q5p~40;Tzn^!V^U{(`iNMk5sNMy)mNM*=jNM$HyDCPhK1sekc17})M QVs2_qYH{)APF5jK01j7YQ2+n{ delta 378 zcmca9J6m>wh-L=^>$VsM2F^p`*+Vc1_rL(9C1dc85kIDa3spjVqoBy$?=a_hJk@4 zo72H4m4Si%2xsC276t~k6P%?HUl)~=ZwvVBnfsKi)s+o&{fyI>j zfc8xW2Cj1M6Z_p57}$b&oZ>hWyPt8DB7OzRt?T2>?5aU=08O diff --git a/QtScrcpy/res/i18n/QtScrcpy_en.ts b/QtScrcpy/res/i18n/QtScrcpy_en.ts index f158eee..9592331 100644 --- a/QtScrcpy/res/i18n/QtScrcpy_en.ts +++ b/QtScrcpy/res/i18n/QtScrcpy_en.ts @@ -16,22 +16,22 @@ file transfer failed - + install apk install apk - + file transfer file transfer - + wait current %1 to complete wait current %1 to complete - + %1 complete, save in %2 %1 complete, save in %2 @@ -41,7 +41,7 @@ %1 complete\n save in %2 - + %1 failed %1 failed @@ -49,17 +49,17 @@ Dialog - + Wireless Wireless - + wireless connect wireless connect - + wireless disconnect wireless disconnect @@ -75,7 +75,7 @@ - + select path select path @@ -90,27 +90,32 @@ record screen - + + frameless + frameless + + + stop all server stop all server - + adb command: adb command: - + terminate terminate - + execute execute - + clear clear @@ -124,12 +129,12 @@ auto enable - + background record background record - + screen-off screen-off @@ -144,7 +149,7 @@ max size: - + always on top always on top @@ -154,27 +159,27 @@ refresh script - + get device IP get device IP - + USB line USB line - + stop server stop server - + start server start server - + device serial: device serial: @@ -188,12 +193,12 @@ bit rate: - + start adbd start adbd - + refresh devices refresh devices @@ -206,7 +211,7 @@ QObject - + This software is completely open source and free, you can download it at the following address: This software is completely open source and free, you can download it at the following address: @@ -219,12 +224,12 @@ Tool - + full screen full screen - + expand notify expand notify @@ -237,52 +242,52 @@ turn on - + touch switch touch switch - + close screen close screen - + power power - + volume up volume up - + volume down volume down - + app switch app switch - + menu menu - + home home - + return return - + screen shot screen shot @@ -302,7 +307,7 @@ file transfer failed - + file does not exist file does not exist diff --git a/QtScrcpy/res/i18n/QtScrcpy_zh.qm b/QtScrcpy/res/i18n/QtScrcpy_zh.qm index 3552ab7ad6c5dda9a8bbe98353c97ba9b1821a8a..7bcbdadaf83f7736a718185a2cbcb3a6bbbc06c5 100644 GIT binary patch delta 405 zcmdlY_DpPoh~@+a)@?Bi4D4PEY~M^77&vqp*lj`?7&t;0WHwtcFmQZgFcV$Gz`$BR z(N^5DlA%Y_nSp_^gwgWRIR*yyd5rdQ4h#&;`iucbr!z1xN-^$gnZ&@rx{jIqsvH9Y zr#katt_2JXoS_qY)$6U;j=ySQU|?`#d(q&;z`(%3?jSA9z`zpD?ymimfq~JJy=PA! z0|Uo=_BFjb7#P^|*`H}WVqjo>!v5Vej)8%Lk;BGOnSp_sl_SpRGy?;}5{^Wc?3c@r8kbNsUWxl>`GrJ*xtj!?Aq~3@rP& zs+zeN7?_i}4`|JbePX{G0|U!v9;dhv1_qX1o;vd@3=AB{cwVnL%D}*MpHJGd zg@J)Bmv8lD5e5d%Mt+6I>lheV)cG@4NHH)lzvZue9l*fAc#eP90 zV7QXWz`(hOnSp^pgh7>I^D0J0W+}GR2mL!U+&Dn~XJcSs;7lt@%uUTnEiT?Xn`I^& E0CK)#H~;_u delta 378 zcmaDRwnc1$h-L=^>$VsM26hDowr{2k3>?f1>^7kc3>;bvGMgsRX9r{zA!K_sd34zl3-w9`NrjNY##$dJQC)8@M@oooPca9!~L diff --git a/QtScrcpy/res/i18n/QtScrcpy_zh.ts b/QtScrcpy/res/i18n/QtScrcpy_zh.ts index 5001248..f3e0056 100644 --- a/QtScrcpy/res/i18n/QtScrcpy_zh.ts +++ b/QtScrcpy/res/i18n/QtScrcpy_zh.ts @@ -16,22 +16,22 @@ 文件传输失败 - + install apk 安装apk - + file transfer 文件传输 - + wait current %1 to complete 等待当前%1完成 - + %1 complete, save in %2 %1完成,保存在%2 @@ -41,7 +41,7 @@ %1完成\n 保存在 %2 - + %1 failed %1 失败 @@ -49,17 +49,17 @@ Dialog - + Wireless 无线 - + wireless connect 无线连接 - + wireless disconnect 无线断开 @@ -75,7 +75,7 @@ - + select path 选择路径 @@ -90,27 +90,32 @@ 录制屏幕 - + + frameless + 无边框 + + + stop all server 停止所有服务 - + adb command: adb命令: - + terminate 终止 - + execute 执行 - + clear 清理 @@ -124,12 +129,12 @@ 自动启用脚本 - + background record 后台录制 - + screen-off 自动息屏 @@ -144,7 +149,7 @@ 最大尺寸: - + always on top 窗口置顶 @@ -154,27 +159,27 @@ 刷新脚本 - + get device IP 获取设备IP - + USB line USB线 - + stop server 停止服务 - + start server 启动服务 - + device serial: 设备序列号: @@ -188,12 +193,12 @@ 比特率: - + start adbd 启动adbd - + refresh devices 刷新设备列表 @@ -206,7 +211,7 @@ QObject - + This software is completely open source and free, you can download it at the following address: 本软件完全开源免费,你可以在下面的地址下载: @@ -219,12 +224,12 @@ 工具 - + full screen 全屏 - + expand notify 下拉通知 @@ -237,52 +242,52 @@ 解锁 - + touch switch 触摸显示开关 - + close screen 关闭屏幕 - + power 电源 - + volume up 音量加 - + volume down 音量减 - + app switch 切换应用 - + menu 菜单 - + home 主界面 - + return 返回 - + screen shot 截图 @@ -302,7 +307,7 @@ 文件传输失败 - + file does not exist 文件不存在 diff --git a/QtScrcpy/util/config.cpp b/QtScrcpy/util/config.cpp index 2f7b0a7..ea39ea7 100644 --- a/QtScrcpy/util/config.cpp +++ b/QtScrcpy/util/config.cpp @@ -50,6 +50,9 @@ #define SERIAL_WINDOW_RECT_KEY_H "WindowRectH" #define SERIAL_WINDOW_RECT_KEY_DEF -1 +#define COMMON_FRAMELESS_WINDOW_KEY "FramelessWindow" +#define COMMON_FRAMELESS_WINDOW_DEF false + // 最大尺寸 录制格式 QString Config::s_configPath = ""; @@ -169,6 +172,22 @@ QRect Config::getRect(const QString &serial) return rc; } +void Config::setFramelessWindow(bool frameless) +{ + m_userData->beginGroup(GROUP_COMMON); + m_userData->setValue(COMMON_FRAMELESS_WINDOW_KEY, frameless); + m_userData->endGroup(); +} + +bool Config::getFramelessWindow() +{ + bool framelessWindow = false; + m_userData->beginGroup(GROUP_COMMON); + framelessWindow = m_userData->value(COMMON_FRAMELESS_WINDOW_KEY, COMMON_FRAMELESS_WINDOW_DEF).toBool(); + m_userData->endGroup(); + return framelessWindow; +} + QString Config::getServerVersion() { QString server; diff --git a/QtScrcpy/util/config.h b/QtScrcpy/util/config.h index e635278..28cfec2 100644 --- a/QtScrcpy/util/config.h +++ b/QtScrcpy/util/config.h @@ -32,6 +32,8 @@ public: void setRecordFormatIndex(int recordFormatIndex); void setRect(const QString &serial, const QRect &rc); QRect getRect(const QString &serial); + bool getFramelessWindow(); + void setFramelessWindow(bool frameless); private: explicit Config(QObject *parent = nullptr); diff --git a/README.md b/README.md index 742b7df..4003f8e 100644 --- a/README.md +++ b/README.md @@ -226,7 +226,7 @@ There are several reasons listed as below according to importance (high to low). All the dependencies are provided and it is easy to compile. ### PC client -1. Set up the Qt development environment on the target platform (Qt >= 5.9.7, vs >= 2015 (mingw not supported)) +1. Set up the Qt development environment on the target platform (Qt >= 5.12.0, vs >= 2017 (mingw not supported)) 2. Clone the project 3. Open the project root directory all.pro with QtCreator 4. Compile and run diff --git a/README_zh.md b/README_zh.md index 12d63ad..f1c6dcc 100644 --- a/README_zh.md +++ b/README_zh.md @@ -226,7 +226,7 @@ Mac OS平台,你可以直接使用我编译好的可执行程序: 尽量提供了所有依赖资源,方便傻瓜式编译。 ### PC端 -1. 目标平台上搭建Qt开发环境(Qt >= 5.9.7, vs >= 2015 (**不支持mingw**)) +1. 目标平台上搭建Qt开发环境(Qt >= 5.12.0, vs >= 2017 (**不支持mingw**)) 2. 克隆该项目 3. 使用QtCreator打开项目根目录all.pro 4. 编译,运行即可