From 8451c3eebc51225b6eb4fb0b6a504221a1e5194a Mon Sep 17 00:00:00 2001 From: ffiirree Date: Mon, 27 Mar 2023 15:34:44 +0800 Subject: [PATCH] [w&l] high dpi scaling --- CMakeLists.txt | 2 +- README.md | 7 ++--- src/capturer.qrc | 2 ++ src/capturer.qss | 4 +-- src/menu/editmenu.h | 2 +- src/menu/imageeditmenu.h | 1 - src/menu/menu-dark.qss | 4 --- src/menu/menu.qss | 29 +++++++++--------- src/menu/stylemenu.cpp | 2 +- src/menu/stylemenu.h | 3 +- src/res/close-dark.png | Bin 0 -> 2666 bytes src/res/close-light.png | Bin 0 -> 2649 bytes src/res/close.png | Bin 451 -> 2573 bytes src/setting/settingswindow-dark.qss | 5 +++ src/setting/settingswindow-light.qss | 4 +++ src/setting/settingswindow.qss | 19 ++++++++++++ src/widgets/iconbutton.cpp | 24 --------------- src/widgets/iconbutton.h | 19 ------------ ...inewidthwidget.cpp => linewidthbutton.cpp} | 2 +- .../{linewidthwidget.h => linewidthbutton.h} | 6 ++-- src/widgets/titlebar.cpp | 17 +++++----- src/widgets/titlebar.h | 1 - 22 files changed, 67 insertions(+), 86 deletions(-) create mode 100644 src/res/close-dark.png create mode 100644 src/res/close-light.png delete mode 100644 src/widgets/iconbutton.cpp delete mode 100644 src/widgets/iconbutton.h rename src/widgets/{linewidthwidget.cpp => linewidthbutton.cpp} (94%) rename src/widgets/{linewidthwidget.h => linewidthbutton.h} (91%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 24084da..f936f1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.12) -project(capturer VERSION 1.4.0 LANGUAGES C CXX) +project(capturer VERSION 1.4.1 LANGUAGES C CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) diff --git a/README.md b/README.md index dce56aa..6ba896f 100644 --- a/README.md +++ b/README.md @@ -2,9 +2,8 @@ ![image](/capturer.png) - -`Capturer`是使用`Qt`开发的一款**截图**、**录屏**和**录制GIF**软件,支持`Windows`和`Linux`系统。 -> `录屏`和`录制GIF`依赖于`FFmpeg`,请[安装FFmpeg](#安装FFmpeg). +`Capturer`是使用`Qt`开发的一款**截图**、**贴图**、**录屏**和**录制GIF**软件,支持`Windows`和`Linux`系统。 +配合快捷键可以快速选择`桌面区域`或`窗口`进行快速截图/录制。 ## 快捷键 @@ -90,7 +89,7 @@ git clone https://github.com/ffiirree/Capturer.git --recursive git submodule update --init --recursive ``` -> 本项目开发使用的`Qt`版本为`Qt 5.12.12`, `FFmpeg`版本为4.4.1 +> 本项目开发使用的`Qt`版本为`Qt 5.12.x / 5.15.x`, `FFmpeg`版本为`4.4.x` / `5.1.2` ### Windows diff --git a/src/capturer.qrc b/src/capturer.qrc index d046d35..3933b18 100644 --- a/src/capturer.qrc +++ b/src/capturer.qrc @@ -1,6 +1,8 @@ res/close.png + res/close-light.png + res/close-dark.png res/save.png res/save-light.png res/save-dark.png diff --git a/src/capturer.qss b/src/capturer.qss index 154a8b3..d9448c3 100644 --- a/src/capturer.qss +++ b/src/capturer.qss @@ -140,7 +140,7 @@ QSpinBox::down-arrow { QMenu { border-radius: 5px; - padding: 0.5em; + padding: 0.35em; } QMenu::icon { @@ -179,7 +179,7 @@ QMenu#tray-menu::item { /*///////////////////////////////////////////////////////////////*/ QLabel#size_info { - background-color: rgba(0, 0, 0, 200);; + background-color: rgba(0, 0, 0, 200); color: white; font-size: 9pt; font-family: "Microsoft YaHei"; diff --git a/src/menu/editmenu.h b/src/menu/editmenu.h index 898f9ad..8c837bd 100644 --- a/src/menu/editmenu.h +++ b/src/menu/editmenu.h @@ -3,7 +3,7 @@ #include #include -#include "iconbutton.h" +#include "custombutton.h" class EditMenu : public QWidget { diff --git a/src/menu/imageeditmenu.h b/src/menu/imageeditmenu.h index 4790ca1..fdc780c 100644 --- a/src/menu/imageeditmenu.h +++ b/src/menu/imageeditmenu.h @@ -4,7 +4,6 @@ #include #include "utils.h" #include "stylemenu.h" -#include "iconbutton.h" #include "buttongroup.h" class ImageEditMenu : public EditMenu diff --git a/src/menu/menu-dark.qss b/src/menu/menu-dark.qss index 7ab3276..c7525a8 100644 --- a/src/menu/menu-dark.qss +++ b/src/menu/menu-dark.qss @@ -63,10 +63,6 @@ EditMenu { background-color: #232323; } -ImageEditMenu QPushButton { - background-color: #232323; -} - ImageEditMenu QCheckBox::indicator:unchecked:hover { background-color: #323232; } diff --git a/src/menu/menu.qss b/src/menu/menu.qss index a93ee95..f9066df 100644 --- a/src/menu/menu.qss +++ b/src/menu/menu.qss @@ -9,9 +9,11 @@ RecordMenu QCheckBox { } RecordMenu QCheckBox::indicator { - height: 1.5em; - width: 1.5em; - padding: 0.75em; + font-size: 9pt; + + height: 1.35em; + width: 1.35em; + padding: 0.6em; border-radius: 5px; } @@ -29,19 +31,15 @@ RecordMenu QCheckBox#stop-btn::indicator { /*///////////////////////////////// Edit Menu //////////////////////////////*/ -ImageEditMenu QPushButton { - width: 35px; - height: 35px; - border: none; -} - ImageEditMenu QCheckBox { spacing: 0px; } ImageEditMenu QCheckBox::indicator { - height: 1.75em; - width: 1.75em; + font-size: 9pt; + + height: 1.5em; + width: 1.5em; padding: 0.5em; } @@ -102,8 +100,10 @@ StyleMenu QCheckBox { } StyleMenu QCheckBox::indicator { - height: 1.75em; - width: 1.75em; + font-size: 9pt; + + height: 1.5em; + width: 1.5em; padding: 0.5em; } @@ -112,5 +112,6 @@ StyleMenu QCheckBox#fill-btn::indicator:checked { } StyleMenu ColorPanel { - min-height: 2.75em; + font-size: 9pt; + min-height: 2.45em; } diff --git a/src/menu/stylemenu.cpp b/src/menu/stylemenu.cpp index b05b466..ffdc943 100644 --- a/src/menu/stylemenu.cpp +++ b/src/menu/stylemenu.cpp @@ -21,7 +21,7 @@ StyleMenu::StyleMenu(int buttons, QWidget* parent) if (buttons & FILL_BTN) { fill_btn_ = new QCheckBox(this); fill_btn_->setObjectName("fill-btn"); - connect(fill_btn_, &IconButton::toggled, [this](bool checked) { fill_ = checked; emit changed(); }); + connect(fill_btn_, &QCheckBox::toggled, [this](bool checked) { fill_ = checked; emit changed(); }); addWidget(fill_btn_); group->addButton(fill_btn_); diff --git a/src/menu/stylemenu.h b/src/menu/stylemenu.h index 8d16ab5..e650ccd 100644 --- a/src/menu/stylemenu.h +++ b/src/menu/stylemenu.h @@ -5,8 +5,7 @@ #include #include "editmenu.h" #include "colorpanel.h" -#include "linewidthwidget.h" -#include "iconbutton.h" +#include "linewidthbutton.h" #include "buttongroup.h" class StyleMenu : public EditMenu diff --git a/src/res/close-dark.png b/src/res/close-dark.png new file mode 100644 index 0000000000000000000000000000000000000000..92730caa43ca9f0c2a31b7790c5e3e36c0315e88 GIT binary patch literal 2666 zcmdT`{X3L-7r*BPGlXgMvY5DWXVy!#te8ArW|%eiv{7aYS&^4mL}P5;h8iz1(`wu^ zwk8o_HrgH|Y-TBDL?PR5TT(*J5GAV~Ls=R1%>EV6_5AQXpYL_f`JD5;zSlX|If8vb z3}ZtJLjVAbnJ}HD!-0PePG2XR!erGtK&7)7et_(E(kuWNLQFbse^%uDL=-dvt2*sl$x|JO~2T=c4WS%)Fkw|`R!}!%;L&{hi<-= zmjx%^tQp!kSJ%|M&5y|&e>gX${MEbF?xWsHa!14+-$&j1^M8wP8zbBr8x;NL`1AI8 zG=yiGM{4HBZMZ2_6yN%;;^20P;ukBXF>EiC=XT1tIoa7A`ht;Pmu?(G3FVgU zDcsse=^Met6|Zh-r-Q%}+InU7t;6lwwars1syog5eWE%1LF%D>=0nN&xoafL*Oh|! zH1ww?(_FQeB;&z2hW5?Kq*|?(NsE2B0Y>!ISMz3_k}ej-y{r4%rjQ?M+bl`&VC7>Wi3*Bs91lCT1N@{B1a2|L3hD z?7m0ky69{EfH0R-u7?&c_X0v!Qn@}_?CXyba!BO{lUwkV4{A25&xy!h>R0RYJs=g* zqc-Gk)?u&OWMEjt^WRkRHTca}Xp?MGYW^N$Jms~DZ5-zaD}zl-xL_;;E$pNKt%I4R z3Kov^E)9qyPr2Bj`oEw68k?6cAgZ6OGn12tV5N(*36C@|W=mwRE5m>cS9uYZR;zyHhQ4GIA#~l?f6imtQdoXy4^hQ{QHxHU|hlp&*{Rr;}Fo?^>K`m9f zN*}wND0AKYb@~SQr2bLsebdZq@D{b!Y4=lf4KT78Bf7h4&rUCFV8U1LeI4q*el4~eVx|PO=KpGZ1k^&RE=YdAmsGQh!0a4 z+>%`dzUysTxiTJ>ht+5_oUX{`sh9GAPsIoU3Q-KC8c%9M^q_jF0D%{AGu2BC2%N=(m<2ut z;=uOCeP5a&17L+Sfvw#_I58P1JR+tl7qUSrt2mBBRi zXyMYGLdg3n6F@O?dRN|rM26HGpoKS!-^ym7T^A=B^LbO>7w&BW1{aC~jC5TY;Jc$Lgr+y@&APHRc%;9EHX3Ik^S)NpN=rRRh)^#S z6l2XsmREAcE?CdC=8u!QskC*XFZ|Qkm$RM?oURM-h07hs#xhzWn`_)OEX+SH?t$rc zYxh-1klTFDS<$$&WGE`}?0}4gYRyi3_xbAQff$on`l2k3aA;XpZ)@BbmQ}z+UIQJ$uM{5weee s8wh($ literal 0 HcmV?d00001 diff --git a/src/res/close-light.png b/src/res/close-light.png new file mode 100644 index 0000000000000000000000000000000000000000..66665e62566aafb40cd3f50da9703f4420fa79ef GIT binary patch literal 2649 zcmdT``BM|w7Vb`BHYLV@piYoRS`a}|1W8n!0FfjzilT!Ef`W*OV@!g`qG+RGduV7{ zWq-s46$^nuRCW-EgeVL?1kn*D3EMoy4IP94!u0$Vuig*$ey7g;&Uflo-CN&D*|A+< zL|;M&0KiBj*`p=@0@x9ouBp(Mb!bji^l>Eki3jlOu5#MchbkK*szQ{KmW@2zt z;Erm)8tm1-Raal#ReglFE-$J>yAmoXij(&^li=gU2U=s|Y5?wZSbhS0tnT_i5=p2F zA;kY8L`bV`0Osurq!Jilwp<_qP4iIRUP2ypsH*IlhyX}Ck1Q>>2azj7Evs#4fJ$^T zrtLln@X7e0CJ(Q$xi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hia4rl?f^+G__8b{~wd@N|Z z&9g}y|8oc2hP=Oiex};s*GtUq)Qm>Lyc=mMXVi8;H`iyF94?K(@9^nN;r2`96aAnjY{HUA-V=pZC=%1sHNLI*WN3a}WVsLce>dYU--PcAt zasjT~P})R{_pt2h@(N!@v)uH6v&A2bVJBMF*J9IPQfN*>Pp7*qI(sb0&v*2ZHP0j{ zDE?+NY0xDc8YK^|l79{?bk;HHK3^O=|B>FmINq#F=3tHwbY9!f=h2rtCL6=vuT%h-0nJtIlLGorF0*!cr&r~ zQ=IIUa&F^JrvJz)t8}N4n02_jmJFI4HQhY|<~D!#N`J7yHDtIQQRN;!+gsyrZ|WVf z$fTnKO)cnF*Ql2|&tau<^59XUsVA8M#U5WaJ@@Z8J8^AzXsfm-seaEnt#q=jJ)WJK zvg6y-_lnDpUq(em%|-@RgpV#H7B}jul{D20_}j*Bu5#vnnL2;=Uv`uAr85CvBkI-? z<&BnLDn7u3>?zdzL;%*lpwr8;0G|D+gq${fkXcuJjrsq4JUu`82IiKyC~F5kD*~b| L+xaE#2hRTuro(t) literal 0 HcmV?d00001 diff --git a/src/res/close.png b/src/res/close.png index 7b28b782dc2a31a08f42dd9db3c06f265bd673eb..bbe9632f349a02c5dcc5d838a3ba96e2b36413a8 100644 GIT binary patch literal 2573 zcmdT``8$+rAAg=%&BPc(ie~D;RHn_6GPXR%#84qr;&fP?kircx}^}^IyF05BGPuuj~8ye6IU@fA8x~@Nje1AnFqV0MKyZ zusv12<=>@-Q`thFqT4D5hI%@)fT9lSC;$-TE^G(y^9R3vcoCs(Lyq$=5Ie5phq2Zf zc=JXu`LP+UVJo%f69^Ui(q5f7wk0c=$A5Hx(K+~7t(lA4V-A7|S|e(W!*CSgD8T=m zNS28K>VH8XQiA8eDFBU~vf|+-Iv|2Be>Oi#0RA7+D$vt)_Cif;5<{xVkgj4#vl!CU zjPF;+r*D0-<9mJhZT0H$rpnj7yFRq@Z+LE#-l&t@7<=Pae3ytb?yHQPpK~)+)^5&? z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slIgH(rwoA4$SM`%Wncc+Q{KRsB}33_%)61b9=~ zOd^`Tl>_jeEvl*XtRldDN=W$H#K&XymFv&H7oXx)Gm~5U z4LaF*iU282m@wTd=gO>Y$=n}H7kCz#fi{0TqE#cuuXI9&qFDkgN?2IfubhOcGhZ3- zk=&^7l|oGGPYDT+p%(hpU8Hi99pfIb?8TGO$m7URXCn!Xq1O5x*tU`${EmiFV-BSs zu-2v*w^rj(q*2{|drf)=9|`!qrav-vg!4X}%pL#GJNVhzX@H`}Y(6uw+xg0sMjDx$ z*xNmrq^*^(9#SlSQsBJGOrK&2%gp|>{tL~7LRkjOaw`8S7gDhaR%GspGyaQ%PVf;T zhB}w-Gp~N%s1!GCC;j1)6Tj}_ubuvxJE)#|tw}e!y*g%_3^#0sq&G|$(&Lw};smUG zKY_Q?bVjJMrW|+eq9w>9eow8(@*NF&UOTQciYOT|+zXGL*;8AqKZ}yLSX`ESvOR+z z))7)y-#&&7{PA@uv(fMH0(&)G^~^tUQAT*2l$jZ~To>$yr#B8SSn#fGl$VV`xvDdl zK647d8JR`o24N-PNml|pmrx_S(=EkN^$xYuQD#jnUpzdVEOeOA%%wF`IiPYOh(29TcXe(YGwM)^nYn{k<#`m}HaMqLHGwRW&q6;?#Atfg{ zvH%n?<+Jql&>9e_Vqlj{-2!0Sy_dICy8uv->r?n`tbi5iAE1;7!5h?wK$S!oJ|du&NWn)1R1#_U zj6haG0-qI#O32_90;3XAc$EMvA%|BAcoHS>YJn{Yd)Ktb1L_Uyy@Bbo23x2*X0*U< z2`PL<0xN94WbAi2{9g+w&rZLoj-G{>6?LooZ8FlMxLV-WZe#H6e?ppsQebbZEIW#; z1ekrkL_#6Jz;EqN>E)Ca7=bU5$OuH>l^eAz&jzgeY%!~yHd_Dy002ovPDHLkV1f-%zw`hA diff --git a/src/setting/settingswindow-dark.qss b/src/setting/settingswindow-dark.qss index 43ee01a..49f8f57 100644 --- a/src/setting/settingswindow-dark.qss +++ b/src/setting/settingswindow-dark.qss @@ -19,7 +19,12 @@ QLabel#title { background-color: #202021; } +TitleBar QCheckBox#close-btn::indicator { + image: url(:/icon/res/close-light) +} + /*///////////////////////////////////////////////////////////////*/ + QTabWidget#firstmenu::pane { background: #272728; } diff --git a/src/setting/settingswindow-light.qss b/src/setting/settingswindow-light.qss index e632e45..3541e0c 100644 --- a/src/setting/settingswindow-light.qss +++ b/src/setting/settingswindow-light.qss @@ -20,6 +20,10 @@ QLabel#title { background-color: #f5f7fa; } +TitleBar QCheckBox#close-btn::indicator { + image: url(:/icon/res/close-dark) +} + /*///////////////////////////////////////////////////////////////*/ QTabWidget#firstmenu::pane { background: #fcfdfe; diff --git a/src/setting/settingswindow.qss b/src/setting/settingswindow.qss index 450e86c..51c6d0c 100644 --- a/src/setting/settingswindow.qss +++ b/src/setting/settingswindow.qss @@ -16,7 +16,26 @@ QLabel#title { font-family: "华文新魏"; } +TitleBar QCheckBox { + spacing: 0px; +} + +TitleBar QCheckBox#close-btn::indicator { + font-size: 9pt; + + height: 1.25em; + width: 1.25em; + + padding: 0.75em 1.25em 0.75em 1.25em; +} + +TitleBar QCheckBox#close-btn::indicator:hover { + background-color: #e81123; + image: url(:/icon/res/close-light) +} + /*///////////////////////////////////////////////////////////////*/ + QTabWidget#firstmenu::pane { border: none; } diff --git a/src/widgets/iconbutton.cpp b/src/widgets/iconbutton.cpp deleted file mode 100644 index 6be22b6..0000000 --- a/src/widgets/iconbutton.cpp +++ /dev/null @@ -1,24 +0,0 @@ -#include "iconbutton.h" -#include -#include "utils.h" - -IconButton::IconButton(const QPixmap& icon, QWidget* parent) - : CustomButton(parent), icon_(icon) -{ } - -IconButton::IconButton(const QPixmap& icon, const QSize& size, const QSize& icon_size, bool checkable, QWidget* parent) - : CustomButton(size, checkable, parent), icon_(icon), isize_(icon_size) -{ - setIconSize(isize_); -} - -void IconButton::paint(QPainter* painter) -{ - auto mask = icon_.createMaskFromColor(Qt::transparent); - - icon_.fill(iconColor()); - icon_.setMask(mask); - - auto c = rect().center(); - QIcon(icon_).paint(painter, { c.x() - iconSize().width() / 2, c.y() - iconSize().height() / 2, iconSize().width(), iconSize().height() }); -} diff --git a/src/widgets/iconbutton.h b/src/widgets/iconbutton.h deleted file mode 100644 index 410d46c..0000000 --- a/src/widgets/iconbutton.h +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef ICON_BUTTON_H -#define ICON_BUTTON_H - -#include "utils.h" -#include "custombutton.h" - -class IconButton : public CustomButton -{ -public: - explicit IconButton(const QPixmap&, QWidget* = nullptr); - IconButton(const QPixmap&, const QSize&, const QSize&, bool = false, QWidget* = nullptr); - - void paint(QPainter*) override; -private: - QPixmap icon_; - QSize isize_; -}; - -#endif // ICON_BUTTON_H diff --git a/src/widgets/linewidthwidget.cpp b/src/widgets/linewidthbutton.cpp similarity index 94% rename from src/widgets/linewidthwidget.cpp rename to src/widgets/linewidthbutton.cpp index 970b061..d4d16a9 100644 --- a/src/widgets/linewidthwidget.cpp +++ b/src/widgets/linewidthbutton.cpp @@ -1,6 +1,6 @@ -#include "linewidthwidget.h" #include #include +#include "linewidthbutton.h" void WidthButton::wheelEvent(QWheelEvent *event) { diff --git a/src/widgets/linewidthwidget.h b/src/widgets/linewidthbutton.h similarity index 91% rename from src/widgets/linewidthwidget.h rename to src/widgets/linewidthbutton.h index ad7465b..fa2e759 100644 --- a/src/widgets/linewidthwidget.h +++ b/src/widgets/linewidthbutton.h @@ -1,5 +1,5 @@ -#ifndef LINE_WIDTH_WIDGET_H -#define LINE_WIDTH_WIDGET_H +#ifndef LINE_WIDTH_BUTTON_H +#define LINE_WIDTH_BUTTON_H #include "custombutton.h" @@ -46,4 +46,4 @@ public slots: int min_{ 1 }; }; -#endif // LINE_WIDTH_WIDGET_H +#endif // !LINE_WIDTH_BUTTON_H diff --git a/src/widgets/titlebar.cpp b/src/widgets/titlebar.cpp index da7da10..136d6e2 100644 --- a/src/widgets/titlebar.cpp +++ b/src/widgets/titlebar.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include TitleBar::TitleBar(QWidget *parent) @@ -20,12 +21,12 @@ TitleBar::TitleBar(QWidget *parent) icon_label->setObjectName("logo"); auto logo = QPixmap(":/icon/res/icon"); icon_label->setPixmap(logo); - icon_label->setFixedSize(50, 50); - icon_label->setContentsMargins({10, 10, 10, 10}); + icon_label->setFixedSize(60, 50); + icon_label->setContentsMargins({ 20, 10, 10, 10 }); icon_label->setScaledContents(true); title_label_ = new QLabel("", this); - title_label_->setFixedWidth(150); + title_label_->setFixedWidth(140); title_label_->setObjectName("title"); layout->addWidget(icon_label); @@ -35,12 +36,12 @@ TitleBar::TitleBar(QWidget *parent) layout->addSpacerItem(new QSpacerItem(20, 50, QSizePolicy::Expanding, QSizePolicy::Minimum)); // close button - auto close_btn = new IconButton(QPixmap(":/icon/res/close"), { 50, 50 }, { 24, 24 }, false, this); - close_btn->normal(QColor("#afafaf")); - close_btn->hover(QColor("#409eff")); - connect(close_btn, &QPushButton::clicked, this, &TitleBar::close); + auto close_btn = new QCheckBox(this); + close_btn->setObjectName("close-btn"); + close_btn->setCheckable(false); + connect(close_btn, &QCheckBox::clicked, this, &TitleBar::close); - layout->addWidget(close_btn); + layout->addWidget(close_btn, 0, Qt::AlignTop); } void TitleBar::mousePressEvent(QMouseEvent * event) diff --git a/src/widgets/titlebar.h b/src/widgets/titlebar.h index 9a19f21..29864a6 100644 --- a/src/widgets/titlebar.h +++ b/src/widgets/titlebar.h @@ -3,7 +3,6 @@ #include #include -#include "iconbutton.h" class TitleBar : public QWidget { Q_OBJECT