From 83e1b88c2cce426b792dbc837bb902e60f539245 Mon Sep 17 00:00:00 2001 From: luisangelsm Date: Tue, 17 Mar 2026 19:35:30 +0100 Subject: [PATCH] Replace goto.png with a themeable svg image --- YACReader/goto_dialog.cpp | 10 +++++++--- YACReader/goto_dialog.h | 8 +++++++- YACReader/themes/builtin_classic.json | 3 +++ YACReader/themes/builtin_dark.json | 3 +++ YACReader/themes/builtin_light.json | 3 +++ YACReader/themes/theme.h | 1 + YACReader/themes/theme_factory.cpp | 10 ++++++++++ YACReader/yacreader_images.qrc | 2 +- images/goto.png | Bin 908 -> 0 bytes images/goto.svg | 11 +++++++++++ 10 files changed, 46 insertions(+), 5 deletions(-) delete mode 100644 images/goto.png create mode 100644 images/goto.svg diff --git a/YACReader/goto_dialog.cpp b/YACReader/goto_dialog.cpp index f442b93b..d0c5b12e 100644 --- a/YACReader/goto_dialog.cpp +++ b/YACReader/goto_dialog.cpp @@ -8,6 +8,7 @@ GoToDialog::GoToDialog(QWidget *parent) : QDialog(parent) { setupUI(); + initTheme(this); } void GoToDialog::setupUI() @@ -42,9 +43,7 @@ void GoToDialog::setupUI() mainLayout->addLayout(bottomLayout); auto imgMainLayout = new QHBoxLayout; - auto imgLabel = new QLabel(); - QPixmap p(":/images/goto.png"); - imgLabel->setPixmap(p); + imgLabel = new QLabel(); imgMainLayout->addWidget(imgLabel); imgMainLayout->addLayout(mainLayout); @@ -78,3 +77,8 @@ void GoToDialog::open() pageNumber->setFocus(); QDialog::open(); } + +void GoToDialog::applyTheme(const Theme &theme) +{ + imgLabel->setPixmap(theme.dialogIcons.goToDialogIcon); +} diff --git a/YACReader/goto_dialog.h b/YACReader/goto_dialog.h index e62f8d2d..339104d1 100644 --- a/YACReader/goto_dialog.h +++ b/YACReader/goto_dialog.h @@ -1,21 +1,27 @@ #ifndef __GOTODIALOG_H #define __GOTODIALOG_H +#include "themable.h" + #include #include #include #include #include -class GoToDialog : public QDialog +class GoToDialog : public QDialog, protected Themable { Q_OBJECT public: GoToDialog(QWidget *parent = nullptr); +protected: + void applyTheme(const Theme &theme) override; + private: QLabel *numPagesLabel; QLabel *textLabel; + QLabel *imgLabel; QLineEdit *pageNumber; QIntValidator *v; QPushButton *accept; diff --git a/YACReader/themes/builtin_classic.json b/YACReader/themes/builtin_classic.json index fcac45c7..3b0b217e 100644 --- a/YACReader/themes/builtin_classic.json +++ b/YACReader/themes/builtin_classic.json @@ -1,4 +1,7 @@ { + "dialogIcons": { + "iconColor": "#404040" + }, "goToFlowWidget": { "editBackgroundColor": "#55000000", "editBorderColor": "#77000000", diff --git a/YACReader/themes/builtin_dark.json b/YACReader/themes/builtin_dark.json index 7efd26ae..3dc7b9d3 100644 --- a/YACReader/themes/builtin_dark.json +++ b/YACReader/themes/builtin_dark.json @@ -1,4 +1,7 @@ { + "dialogIcons": { + "iconColor": "#cccccc" + }, "goToFlowWidget": { "editBackgroundColor": "#55000000", "editBorderColor": "#77000000", diff --git a/YACReader/themes/builtin_light.json b/YACReader/themes/builtin_light.json index dc9209f7..274788b8 100644 --- a/YACReader/themes/builtin_light.json +++ b/YACReader/themes/builtin_light.json @@ -1,4 +1,7 @@ { + "dialogIcons": { + "iconColor": "#404040" + }, "goToFlowWidget": { "editBackgroundColor": "#22000000", "editBorderColor": "#33000000", diff --git a/YACReader/themes/theme.h b/YACReader/themes/theme.h index f5c07351..1355dfbe 100644 --- a/YACReader/themes/theme.h +++ b/YACReader/themes/theme.h @@ -182,6 +182,7 @@ struct ShortcutsIconsTheme { struct DialogIconsTheme { QIcon findFolderIcon; + QPixmap goToDialogIcon; }; struct Theme { diff --git a/YACReader/themes/theme_factory.cpp b/YACReader/themes/theme_factory.cpp index deb85517..42f07fe8 100644 --- a/YACReader/themes/theme_factory.cpp +++ b/YACReader/themes/theme_factory.cpp @@ -56,6 +56,10 @@ struct ShortcutsIconsParams { QColor iconColor; // Main icon color (replaces #f0f) }; +struct DialogIconsParams { + QColor iconColor; // Main icon color (replaces #f0f) +}; + struct TranslatorParams { TranslatorThemeTemplates t; @@ -79,6 +83,7 @@ struct ThemeParams { HelpAboutDialogTheme helpAboutDialogParams; WhatsNewDialogParams whatsNewDialogParams; ShortcutsIconsParams shortcutsIconsParams; + DialogIconsParams dialogIconsParams; TranslatorParams translatorParams; }; @@ -340,6 +345,11 @@ Theme makeTheme(const QJsonObject &json) p.shortcutsIconsParams.iconColor = colorFromJson(s, "iconColor", p.shortcutsIconsParams.iconColor); } + if (json.contains("dialogIcons")) { + const auto o = json["dialogIcons"].toObject(); + p.dialogIconsParams.iconColor = colorFromJson(o, "iconColor", p.dialogIconsParams.iconColor); + } + if (json.contains("translator")) { const auto t = json["translator"].toObject(); auto &tp = p.translatorParams; diff --git a/YACReader/yacreader_images.qrc b/YACReader/yacreader_images.qrc index a5b011ed..a573b9fb 100644 --- a/YACReader/yacreader_images.qrc +++ b/YACReader/yacreader_images.qrc @@ -1,7 +1,7 @@ ../images/icon-new.svg - ../images/goto.png + ../images/goto.svg ../images/find_folder.svg ../images/flow1.png ../images/flow2.png diff --git a/images/goto.png b/images/goto.png deleted file mode 100644 index d99a3d013cf6269179d60d2d77d95e5b0cc44750..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 908 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7uRSk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*9U+nDsne978H@y}7e7NW@X#*vF@R2R=9*`pRoyTzpn#_k}ac z#?9so^BF3cOqw|=n2t^8c+7d{f`F0H3%%tZPBm$Zq?IlE{eSf=D~~C&|L#gJ&-*?L zq_a})}GSy#Rf(57;S$@HN~zM-tcG-^BuiER?|01I?cGu_=2s3pw3(*54r=R74Z_uSAJj-@ zjhtaod{^Om>H`(OJKH8!8eirOVtugj^m5yoTa1;xn>zC*XfY(-3|-VS->T3^t%P|t zpr1kGzhVOa4}DvAaGyev|NzJ5Sfoiajz#y)pjZN0mbB zG8S9+85eoA-ZT8a$SU`WOWnwC=`263R}7)0%~u#NZ2sFF@$mdo#UBgT>u>c*;W$uh zK4pL9^;m{SD%sihs~^^H>%Y3RamMKheyU$sN?y}X zz6}>RuO+L`n9yjn%kf$@)8pAS^4Bv&Hsl+eux%`9D%y2Wp`7(H=c$)$&G$ro)Ft*w z^Zbf&s3~4Q`}lkL1=1?-*j#PI1-^5ZY%e%gc>Xr;G1WcRchx5pYF$5i{nKmqzVdyw z&5PuCC%4p3oo=qf`LoCSceBdF{VFfr&%T#Eyj^C|Z`A~6t|u3sSRR;E-0TPjn%doi0HKk-t$?SAa4t(=^B|CdP{7r&Bad$9g9 zbFA31kiCZ)Y&MwqXxq9=e0iK;d|yDQT-cOlzE+eR+kV?KPr{EJS+^juBK(C=;2GV- z8utl@SH*9+bs+YtFvIgue}*~Xwu}XFUs(=RQY3&q=>oG>)E!O(2F;X+lgoMK%t5L= MUHx3vIVCg!0Fcgu5dZ)H diff --git a/images/goto.svg b/images/goto.svg new file mode 100644 index 00000000..89ccb810 --- /dev/null +++ b/images/goto.svg @@ -0,0 +1,11 @@ + + + + + + + \ No newline at end of file