diff --git a/YACReader/goto_flow_toolbar.cpp b/YACReader/goto_flow_toolbar.cpp index c0c35de2..2f45af1d 100644 --- a/YACReader/goto_flow_toolbar.cpp +++ b/YACReader/goto_flow_toolbar.cpp @@ -18,19 +18,6 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) quickNavi->setLayout(naviLayout); slider = new QSlider(Qt::Horizontal, this); - slider->setStyleSheet( - "QSlider::groove:horizontal {" - " border: 1px solid #22FFFFFF;" - " border-radius: 1px;" - " background: #77000000;" - " margin: 2px 0;" - " padding: 1px;" - "}" - "QSlider::handle:horizontal {" - " background: #55FFFFFF;" - " width: 48px;" - " border-radius: 1px;" - "}"); connect(slider, &QSlider::valueChanged, this, &GoToFlowToolBar::setCenter); connect(slider, &QSlider::valueChanged, this, &GoToFlowToolBar::setPage); @@ -41,35 +28,25 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) edit = new QLineEdit(); edit->setValidator(v); edit->setAlignment(Qt::AlignRight | Qt::AlignVCenter); - edit->setStyleSheet("QLineEdit {border: 1px solid #77000000; background: #55000000; color: white; padding: 3px 5px 5px 5px; margin: 13px 5px 12px 5px; font-weight:bold}"); edit->setFixedSize(54, 50); edit->setAttribute(Qt::WA_MacShowFocusRect, false); - // edit->setAttribute(Qt::WA_LayoutUsesWidgetRect,true); - // edit->resize(QSize(54,50)); edit->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed)); - // edit->setAutoFillBackground(false); connect(edit, &QLineEdit::returnPressed, this, &GoToFlowToolBar::goTo); - QString centerButtonCSS = "QPushButton {background-image: url(:/images/imgCenterSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} " - "QPushButton:focus { border: none; outline: none;}" - "QPushButton:pressed {background-image: url(:/images/imgCenterSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} "; centerButton = new QPushButton(); - centerButton->setStyleSheet(centerButtonCSS); + centerButton->setIconSize(QSize(12, 12)); centerButton->setFixedSize(26, 50); centerButton->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); connect(centerButton, &QAbstractButton::clicked, this, &GoToFlowToolBar::centerSlide); - QString goToButtonCSS = "QPushButton {background-image: url(:/images/imgGoToSlide.png); width: 100%; height:100%; background-repeat: none; border: none;} " - "QPushButton:focus { border: none; outline: none;}" - "QPushButton:pressed {background-image: url(:/images/imgGoToSlidePressed.png); width: 100%; height:100%; background-repeat: none; border: none;} "; goToButton = new QPushButton(); - goToButton->setStyleSheet(goToButtonCSS); + goToButton->setIconSize(QSize(12, 12)); goToButton->setFixedSize(32, 50); goToButton->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); connect(goToButton, &QPushButton::clicked, this, &GoToFlowToolBar::goTo); goToButton2 = new QPushButton(); - goToButton2->setStyleSheet(goToButtonCSS); + goToButton2->setIconSize(QSize(12, 12)); goToButton2->setFixedSize(32, 50); goToButton2->setAttribute(Qt::WA_LayoutUsesWidgetRect, true); connect(goToButton2, &QPushButton::clicked, this, &GoToFlowToolBar::goTo); @@ -94,12 +71,34 @@ GoToFlowToolBar::GoToFlowToolBar(QWidget *parent) updateOptions(); setFixedHeight(50); + + initTheme(this); +} + +void GoToFlowToolBar::applyTheme(const Theme &theme) +{ + auto goToFlowTheme = theme.goToFlowWidget; + + slider->setStyleSheet(goToFlowTheme.sliderQSS); + edit->setStyleSheet(goToFlowTheme.editQSS); + pageHint->setStyleSheet(goToFlowTheme.labelQSS); + + centerButton->setStyleSheet(goToFlowTheme.buttonQSS); + centerButton->setIcon(goToFlowTheme.centerIcon); + + goToButton->setStyleSheet(goToFlowTheme.buttonQSS); + goToButton->setIcon(goToFlowTheme.goToIcon); + + goToButton2->setStyleSheet(goToFlowTheme.buttonQSS); + goToButton2->setIcon(goToFlowTheme.goToIcon); + + update(); } void GoToFlowToolBar::paintEvent(QPaintEvent *) { QPainter painter(this); - painter.fillRect(0, 0, width(), height(), QColor(0x99000000)); + painter.fillRect(0, 0, width(), height(), theme.goToFlowWidget.toolbarBackgroundColor); } void GoToFlowToolBar::setPage(int pageNumber) diff --git a/YACReader/goto_flow_toolbar.h b/YACReader/goto_flow_toolbar.h index ba5b0d26..615a3511 100644 --- a/YACReader/goto_flow_toolbar.h +++ b/YACReader/goto_flow_toolbar.h @@ -4,15 +4,20 @@ #include #include +#include "themable.h" + class QLineEdit; class QIntValidator; class QPushButton; class QSlider; class QLabel; -class GoToFlowToolBar : public QStackedWidget +class GoToFlowToolBar : public QStackedWidget, protected Themable { Q_OBJECT +protected: + void applyTheme(const Theme &theme) override; + private: QLineEdit *edit; QSlider *slider; diff --git a/YACReader/goto_flow_widget.cpp b/YACReader/goto_flow_widget.cpp index 1fc339d3..782b9b87 100644 --- a/YACReader/goto_flow_widget.cpp +++ b/YACReader/goto_flow_widget.cpp @@ -40,6 +40,16 @@ GoToFlowWidget::GoToFlowWidget(QWidget *parent, FlowType flowType) resize(static_cast(5 * imageSize.width()), toolBar->height() + static_cast(imageSize.height() * 1.7)); this->setCursor(QCursor(Qt::ArrowCursor)); + + initTheme(this); +} + +void GoToFlowWidget::applyTheme(const Theme &theme) +{ + auto goToFlowTheme = theme.goToFlowWidget; + + flow->setBackgroundColor(goToFlowTheme.flowBackgroundColor); + flow->setTextColor(goToFlowTheme.flowTextColor); } GoToFlowWidget::~GoToFlowWidget() diff --git a/YACReader/goto_flow_widget.h b/YACReader/goto_flow_widget.h index df294dfb..6456463a 100644 --- a/YACReader/goto_flow_widget.h +++ b/YACReader/goto_flow_widget.h @@ -6,6 +6,7 @@ #include "yacreader_global_gui.h" #include "yacreader_page_flow_rhi.h" +#include "themable.h" using namespace YACReader; @@ -14,9 +15,12 @@ class GoToFlowToolBar; class QVBoxLayout; class QKeyEvent; -class GoToFlowWidget : public QWidget +class GoToFlowWidget : public QWidget, protected Themable { Q_OBJECT +protected: + void applyTheme(const Theme &theme) override; + public: GoToFlowWidget(QWidget *parent = nullptr, FlowType flowType = CoverFlowLike); ~GoToFlowWidget() override; diff --git a/YACReader/themes/theme.h b/YACReader/themes/theme.h index 719ba61b..0ccec5a0 100644 --- a/YACReader/themes/theme.h +++ b/YACReader/themes/theme.h @@ -16,6 +16,26 @@ struct ViewerThemeTemplates { QString infoLabelQSS = "QLabel { color : %1; font-size:%2px; }"; }; +struct GoToFlowWidgetThemeTemplates { + QString sliderQSS = "QSlider::groove:horizontal {" + " border: 1px solid %1;" + " border-radius: 1px;" + " background: %2;" + " margin: 2px 0;" + " padding: 1px;" + "}" + "QSlider::handle:horizontal {" + " background: %3;" + " width: 48px;" + " border-radius: 1px;" + "}"; + QString editQSS = "QLineEdit {border: 1px solid %1; background: %2; color: %3; padding: 3px 5px 5px 5px; margin: 13px 5px 12px 5px; font-weight:bold}"; + QString buttonQSS = "QPushButton { border: none; padding: 0px; } " + "QPushButton:focus { border: none; outline: none; } " + "QPushButton:pressed { padding-top: 1px; padding-left: 1px; padding-bottom: -1px; padding-right: -1px; }"; + QString labelQSS = "QLabel { color: %1; }"; +}; + struct ToolbarTheme { QString toolbarQSS; @@ -92,9 +112,22 @@ struct ViewerTheme { QString infoLabelQSS; }; +struct GoToFlowWidgetTheme { + QColor flowBackgroundColor; + QColor flowTextColor; + QColor toolbarBackgroundColor; + QString sliderQSS; + QString editQSS; + QString buttonQSS; + QString labelQSS; + QIcon centerIcon; + QIcon goToIcon; +}; + struct Theme { ToolbarTheme toolbar; ViewerTheme viewer; + GoToFlowWidgetTheme goToFlowWidget; }; #endif // THEME_H diff --git a/YACReader/themes/theme_factory.cpp b/YACReader/themes/theme_factory.cpp index 04002b47..603572fb 100644 --- a/YACReader/themes/theme_factory.cpp +++ b/YACReader/themes/theme_factory.cpp @@ -23,11 +23,28 @@ struct ViewerParams { QColor infoTextColor; }; +struct GoToFlowWidgetParams { + GoToFlowWidgetThemeTemplates t; + + QColor flowBackgroundColor; + QColor flowTextColor; + QColor toolbarBackgroundColor; + QColor sliderBorderColor; + QColor sliderGrooveColor; + QColor sliderHandleColor; + QColor editBorderColor; + QColor editBackgroundColor; + QColor editTextColor; + QColor labelTextColor; + QColor iconColor; +}; + struct ThemeParams { QString themeName; ToolbarParams toolbarParams; ViewerParams viewerParams; + GoToFlowWidgetParams goToFlowWidgetParams; }; void setToolbarIconPair(QIcon &icon, @@ -113,6 +130,28 @@ Theme makeTheme(const ThemeParams ¶ms) theme.viewer.infoLabelQSS = params.viewerParams.t.infoLabelQSS.arg(params.viewerParams.infoTextColor.name()); // end Viewer + // GoToFlowWidget + auto &gotoParams = params.goToFlowWidgetParams; + theme.goToFlowWidget.flowBackgroundColor = gotoParams.flowBackgroundColor; + theme.goToFlowWidget.flowTextColor = gotoParams.flowTextColor; + theme.goToFlowWidget.toolbarBackgroundColor = gotoParams.toolbarBackgroundColor; + theme.goToFlowWidget.sliderQSS = gotoParams.t.sliderQSS.arg( + gotoParams.sliderBorderColor.name(QColor::HexArgb), + gotoParams.sliderGrooveColor.name(QColor::HexArgb), + gotoParams.sliderHandleColor.name(QColor::HexArgb)); + theme.goToFlowWidget.editQSS = gotoParams.t.editQSS.arg( + gotoParams.editBorderColor.name(QColor::HexArgb), + gotoParams.editBackgroundColor.name(QColor::HexArgb), + gotoParams.editTextColor.name()); + theme.goToFlowWidget.buttonQSS = gotoParams.t.buttonQSS; + theme.goToFlowWidget.labelQSS = gotoParams.t.labelQSS.arg(gotoParams.labelTextColor.name()); + + const QString centerIconPath = recoloredSvgToThemeFile(":/images/centerFlow.svg", gotoParams.iconColor, params.themeName); + const QString goToIconPath = recoloredSvgToThemeFile(":/images/gotoFlow.svg", gotoParams.iconColor, params.themeName); + theme.goToFlowWidget.centerIcon = QIcon(centerIconPath); + theme.goToFlowWidget.goToIcon = QIcon(goToIconPath); + // end GoToFlowWidget + return theme; } @@ -157,6 +196,22 @@ ThemeParams classicThemeParams() params.viewerParams = viewerParams; + GoToFlowWidgetParams goToFlowWidgetParams; + goToFlowWidgetParams.flowBackgroundColor = QColor(0x282828); + goToFlowWidgetParams.flowTextColor = Qt::white; + goToFlowWidgetParams.toolbarBackgroundColor = QColor::fromRgba(0x99000000); + goToFlowWidgetParams.sliderBorderColor = QColor::fromRgba(0x22FFFFFF); + goToFlowWidgetParams.sliderGrooveColor = QColor::fromRgba(0x77000000); + goToFlowWidgetParams.sliderHandleColor = QColor::fromRgba(0x55FFFFFF); + goToFlowWidgetParams.editBorderColor = QColor::fromRgba(0x77000000); + goToFlowWidgetParams.editBackgroundColor = QColor::fromRgba(0x55000000); + goToFlowWidgetParams.editTextColor = Qt::white; + goToFlowWidgetParams.labelTextColor = Qt::white; + goToFlowWidgetParams.iconColor = Qt::white; + goToFlowWidgetParams.t = GoToFlowWidgetThemeTemplates(); + + params.goToFlowWidgetParams = goToFlowWidgetParams; + return params; } @@ -185,6 +240,22 @@ ThemeParams lightThemeParams() params.viewerParams = viewerParams; + GoToFlowWidgetParams goToFlowWidgetParams; + goToFlowWidgetParams.flowBackgroundColor = QColor(0xF6F6F6); + goToFlowWidgetParams.flowTextColor = QColor(0x202020); + goToFlowWidgetParams.toolbarBackgroundColor = QColor::fromRgba(0xBBFFFFFF); + goToFlowWidgetParams.sliderBorderColor = QColor::fromRgba(0x22000000); + goToFlowWidgetParams.sliderGrooveColor = QColor::fromRgba(0x33000000); + goToFlowWidgetParams.sliderHandleColor = QColor::fromRgba(0x55000000); + goToFlowWidgetParams.editBorderColor = QColor::fromRgba(0x33000000); + goToFlowWidgetParams.editBackgroundColor = QColor::fromRgba(0x22000000); + goToFlowWidgetParams.editTextColor = QColor(0x202020); + goToFlowWidgetParams.labelTextColor = QColor(0x202020); + goToFlowWidgetParams.iconColor = QColor(0x404040); + goToFlowWidgetParams.t = GoToFlowWidgetThemeTemplates(); + + params.goToFlowWidgetParams = goToFlowWidgetParams; + return params; } @@ -213,6 +284,22 @@ ThemeParams darkThemeParams() params.viewerParams = viewerParams; + GoToFlowWidgetParams goToFlowWidgetParams; + goToFlowWidgetParams.flowBackgroundColor = QColor(40, 40, 40); + goToFlowWidgetParams.flowTextColor = Qt::white; + goToFlowWidgetParams.toolbarBackgroundColor = QColor::fromRgba(0x99000000); + goToFlowWidgetParams.sliderBorderColor = QColor::fromRgba(0x22FFFFFF); + goToFlowWidgetParams.sliderGrooveColor = QColor::fromRgba(0x77000000); + goToFlowWidgetParams.sliderHandleColor = QColor::fromRgba(0x55FFFFFF); + goToFlowWidgetParams.editBorderColor = QColor::fromRgba(0x77000000); + goToFlowWidgetParams.editBackgroundColor = QColor::fromRgba(0x55000000); + goToFlowWidgetParams.editTextColor = Qt::white; + goToFlowWidgetParams.labelTextColor = Qt::white; + goToFlowWidgetParams.iconColor = QColor(0xCCCCCC); + goToFlowWidgetParams.t = GoToFlowWidgetThemeTemplates(); + + params.goToFlowWidgetParams = goToFlowWidgetParams; + return params; } diff --git a/YACReader/yacreader_images.qrc b/YACReader/yacreader_images.qrc index ef71304d..ac17f295 100644 --- a/YACReader/yacreader_images.qrc +++ b/YACReader/yacreader_images.qrc @@ -12,10 +12,8 @@ ../images/close.svg ../images/up.png ../images/down.png - ../images/imgCenterSlide.png - ../images/imgGoToSlide.png - ../images/imgCenterSlidePressed.png - ../images/imgGoToSlidePressed.png + ../images/centerFlow.svg + ../images/gotoFlow.svg ../images/defaultCover.png ../images/fromTo.png ../images/dropDownArrow.png diff --git a/images/centerFlow.svg b/images/centerFlow.svg new file mode 100644 index 00000000..ccfb1c17 --- /dev/null +++ b/images/centerFlow.svg @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/images/gotoFlow.svg b/images/gotoFlow.svg new file mode 100644 index 00000000..8c0a7158 --- /dev/null +++ b/images/gotoFlow.svg @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file diff --git a/images/imgCenterSlide.png b/images/imgCenterSlide.png deleted file mode 100644 index 0c50ca86..00000000 Binary files a/images/imgCenterSlide.png and /dev/null differ diff --git a/images/imgCenterSlide@2x.png b/images/imgCenterSlide@2x.png deleted file mode 100644 index eb1108ed..00000000 Binary files a/images/imgCenterSlide@2x.png and /dev/null differ diff --git a/images/imgCenterSlidePressed.png b/images/imgCenterSlidePressed.png deleted file mode 100644 index 66b47ed2..00000000 Binary files a/images/imgCenterSlidePressed.png and /dev/null differ diff --git a/images/imgCenterSlidePressed@2x.png b/images/imgCenterSlidePressed@2x.png deleted file mode 100644 index e6d216b6..00000000 Binary files a/images/imgCenterSlidePressed@2x.png and /dev/null differ diff --git a/images/imgGoToSlide.png b/images/imgGoToSlide.png deleted file mode 100644 index 3187cfc5..00000000 Binary files a/images/imgGoToSlide.png and /dev/null differ diff --git a/images/imgGoToSlide@2x.png b/images/imgGoToSlide@2x.png deleted file mode 100644 index f833be3c..00000000 Binary files a/images/imgGoToSlide@2x.png and /dev/null differ diff --git a/images/imgGoToSlidePressed.png b/images/imgGoToSlidePressed.png deleted file mode 100644 index 76f5b0b1..00000000 Binary files a/images/imgGoToSlidePressed.png and /dev/null differ diff --git a/images/imgGoToSlidePressed@2x.png b/images/imgGoToSlidePressed@2x.png deleted file mode 100644 index 354993d7..00000000 Binary files a/images/imgGoToSlidePressed@2x.png and /dev/null differ