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 0000000..92730ca Binary files /dev/null and b/src/res/close-dark.png differ diff --git a/src/res/close-light.png b/src/res/close-light.png new file mode 100644 index 0000000..66665e6 Binary files /dev/null and b/src/res/close-light.png differ diff --git a/src/res/close.png b/src/res/close.png index 7b28b78..bbe9632 100644 Binary files a/src/res/close.png and b/src/res/close.png differ 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