From 582d222f708d1305d39ca5485cd1b4bce9dccb89 Mon Sep 17 00:00:00 2001 From: ffiirree Date: Thu, 13 Apr 2023 05:14:01 +0800 Subject: [PATCH] #40, setting page --- languages/capturer_en_US.ts | 110 +++++++++++++-------------- languages/capturer_zh_CN.ts | 110 +++++++++++++-------------- src/capturer-dark.qss | 9 +-- src/capturer-light.qss | 64 ++++++++++++++-- src/capturer.qss | 76 +++++------------- src/core/config.h | 2 +- src/menu/menu-dark.qss | 4 - src/menu/menu.qss | 34 ++++----- src/menu/stylemenu.cpp | 50 +++--------- src/menu/stylemenu.h | 8 +- src/record/screenrecorder.h | 3 +- src/setting/settingdialog.cpp | 80 +++++++++++++------ src/setting/settingdialog.h | 4 +- src/setting/settingswindow-dark.qss | 33 ++++---- src/setting/settingswindow-light.qss | 46 +++++------ src/setting/settingswindow.qss | 64 +++++++--------- src/widgets/apptabbar.cpp | 40 ---------- src/widgets/apptabbar.h | 32 -------- src/widgets/apptabcontrol.cpp | 20 ----- src/widgets/apptabcontrol.h | 22 ------ src/widgets/colorpanel.cpp | 2 +- src/widgets/combobox.h | 2 +- src/widgets/titlebar.cpp | 20 +---- src/widgets/titlebar.h | 9 +-- src/widgets/widthbutton.cpp | 6 +- src/widgets/widthbutton.h | 2 +- 26 files changed, 361 insertions(+), 491 deletions(-) delete mode 100644 src/widgets/apptabbar.cpp delete mode 100644 src/widgets/apptabbar.h delete mode 100644 src/widgets/apptabcontrol.cpp delete mode 100644 src/widgets/apptabcontrol.h diff --git a/languages/capturer_en_US.ts b/languages/capturer_en_US.ts index 1affb87..9dc1e14 100644 --- a/languages/capturer_en_US.ts +++ b/languages/capturer_en_US.ts @@ -224,205 +224,205 @@ SettingWindow - + Settings - + General - + Language - + Auto - + Dark - + Light - + Theme - - + + Screenshot - - - + + + Border Width - - - + + + Border Color - - - + + + Line Type - - - + + + Mask Color - + Screen Recording - - - + + + Appearance: - - + + Show Region - - + + Params: - - + + Framerate - + Encoder - - + + High - - + + Medium - - + + Low - - + + Quality - + GIF Recording - + Devices - + Microphones - + Speakers - + Cameras - + Shortcuts - + Paste - + Hide/Show All Images - + Video Recording - + Gif Recording - + About - + Version - + Copyright © 2018 - 2023 ffiirree. All rights reserved - + Run on Startup - + Settings File diff --git a/languages/capturer_zh_CN.ts b/languages/capturer_zh_CN.ts index df516e4..840a5c2 100644 --- a/languages/capturer_zh_CN.ts +++ b/languages/capturer_zh_CN.ts @@ -224,205 +224,205 @@ SettingWindow - + Settings 设置 - + General 通用 - + Language 语言 - + Dark 暗色 - + Light 亮色 - + Theme 主题 - - + + Screenshot 截图 - - + + Params: 参数: - - + + Framerate 帧率 - + Microphones 麦克风 - + Speakers 扬声器 - + Cameras 摄像头 - + Encoder 编码器 - + Screen Recording 录屏 - + Run on Startup 开机启动 - + Settings File 设置文件 - + Auto 跟随系统 - - - + + + Border Width 边框宽度 - - - + + + Border Color 边框颜色 - - - + + + Line Type 线条类型 - - - + + + Mask Color 遮罩颜色 - - - + + + Appearance: 界面: - - + + Show Region 显示区域 - - + + High - - + + Medium - - + + Low - - + + Quality 质量 - + GIF Recording 录制GIF - + Devices 设备 - + Shortcuts 快捷键 - + Paste 粘贴 - + Hide/Show All Images 隐藏/显示全部贴图 - + Video Recording 录制视频 - + Gif Recording 录制GIF - + About 关于 - + Version 版本 - + Copyright © 2018 - 2023 ffiirree. All rights reserved diff --git a/src/capturer-dark.qss b/src/capturer-dark.qss index cbe6af7..e73fdbb 100644 --- a/src/capturer-dark.qss +++ b/src/capturer-dark.qss @@ -59,11 +59,6 @@ QLineEdit:focus { border: 1px solid #323232; } -QLineEdit[readOnly="true"] { - color: gray -} - - /*///////////////////////////////////////////////////////////////*/ QSpinBox { border: 1px solid #323232; @@ -82,14 +77,14 @@ QSpinBox:focus { QSpinBox::down-button, QSpinBox::up-button { - background-color: #323232; + background-color: #292929; } QSpinBox::up-button:hover, QSpinBox::up-button:pressed, QSpinBox::down-button:hover, QSpinBox::down-button:pressed { - background-color: #393939; + background-color: #262626; } /*///////////////////////////////////////////////////////////////*/ diff --git a/src/capturer-light.qss b/src/capturer-light.qss index 207d983..dde3e85 100644 --- a/src/capturer-light.qss +++ b/src/capturer-light.qss @@ -1,7 +1,8 @@ /*///////////////////////////////////////////////////////////////*/ QComboBox { - border: 1px solid #dfdfdf; - background-color: white; + border: 1px solid #e9e8e7; + border-bottom: 1px solid #d4d3d2; + background-color: #fefefe; color: #50505f; } @@ -13,8 +14,8 @@ QComboBox::down-arrow:on { image: url(:/icon/res/arrow_up.png); } - QComboBox:hover { + background-color: #fafafa; border: 1px solid #dfdfdf; } @@ -39,10 +40,63 @@ QComboBox QAbstractItemView::item { QComboBox QAbstractItemView::item:hover, QComboBox QAbstractItemView::item:selected, QComboBox QAbstractItemView::item:checked { - background-color: #dfdfdf; + background-color: #ebebeb; +} + +/*///////////////////////////////////////////////////////////////*/ +QLineEdit { + border: 1px solid #e9e8e7; + border-bottom: 1px solid #d4d3d2; + background-color: #fefefe; + color: #50505f; +} + +QLineEdit:hover { + background-color: #fafafa; + border: 1px solid #dfdfdf; +} + +QLineEdit:focus { + color: #409eff; + border: 1px solid #409eff; +} + +/*///////////////////////////////////////////////////////////////*/ +QSpinBox { + border: 1px solid #e9e8e7; + border-bottom: 1px solid #d4d3d2; + background-color: #fefefe; + color: #50505f; +} + +QSpinBox:hover { + background-color: #fafafa; + border: 1px solid #dfdfdf; +} + +QSpinBox:focus { + border: 1px solid #409eff; +} + +QSpinBox::up-button { + background-color: #f0f0f0; +} + +QSpinBox::up-button:hover, +QSpinBox::up-button:pressed { + background-color: #e0e0e0; +} + +QSpinBox::down-button { + background-color: #f0f0f0; +} + +QSpinBox::down-button:hover, +QSpinBox::down-button:pressed { + background-color: #e0e0e0; } -/* context menu */ +/*///////////////////////////////////////////////////////////////*/ QMenu { background-color: #f9f9f9; color: #2c2c2c; diff --git a/src/capturer.qss b/src/capturer.qss index d9448c3..f2f397a 100644 --- a/src/capturer.qss +++ b/src/capturer.qss @@ -1,8 +1,13 @@ +QWidget { + font-size: 10.5pt; + font-family: "Microsoft YaHei"; +} + /*///////////////////////////////////////////////////////////////*/ QComboBox { - border-radius: 3px; + border-radius: 5px; height: 1.5em; - padding-left: 10px; + padding-left: 0.5em; margin: 1px 0px; } @@ -22,70 +27,35 @@ QComboBox::down-arrow { QComboBox QAbstractItemView { outline: 0px; - border: 1px solid #e4e7ed; } QComboBox QAbstractItemView { - background-color: #fcfcfc; - border: 1px solid #dfdfdf; padding: 5px; border-radius: 5px; } QComboBox QAbstractItemView::item { + font-size: 10.5pt; border-radius: 5px; - padding-left: 10px; - height: 30px; - color: #505255; + padding-left: 0.5em; + height: 2em; background-color: transparent; } -QComboBox QAbstractItemView::item:hover, -QComboBox QAbstractItemView::item:selected, -QComboBox QAbstractItemView::item:checked { - background-color: #f2f2f2; -} - /*///////////////////////////////////////////////////////////////*/ QLineEdit { - border: 1px solid #dcdfe6; - border-radius: 3px; + border-radius: 5px; height: 1.5em; - padding: 0 10px; + padding: 0 0.5em; margin: 1px 0px; - color: #50505f; -} - -QLineEdit:hover { - border: 1px solid #909399; -} - -QLineEdit:focus { - color: #409eff; - border: 1px solid #409eff; -} - -QLineEdit[readOnly="true"] { - color: gray } /*///////////////////////////////////////////////////////////////*/ QSpinBox { - border: 1px solid #dcdfe6; - border-radius: 3px; - background-color: white; + border-radius: 5px; height: 1.5em; padding: 0 10px; margin: 1px 0px; - color: #50505f; -} - -QSpinBox:hover { - border: 1px solid #909399; -} - -QSpinBox:focus { - border: 1px solid #409eff; } QSpinBox::up-button { @@ -93,8 +63,7 @@ QSpinBox::up-button { subcontrol-position: top right; border: none; - border-radius: 3px; - background-color: #f0f0f0; + border-radius: 5px; width: 20px; margin-right: 2px; @@ -102,11 +71,6 @@ QSpinBox::up-button { margin-bottom: 1px; } -QSpinBox::up-button:hover, -QSpinBox::up-button:pressed { - background-color: #e0e0e0; -} - QSpinBox::up-arrow { image: url(:/icon/res/spin_up.png); width: 20px; @@ -117,8 +81,7 @@ QSpinBox::down-button { subcontrol-position: bottom right; border: none; - border-radius: 3px; - background-color: #f0f0f0; + border-radius: 5px; width: 20px; margin-right: 2px; @@ -126,11 +89,6 @@ QSpinBox::down-button { margin-top: 1px; } -QSpinBox::down-button:hover, -QSpinBox::down-button:pressed { - background-color: #e0e0e0; -} - QSpinBox::down-arrow { image: url(:/icon/res/spin_down.png); width: 20px; @@ -153,9 +111,9 @@ QMenu::item { border-radius: 5px; font-family: "Microsoft YaHei"; - font-size: 9pt; + font-size: 10pt; - height: 2em; + height: 1.75em; padding-left: 0.75em; padding-right: 0.75em; diff --git a/src/core/config.h b/src/core/config.h index 1d7ed7e..db11a14 100644 --- a/src/core/config.h +++ b/src/core/config.h @@ -21,7 +21,7 @@ class Config : public QObject Config(const Config&) = delete; Config& operator=(const Config&) = delete; - QString getFilePath() const { return filepath_; } + [[nodiscard]] QString getFilePath() const { return filepath_; } static std::string theme(); diff --git a/src/menu/menu-dark.qss b/src/menu/menu-dark.qss index b7fe392..397c440 100644 --- a/src/menu/menu-dark.qss +++ b/src/menu/menu-dark.qss @@ -131,10 +131,6 @@ StyleMenu QCheckBox#fill-btn::indicator { image: url(:/icon/res/fill-light) } -StyleMenu QCheckBox#width-btn { - background-color: #232323; -} - StyleMenu QCheckBox#width-btn:unchecked:hover { background-color: #323232; } diff --git a/src/menu/menu.qss b/src/menu/menu.qss index 3eaad8a..155a28e 100644 --- a/src/menu/menu.qss +++ b/src/menu/menu.qss @@ -32,15 +32,7 @@ RecordMenu QCheckBox#stop-btn::indicator { /*///////////////////////////////// Edit Menu //////////////////////////////*/ ImageEditMenu QCheckBox { - font-size: 9pt; - max-height: 2.5em; - max-width: 2.5em; - min-height: 2.5em; - min-width: 2.5em; - spacing: 0px; - margin: 0px; - border: 0px; } ImageEditMenu QCheckBox::indicator { @@ -96,24 +88,23 @@ ImageEditMenu QCheckBox#ok-btn::indicator { } /*///////////////////////////////// Style Menu //////////////////////////////*/ +StyleMenu { + font-size: 9pt; + max-height: 2.5em; +} StyleMenu QComboBox { - font-size: 11pt; + font-size: 9pt; max-width: 10em; min-width: 4em; } StyleMenu QCheckBox { font-size: 9pt; + spacing: 0px; - max-height: 2.5em; max-width: 2.5em; - min-height: 2.5em; - min-width: 2.5em; - - spacing: 0px; - margin: 0px; - border: 0px; + max-height: 2.5em; } StyleMenu QCheckBox::indicator { @@ -130,9 +121,15 @@ StyleMenu QCheckBox#width-btn:checked { StyleMenu QCheckBox#width-btn::indicator { padding: 0px; + margin: 0px; subcontrol-position: center center; background-color: white; + + height: 0.5em; + width: 0.5em; + margin: 1em; + border-radius: 0.25em; } StyleMenu QCheckBox#width-btn::indicator:checked { @@ -140,10 +137,11 @@ StyleMenu QCheckBox#width-btn::indicator:checked { } StyleMenu QCheckBox#fill-btn::indicator:checked { - image: url(:/icon/res/fill) + image: url(:/icon/res/fill); } StyleMenu ColorPanel { font-size: 9pt; - min-height: 2.45em; + padding: 0.5em; + background-color: blue; } diff --git a/src/menu/stylemenu.cpp b/src/menu/stylemenu.cpp index 50c5b54..b865fe8 100644 --- a/src/menu/stylemenu.cpp +++ b/src/menu/stylemenu.cpp @@ -1,10 +1,9 @@ #include "stylemenu.h" -#include #include -#include #include #include #include "separator.h" +#include "combobox.h" StyleMenu::StyleMenu(int buttons, QWidget* parent) : EditMenu(parent) @@ -38,59 +37,34 @@ StyleMenu::StyleMenu(int buttons, QWidget* parent) layout()->setSpacing(3); layout()->setContentsMargins({ 5, 0, 0, 0 }); - // font family - font_family_ = new QComboBox(this); - font_family_->setObjectName("font-family"); - font_family_->setView(new QListView()); // qss - font_family_->view()->window()->setWindowFlag(Qt::FramelessWindowHint); - font_family_->view()->window()->setWindowFlag(Qt::NoDropShadowWindowHint); - font_family_->view()->window()->setAttribute(Qt::WA_TranslucentBackground); QFontDatabase font_db; - foreach(const QString & family, font_db.families()) { - font_family_->addItem(family); - #if WIN32 - if (family == "微软雅黑") { - font_family_->setCurrentText(family); - } + QString family = "微软雅黑"; + #else - if (family == "宋体") { - font_family_->setCurrentText(family); - } + QString family = "宋体"; #endif - } + // font family + font_family_ = new ComboBox(this); + font_family_->add(font_db.families()).setCurrentText(family); addWidget(font_family_); // font style - font_style_ = new QComboBox(this); - font_style_->setObjectName("font-style"); - font_style_->setView(new QListView()); - font_style_->view()->window()->setWindowFlag(Qt::FramelessWindowHint); - font_style_->view()->window()->setWindowFlag(Qt::NoDropShadowWindowHint); - font_style_->view()->window()->setAttribute(Qt::WA_TranslucentBackground); - foreach(const QString & style, font_db.styles(font_db.families()[0])) { - font_style_->addItem(style); - } + font_style_ = new ComboBox(this); + font_style_->addItems(font_db.styles(family)); connect(font_style_, SIGNAL(activated(int)), this, SIGNAL(changed())); // set style for family - connect(font_style_, &QComboBox::currentTextChanged, [=](const QString& family) { + connect(font_family_, &QComboBox::currentTextChanged, [=](const QString& family) { font_style_->clear(); - foreach(const QString & style, font_db.styles(family)) { - font_style_->addItem(style); - } + font_style_->addItems(font_db.styles(family)); emit changed(); }); addWidget(font_style_); // font size - font_size_ = new QComboBox(); - font_size_->setObjectName("font-size"); - font_size_->setView(new QListView()); + font_size_ = new ComboBox(); font_size_->setEditable(true); font_size_->lineEdit()->setFocusPolicy(Qt::NoFocus); - font_size_->view()->window()->setWindowFlag(Qt::FramelessWindowHint); - font_size_->view()->window()->setWindowFlag(Qt::NoDropShadowWindowHint); - font_size_->view()->window()->setAttribute(Qt::WA_TranslucentBackground); foreach(const int& s, font_db.standardSizes()) { font_size_->addItem(QString::number(s)); } diff --git a/src/menu/stylemenu.h b/src/menu/stylemenu.h index c57b0ba..2cb368d 100644 --- a/src/menu/stylemenu.h +++ b/src/menu/stylemenu.h @@ -1,9 +1,9 @@ #ifndef CAPTURER_STYLE_MENU_H #define CAPTURER_STYLE_MENU_H -#include #include #include "editmenu.h" +#include "combobox.h" #include "colorpanel.h" #include "widthbutton.h" #include "buttongroup.h" @@ -62,9 +62,9 @@ class StyleMenu : public EditMenu private: WidthButton* width_btn_{ nullptr }; QCheckBox* fill_btn_{ nullptr }; - QComboBox* font_family_{ nullptr }; - QComboBox* font_size_{ nullptr }; - QComboBox* font_style_{ nullptr }; + ComboBox* font_family_{ nullptr }; + ComboBox* font_size_{ nullptr }; + ComboBox* font_style_{ nullptr }; ColorPanel* color_panel_{ nullptr }; const int HEIGHT = 35; diff --git a/src/record/screenrecorder.h b/src/record/screenrecorder.h index 6fb75d6..6fc40bc 100644 --- a/src/record/screenrecorder.h +++ b/src/record/screenrecorder.h @@ -97,10 +97,11 @@ public slots: QTimer* timer_{ nullptr }; + // TODO: the low level often generate a whole gray gif while the recording area is simply black. std::map gif_filters_{ {"high", "[0:v] split [a][b];[a] palettegen=stats_mode=single:max_colors=256 [p];[b][p] paletteuse=new=1"}, {"medium", "[0:v] split [a][b];[a] palettegen=stats_mode=single:max_colors=128 [p];[b][p] paletteuse=new=1:dither=none"}, - {"low", "[0:v] split [a][b];[a] palettegen=stats_mode=single:max_colors=64 [p];[b][p] paletteuse=new=1:dither=none"}, + {"low", "[0:v] split [a][b];[a] palettegen=stats_mode=single:max_colors=96 [p];[b][p] paletteuse=new=1:dither=none"}, }; std::map video_qualities_ = { diff --git a/src/setting/settingdialog.cpp b/src/setting/settingdialog.cpp index 46fdd35..b45b25d 100644 --- a/src/setting/settingdialog.cpp +++ b/src/setting/settingdialog.cpp @@ -6,6 +6,9 @@ #include #include #include +#include +#include +#include #include "combobox.h" #include "shortcutinput.h" #include "colorpanel.h" @@ -40,24 +43,39 @@ SettingWindow::SettingWindow(QWidget * parent) effect->setColor(QColor(0, 0, 0, 50)); window->setGraphicsEffect(effect); - auto layout = new QVBoxLayout(); - layout->setSpacing(0); - layout->setContentsMargins({}); - window->setLayout(layout); + // + auto wrapper_layer = new QVBoxLayout(); + wrapper_layer->setSpacing(0); + wrapper_layer->setContentsMargins({}); + window->setLayout(wrapper_layer); // title bar auto titlebar = new TitleBar(); titlebar->setTitle(tr("Settings")); connect(titlebar, &TitleBar::close, this, &QWidget::close); - connect(titlebar, &TitleBar::moved, this, [this](const QPoint& m) { - this->move(this->pos() + m); + connect(titlebar, &TitleBar::moved, [this](const QPoint& m) { + move(pos() + m); }); - layout->addWidget(titlebar); + wrapper_layer->addWidget(titlebar); - tabwidget_ = new AppTabControl(45, 200); - tabwidget_->setObjectName("firstmenu"); - tabwidget_->tabBar()->setObjectName("fristtab"); - layout->addWidget(tabwidget_); + auto layout = new QHBoxLayout(); + layout->setSpacing(0); + layout->setContentsMargins({}); + wrapper_layer->addLayout(layout); + + auto menu = new QListWidget(); + menu->setFocusPolicy(Qt::NoFocus); + menu->addItem(new QListWidgetItem(tr("General"))); + menu->addItem(new QListWidgetItem(tr("Shortcuts"))); + menu->addItem(new QListWidgetItem(tr("Screenshot"))); + menu->addItem(new QListWidgetItem(tr("Screen Recording"))); + menu->addItem(new QListWidgetItem(tr("GIF Recording"))); + menu->addItem(new QListWidgetItem(tr("Devices"))); + menu->addItem(new QListWidgetItem(tr("About"))); + layout->addWidget(menu); + + pages_ = new QStackedWidget(); + layout->addWidget(pages_); setupGeneralWidget(); setupHotkeyWidget(); @@ -66,11 +84,16 @@ SettingWindow::SettingWindow(QWidget * parent) setupGIFWidget(); setupDevicesWidget(); setupAboutWidget(); + + connect(menu, &QListWidget::currentItemChanged, [=](auto current, auto){ + pages_->setCurrentIndex(menu->row(current)); + }); + menu->setCurrentRow(0); } void SettingWindow::setupGeneralWidget() { - auto index = tabwidget_->addTab(new QWidget(), tr("General")); + auto general_widget = new QWidget(pages_); auto layout = new QGridLayout(); layout->setContentsMargins(35, 10, 35, 15); @@ -117,12 +140,13 @@ void SettingWindow::setupGeneralWidget() layout->addWidget(_3_2, 3, 1, 1, 2); layout->setRowStretch(4, 1); - tabwidget_->widget(index)->setLayout(layout); + general_widget->setLayout(layout); + pages_->addWidget(general_widget); } void SettingWindow::setupSnipWidget() { - auto index = tabwidget_->addTab(new QWidget(), tr("Screenshot")); + auto snip_widget = new QWidget(pages_); auto layout = new QGridLayout(); layout->setContentsMargins(35, 10, 35, 15); @@ -164,12 +188,13 @@ void SettingWindow::setupSnipWidget() layout->addWidget(_4_2, 4, 2, 1, 2); layout->setRowStretch(5, 1); - tabwidget_->widget(index)->setLayout(layout); + snip_widget->setLayout(layout); + pages_->addWidget(snip_widget); } void SettingWindow::setupRecordWidget() { - auto index = tabwidget_->addTab(new QWidget(), tr("Screen Recording")); + auto record_widget = new QWidget(pages_); auto layout = new QGridLayout(); layout->setContentsMargins(35, 10, 35, 15); @@ -266,12 +291,13 @@ void SettingWindow::setupRecordWidget() layout->setRowStretch(11, 1); - tabwidget_->widget(index)->setLayout(layout); + record_widget->setLayout(layout); + pages_->addWidget(record_widget); } void SettingWindow::setupGIFWidget() { - auto index = tabwidget_->addTab(new QWidget(), tr("GIF Recording")); + auto gif_widget = new QWidget(); auto layout = new QGridLayout(); layout->setContentsMargins(35, 10, 35, 15); @@ -348,12 +374,13 @@ void SettingWindow::setupGIFWidget() layout->addWidget(_8_2, 9, 2, 1, 2); layout->setRowStretch(10, 1); - tabwidget_->widget(index)->setLayout(layout); + gif_widget->setLayout(layout); + pages_->addWidget(gif_widget); } void SettingWindow::setupDevicesWidget() { - auto index = tabwidget_->addTab(new QWidget(), tr("Devices")); + auto devices_widget = new QWidget(pages_); auto layout = new QGridLayout(); layout->setContentsMargins(35, 10, 35, 15); @@ -384,12 +411,13 @@ void SettingWindow::setupDevicesWidget() layout->setRowStretch(5, 1); - tabwidget_->widget(index)->setLayout(layout); + devices_widget->setLayout(layout); + pages_->addWidget(devices_widget); } void SettingWindow::setupHotkeyWidget() { - auto index = tabwidget_->addTab(new QWidget(), tr("Shortcuts")); + auto hotkey_widget = new QWidget(pages_); auto idx_row = 1; auto layout = new QGridLayout(); @@ -432,15 +460,17 @@ void SettingWindow::setupHotkeyWidget() layout->addWidget(_4_2, idx_row++, 2, 1, 3); layout->setRowStretch(idx_row, 1); - tabwidget_->widget(index)->setLayout(layout); + hotkey_widget->setLayout(layout); + pages_->addWidget(hotkey_widget); } void SettingWindow::setupAboutWidget() { - auto index = tabwidget_->addTab(new QWidget(), tr("About")); + auto about_widget = new QWidget(pages_); + pages_->addWidget(about_widget); auto parent_layout = new QVBoxLayout(); - tabwidget_->widget(index)->setLayout(parent_layout); + about_widget->setLayout(parent_layout); parent_layout->setContentsMargins(35, 10, 35, 15); ///// diff --git a/src/setting/settingdialog.h b/src/setting/settingdialog.h index 997698d..c0093a1 100644 --- a/src/setting/settingdialog.h +++ b/src/setting/settingdialog.h @@ -1,7 +1,7 @@ #ifndef SETTING_DIALOG_H #define SETTING_DIALOG_H -#include "apptabcontrol.h" +#include #include "config.h" class SettingWindow : public QWidget @@ -26,7 +26,7 @@ private slots: Config& config = Config::instance(); - AppTabControl* tabwidget_{ nullptr }; + QStackedWidget* pages_{ nullptr }; }; #endif // SETTING_DIALOG_H diff --git a/src/setting/settingswindow-dark.qss b/src/setting/settingswindow-dark.qss index 49f8f57..0c54d3b 100644 --- a/src/setting/settingswindow-dark.qss +++ b/src/setting/settingswindow-dark.qss @@ -1,39 +1,36 @@ -#settings-mainwindow { - background-color: #202021; -} - -#settings-mainwindow QWidget { +SettingWindow * { color: #e6e6e6; } -/*///////////////////////////////////////////////////////////////*/ TitleBar { background-color: #272728; } -QLabel#logo { +TitleBar QCheckBox#logo { background-color: #202021; } -QLabel#title { - background-color: #202021; +TitleBar QCheckBox#close-btn::indicator { + image: url(:/icon/res/close-light); } -TitleBar QCheckBox#close-btn::indicator { - image: url(:/icon/res/close-light) +SettingWindow QListWidget { + background-color: #202021; } -/*///////////////////////////////////////////////////////////////*/ +SettingWindow QListWidget:item { + color: #e6e6e6; +} -QTabWidget#firstmenu::pane { +SettingWindow QListWidget:item:hover, +SettingWindow QListWidget:item:selected { background: #272728; } -QTabBar#fristtab::tab { - color: #e6e6e6; +SettingWindow QStackedWidget { + background-color: #272728; } -QTabBar#fristtab::tab:selected, -QTabBar#fristtab::tab:hover { - background: #272728; +SettingWindow #copyright-label { + color: #e6e6e6; } diff --git a/src/setting/settingswindow-light.qss b/src/setting/settingswindow-light.qss index 3541e0c..6a8fab9 100644 --- a/src/setting/settingswindow-light.qss +++ b/src/setting/settingswindow-light.qss @@ -1,39 +1,41 @@ -#settings-mainwindow { - background-color: #f5f7fa; +SettingWindow * { + color: #333333; } -#settings-mainwindow QWidget { - color: #333; +TitleBar { + background-color: #fcfbfb; } -/*///////////////////////////////////////////////////////////////*/ -TitleBar { - background-color: #fcfdfe; +TitleBar QCheckBox#logo { + background-color: #f4f6f6; +} + +TitleBar QCheckBox#close-btn::indicator { + image: url(:/icon/res/close-dark); } -QLabel#logo { - background-color: #f5f7fa; +SettingWindow QListWidget { + background-color: #f4f6f6; } -QLabel#title { - color: #50505f; - background-color: #f5f7fa; +SettingWindow QListWidget:item { + color: #1a1a1a; } -TitleBar QCheckBox#close-btn::indicator { - image: url(:/icon/res/close-dark) +SettingWindow QListWidget:item:hover, +SettingWindow QListWidget:item:selected { + background: #e5e7e7; } -/*///////////////////////////////////////////////////////////////*/ -QTabWidget#firstmenu::pane { - background: #fcfdfe; +SettingWindow QStackedWidget { + background-color: #fcfbfb; } -QTabBar#fristtab::tab { - color: #50505f; +SettingWindow ShortcutInput { + color: #363636; } -QTabBar#fristtab::tab:selected, -QTabBar#fristtab::tab:hover { - background: #e3e4e8; +SettingWindow #copyright-label { + color: #363636; + font-size: 11pt; } diff --git a/src/setting/settingswindow.qss b/src/setting/settingswindow.qss index 51c6d0c..d5ee262 100644 --- a/src/setting/settingswindow.qss +++ b/src/setting/settingswindow.qss @@ -1,28 +1,27 @@ -#settings-mainwindow QWidget { - font-size: 10pt; - font-family: "Microsoft Yahei"; -} - /*///////////////////////////////////////////////////////////////*/ -TitleBar { - height: 50px; +TitleBar QCheckBox { + spacing: 0px; + margin: 0px; } -QLabel#title { - height: 50px; - padding-left: 15px; - - font-size: 16pt; - font-family: "华文新魏"; +TitleBar QCheckBox#logo { + font-size: 11pt; + min-width: 9em; + max-width: 9em; + padding-top: 0.15em; } -TitleBar QCheckBox { - spacing: 0px; +TitleBar QCheckBox#logo::indicator { + image: url(:/icon/res/capturer); + font-size: 9pt; + height: 2.25em; + width: 2.25em; + + padding: 0.25em 1.25em 0.25em 1.25em; } TitleBar QCheckBox#close-btn::indicator { font-size: 9pt; - height: 1.25em; width: 1.25em; @@ -31,30 +30,26 @@ TitleBar QCheckBox#close-btn::indicator { TitleBar QCheckBox#close-btn::indicator:hover { background-color: #e81123; - image: url(:/icon/res/close-light) + image: url(:/icon/res/close-light); } -/*///////////////////////////////////////////////////////////////*/ - -QTabWidget#firstmenu::pane { +SettingWindow QListWidget { + font-size: 11pt; + min-width: 9em; + max-width: 9em; border: none; } -QTabWidget#firstmenu::tab-bar { -} - -QTabBar#fristtab::tab { - margin: 0; - padding: 0; - font-size: 11pt; - font-family: "Microsoft Yahei"; - background-color: transparent; - margin: 2px 7px; +SettingWindow QListWidget::item { + height: 2em; + border: none; border-radius: 5px; + padding: 0.25em 0em 0.25em 1.5em; + margin: 0.15em 0.35em; } /*///////////////////////////////////////////////////////////////*/ -ShortcutInput:focus { +SettingWindow ShortcutInput:focus { color: #409eff; } @@ -64,11 +59,10 @@ ColorDialogButton { margin: 1px 0px; } -#sub-title { +SettingWindow #sub-title { font-weight: bold; } -#copyright-label { - color: #888888; - font-size: 12pt; +SettingWindow #copyright-label { + font-size: 11pt; } diff --git a/src/widgets/apptabbar.cpp b/src/widgets/apptabbar.cpp deleted file mode 100644 index 87ed610..0000000 --- a/src/widgets/apptabbar.cpp +++ /dev/null @@ -1,40 +0,0 @@ -#include "apptabbar.h" -#include -#include -#include - -QSize AppTabBar::tabSizeHint(int index) const -{ - QSize s = QTabBar::tabSizeHint(index); - s.setWidth(width_); - s.setHeight(height_); - s.transpose(); - return s; -} - -void AppTabBar::paintEvent(QPaintEvent* event) -{ - QStylePainter painter(this); - QStyleOptionTab opt; - - for (int i = 0; i < this->count(); i++) { - initStyleOption(&opt, i); - painter.drawControl(QStyle::CE_TabBarTabShape, opt); - painter.save(); - - QSize s = opt.rect.size(); - s.transpose(); - QRect r(QPoint(), s); - r.moveCenter(opt.rect.center()); - opt.rect = r; - - QPoint c = tabRect(i).center(); - painter.translate(c); - painter.rotate(90); - painter.translate(-c); - painter.drawControl(QStyle::CE_TabBarTabLabel, opt); - painter.restore(); - } - - QWidget::paintEvent(event); -} diff --git a/src/widgets/apptabbar.h b/src/widgets/apptabbar.h deleted file mode 100644 index 0323602..0000000 --- a/src/widgets/apptabbar.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef APP_TAB_BAR_H -#define APP_TAB_BAR_H - -#include - -class AppTabBar : public QTabBar -{ -public: - explicit AppTabBar(QWidget *parent = nullptr) - : QTabBar(parent) - { - setCursor(Qt::PointingHandCursor); - } - - AppTabBar(int tab_width, int tab_height, QWidget *parent = nullptr) - : QTabBar(parent), width_(tab_width), height_(tab_height) - { - setCursor(Qt::PointingHandCursor); - } - - QSize tabSizeHint(int index) const override; - ~AppTabBar() override = default; - -protected: - void paintEvent(QPaintEvent *event) override; - -private: - int width_ = 30; - int height_ = 115; -}; - -#endif // APP_TAB_BAR_H diff --git a/src/widgets/apptabcontrol.cpp b/src/widgets/apptabcontrol.cpp deleted file mode 100644 index 8766bbd..0000000 --- a/src/widgets/apptabcontrol.cpp +++ /dev/null @@ -1,20 +0,0 @@ -#include "apptabcontrol.h" - -AppTabControl::AppTabControl(QWidget *parent) : QTabWidget(parent) -{ - setTabBar(new AppTabBar(width_, height_, parent)); - setTabPosition(QTabWidget::West); -} - -AppTabControl::AppTabControl(int width, int height, QWidget *parent) - : QTabWidget(parent), width_(width), height_(height) -{ - setTabBar(new AppTabBar(width_, height_, parent)); - setTabPosition(QTabWidget::West); -} - -void AppTabControl::setTabControlSize(int width, int height) -{ - width_ = width; - height_ = height; -} \ No newline at end of file diff --git a/src/widgets/apptabcontrol.h b/src/widgets/apptabcontrol.h deleted file mode 100644 index 2a627fd..0000000 --- a/src/widgets/apptabcontrol.h +++ /dev/null @@ -1,22 +0,0 @@ -#ifndef APP_TAB_CONTROL_H -#define APP_TAB_CONTROL_H - -#include -#include "apptabbar.h" - -class AppTabControl : public QTabWidget -{ -public: - AppTabControl() = default; - explicit AppTabControl(QWidget *parent); - AppTabControl(int width, int height, QWidget *parent = nullptr); - - void setTabControlSize(int width, int height); - ~AppTabControl() override = default; - -private: - int width_{ 0 }; - int height_{ 0 }; -}; - -#endif // APP_TAB_CONTROL_H \ No newline at end of file diff --git a/src/widgets/colorpanel.cpp b/src/widgets/colorpanel.cpp index 7986a51..f276355 100644 --- a/src/widgets/colorpanel.cpp +++ b/src/widgets/colorpanel.cpp @@ -84,7 +84,7 @@ ColorPanel::ColorPanel(QWidget * parent) : QWidget(parent) { auto layout = new QGridLayout(); - layout->setContentsMargins(5, 0, 5, 0); + layout->setContentsMargins(5, 5, 5, 5); layout->setVerticalSpacing(1); layout->setHorizontalSpacing(2); diff --git a/src/widgets/combobox.h b/src/widgets/combobox.h index 16bf3f0..084564c 100644 --- a/src/widgets/combobox.h +++ b/src/widgets/combobox.h @@ -19,7 +19,7 @@ class ComboBox : public QComboBox { }); } - inline ComboBox& add(const std::map& items) + inline ComboBox& add(const std::vector>& items) { for (auto& [value, text] : items) { insertItem(count(), text, value); diff --git a/src/widgets/titlebar.cpp b/src/widgets/titlebar.cpp index 2d93f63..f337540 100644 --- a/src/widgets/titlebar.cpp +++ b/src/widgets/titlebar.cpp @@ -3,7 +3,6 @@ #include #include #include -#include TitleBar::TitleBar(QWidget *parent) : QWidget(parent) @@ -17,23 +16,12 @@ TitleBar::TitleBar(QWidget *parent) setLayout(layout); // logo & title - auto icon_label = new QLabel(this); - icon_label->setObjectName("logo"); - auto logo = QPixmap(":/icon/res/capturer"); - icon_label->setPixmap(logo); - icon_label->setFixedSize(60, 50); - icon_label->setContentsMargins({ 20, 10, 10, 10 }); - icon_label->setScaledContents(true); - - title_label_ = new QLabel("", this); - title_label_->setFixedWidth(140); - title_label_->setObjectName("title"); - - layout->addWidget(icon_label); - layout->addWidget(title_label_); + logo_ = new QCheckBox(); + logo_->setObjectName("logo"); + layout->addWidget(logo_); // blank - layout->addSpacerItem(new QSpacerItem(20, 50, QSizePolicy::Expanding, QSizePolicy::Minimum)); + layout->addSpacerItem(new QSpacerItem(10, 10, QSizePolicy::Expanding, QSizePolicy::Minimum)); // close button auto close_btn = new QCheckBox(this); diff --git a/src/widgets/titlebar.h b/src/widgets/titlebar.h index 29864a6..4418338 100644 --- a/src/widgets/titlebar.h +++ b/src/widgets/titlebar.h @@ -1,20 +1,17 @@ #ifndef TITLE_BAR_H #define TITLE_BAR_H -#include -#include +#include class TitleBar : public QWidget { Q_OBJECT public: explicit TitleBar(QWidget* = nullptr); - void setTitle(const QString& title) { title_label_->setText(title); } + void setTitle(const QString& title) { logo_->setText(title); } signals: void close(); - void maximize(); - void minimize(); void normal(); void moved(const QPoint&); @@ -24,7 +21,7 @@ class TitleBar : public QWidget { void mouseReleaseEvent(QMouseEvent*) override; private: - QLabel* title_label_{ nullptr }; + QCheckBox* logo_{ nullptr }; QPoint begin_{ 0, 0 }; bool moving_{ false }; diff --git a/src/widgets/widthbutton.cpp b/src/widgets/widthbutton.cpp index 287e3be..18a1732 100644 --- a/src/widgets/widthbutton.cpp +++ b/src/widgets/widthbutton.cpp @@ -7,10 +7,10 @@ void WidthButton::setValue(int width) width_ = std::clamp(width, min_, max_); const double max_em = 2.5; - double width_em = ((double)width_ / max_) * max_em; + double width_em = ((double)width_ / max_) * 1.75; - std::string style = fmt::format("WidthButton::indicator{{ height: {}em; width: {}em; margin: {}em; border-radius: {}em; }}", - width_em, width_em, (max_em - width_em) * 4.95, width_em * 0.45); + std::string style = fmt::format("WidthButton::indicator{{ height: {:2.1f}em; width: {:2.1f}em; margin: {:4.3f}em; border-radius: {:4.3f}em; }}", + width_em, width_em, (static_cast((max_em - width_em) * 49.9)) / 100.0, width_em * 0.485); setStyleSheet(QString::fromStdString(style)); diff --git a/src/widgets/widthbutton.h b/src/widgets/widthbutton.h index b6244ac..249829c 100644 --- a/src/widgets/widthbutton.h +++ b/src/widgets/widthbutton.h @@ -30,7 +30,7 @@ public slots: private: int width_{ 2 }; - int max_{ 25 }; + int max_{ 24 }; int min_{ 1 }; };