diff --git a/YACReader/themes/theme.h b/YACReader/themes/theme.h index 0ccec5a0..9754f30c 100644 --- a/YACReader/themes/theme.h +++ b/YACReader/themes/theme.h @@ -3,6 +3,8 @@ #include +#include "help_about_dialog_theme.h" + struct ToolbarThemeTemplates { QString toolbarQSS = "QToolBar { border: none; background: %1; }\n" "QToolBar::separator { background: %2; width: 1px; margin: 5px 4px; }\n" @@ -128,6 +130,7 @@ struct Theme { ToolbarTheme toolbar; ViewerTheme viewer; GoToFlowWidgetTheme goToFlowWidget; + HelpAboutDialogTheme helpAboutDialog; }; #endif // THEME_H diff --git a/YACReader/themes/theme_factory.cpp b/YACReader/themes/theme_factory.cpp index 603572fb..d0ecc7d9 100644 --- a/YACReader/themes/theme_factory.cpp +++ b/YACReader/themes/theme_factory.cpp @@ -45,6 +45,7 @@ struct ThemeParams { ToolbarParams toolbarParams; ViewerParams viewerParams; GoToFlowWidgetParams goToFlowWidgetParams; + HelpAboutDialogTheme helpAboutDialogParams; }; void setToolbarIconPair(QIcon &icon, @@ -152,6 +153,10 @@ Theme makeTheme(const ThemeParams ¶ms) theme.goToFlowWidget.goToIcon = QIcon(goToIconPath); // end GoToFlowWidget + // HelpAboutDialog + theme.helpAboutDialog = params.helpAboutDialogParams; + // end HelpAboutDialog + return theme; } @@ -212,6 +217,9 @@ ThemeParams classicThemeParams() params.goToFlowWidgetParams = goToFlowWidgetParams; + params.helpAboutDialogParams.headingColor = QColor(0x302f2d); + params.helpAboutDialogParams.linkColor = QColor(0xC19441); + return params; } @@ -256,6 +264,9 @@ ThemeParams lightThemeParams() params.goToFlowWidgetParams = goToFlowWidgetParams; + params.helpAboutDialogParams.headingColor = QColor(0x302f2d); + params.helpAboutDialogParams.linkColor = QColor(0xC19441); + return params; } @@ -300,6 +311,9 @@ ThemeParams darkThemeParams() params.goToFlowWidgetParams = goToFlowWidgetParams; + params.helpAboutDialogParams.headingColor = QColor(0xE0E0E0); + params.helpAboutDialogParams.linkColor = QColor(0xD4A84B); + return params; } diff --git a/YACReaderLibrary/themes/theme.h b/YACReaderLibrary/themes/theme.h index 0eabd466..ed8b7a1c 100644 --- a/YACReaderLibrary/themes/theme.h +++ b/YACReaderLibrary/themes/theme.h @@ -4,6 +4,7 @@ #include #include "yacreader_icon.h" +#include "help_about_dialog_theme.h" struct ComicVineThemeTemplates { QString defaultLabelQSS = "QLabel {color:%1; font-size:12px;font-family:Arial;}"; @@ -130,6 +131,7 @@ struct ComicVineTheme { struct Theme { ComicFlowColors comicFlow; ComicVineTheme comicVine; + HelpAboutDialogTheme helpAboutDialog; }; #endif // THEME_H diff --git a/YACReaderLibrary/themes/theme_factory.cpp b/YACReaderLibrary/themes/theme_factory.cpp index 6d11c65d..bdd589f4 100644 --- a/YACReaderLibrary/themes/theme_factory.cpp +++ b/YACReaderLibrary/themes/theme_factory.cpp @@ -54,6 +54,7 @@ struct ThemeParams { ComicFlowColors comicFlowColors; ComicVineParams comicVineParams; + HelpAboutDialogTheme helpAboutDialogParams; }; Theme makeTheme(const ThemeParams ¶ms) @@ -115,6 +116,10 @@ Theme makeTheme(const ThemeParams ¶ms) theme.comicVine.rowUpIcon = { QIcon(recolor(t.rowUpIcon, cv.rowIconColor)), t.rowIconSize }; theme.comicVine.rowDownIcon = { QIcon(recolor(t.rowDownIcon, cv.rowIconColor)), t.rowIconSize }; + // HelpAboutDialog + theme.helpAboutDialog = params.helpAboutDialogParams; + // end HelpAboutDialog + return theme; } @@ -194,6 +199,9 @@ ThemeParams classicThemeParams() params.comicFlowColors = cf; params.comicVineParams = cv; + params.helpAboutDialogParams.headingColor = QColor(0x302f2d); + params.helpAboutDialogParams.linkColor = QColor(0xC19441); + return params; } @@ -255,6 +263,9 @@ ThemeParams lightThemeParams() params.comicFlowColors = cf; params.comicVineParams = cv; + params.helpAboutDialogParams.headingColor = QColor(0x302f2d); + params.helpAboutDialogParams.linkColor = QColor(0xC19441); + return params; } @@ -316,5 +327,8 @@ ThemeParams darkThemeParams() params.comicFlowColors = cf; params.comicVineParams = cv; + params.helpAboutDialogParams.headingColor = QColor(0xE0E0E0); + params.helpAboutDialogParams.linkColor = QColor(0xD4A84B); + return params; } diff --git a/common/themes/shared/help_about_dialog_theme.h b/common/themes/shared/help_about_dialog_theme.h new file mode 100644 index 00000000..52f98d35 --- /dev/null +++ b/common/themes/shared/help_about_dialog_theme.h @@ -0,0 +1,11 @@ +#ifndef HELP_ABOUT_DIALOG_THEME_H +#define HELP_ABOUT_DIALOG_THEME_H + +#include + +struct HelpAboutDialogTheme { + QColor headingColor; + QColor linkColor; +}; + +#endif // HELP_ABOUT_DIALOG_THEME_H diff --git a/common/themes/themes_common.pri b/common/themes/themes_common.pri index 67b11da3..bed4ed5c 100644 --- a/common/themes/themes_common.pri +++ b/common/themes/themes_common.pri @@ -1,4 +1,5 @@ -INCLUDEPATH += $$PWD +INCLUDEPATH += $$PWD \ + $$PWD/shared HEADERS += \ $$PWD/icon_utils.h \ @@ -6,6 +7,7 @@ HEADERS += \ $$PWD/theme_manager.h \ $$PWD/themable.h \ $$PWD/yacreader_icon.h \ + $$PWD/shared/help_about_dialog_theme.h \ SOURCES += \ diff --git a/custom_widgets/help_about_dialog.cpp b/custom_widgets/help_about_dialog.cpp index 25538c80..17c4a82d 100644 --- a/custom_widgets/help_about_dialog.cpp +++ b/custom_widgets/help_about_dialog.cpp @@ -50,6 +50,8 @@ HelpAboutDialog::HelpAboutDialog(QWidget *parent) resize(500, heightDesktopResolution * 0.83); loadSystemInfo(); + + initTheme(this); } HelpAboutDialog::HelpAboutDialog(const QString &pathAbout, const QString &pathHelp, QWidget *parent) @@ -67,14 +69,14 @@ void HelpAboutDialog::loadAboutInformation(const QString &path) buildNumber = BUILD_NUMBER; #endif - aboutText->setHtml(fileToString(path).arg(VERSION, buildNumber)); - aboutText->moveCursor(QTextCursor::Start); + aboutHtmlContent = fileToString(path).arg(VERSION, buildNumber); + applyHtmlTheme(); } void HelpAboutDialog::loadHelp(const QString &path) { - helpText->setHtml(fileToString(path)); - helpText->moveCursor(QTextCursor::Start); + helpHtmlContent = fileToString(path); + applyHtmlTheme(); } QString HelpAboutDialog::fileToString(const QString &path) @@ -104,3 +106,34 @@ void HelpAboutDialog::loadSystemInfo() systemInfoText->setText(text); } + +void HelpAboutDialog::applyTheme(const Theme &theme) +{ + Q_UNUSED(theme) + applyHtmlTheme(); +} + +void HelpAboutDialog::applyHtmlTheme() +{ + auto helpTheme = theme.helpAboutDialog; + + // Original colors in the HTML CSS + const QString originalHeadingColor = "#302f2d"; + const QString originalLinkColor = "#C19441"; + + if (!aboutHtmlContent.isEmpty()) { + QString themedAbout = aboutHtmlContent; + themedAbout.replace(originalHeadingColor, helpTheme.headingColor.name(), Qt::CaseInsensitive); + themedAbout.replace(originalLinkColor, helpTheme.linkColor.name(), Qt::CaseInsensitive); + aboutText->setHtml(themedAbout); + aboutText->moveCursor(QTextCursor::Start); + } + + if (!helpHtmlContent.isEmpty()) { + QString themedHelp = helpHtmlContent; + themedHelp.replace(originalHeadingColor, helpTheme.headingColor.name(), Qt::CaseInsensitive); + themedHelp.replace(originalLinkColor, helpTheme.linkColor.name(), Qt::CaseInsensitive); + helpText->setHtml(themedHelp); + helpText->moveCursor(QTextCursor::Start); + } +} diff --git a/custom_widgets/help_about_dialog.h b/custom_widgets/help_about_dialog.h index d7b8289f..2bf69160 100644 --- a/custom_widgets/help_about_dialog.h +++ b/custom_widgets/help_about_dialog.h @@ -3,12 +3,17 @@ #include +#include "themable.h" + class QTabWidget; class QTextBrowser; -class HelpAboutDialog : public QDialog +class HelpAboutDialog : public QDialog, protected Themable { Q_OBJECT +protected: + void applyTheme(const Theme &theme) override; + public: HelpAboutDialog(QWidget *parent = 0); HelpAboutDialog(const QString &pathAbout, const QString &pathHelp, QWidget *parent = 0); @@ -23,6 +28,10 @@ private: QTextBrowser *systemInfoText; QString fileToString(const QString &path); void loadSystemInfo(); + void applyHtmlTheme(); + + QString aboutHtmlContent; + QString helpHtmlContent; }; #endif // HELP_ABOUT_DIALOG_H