mirror of
https://github.com/YACReader/yacreader
synced 2026-04-12 15:49:53 -04:00
Make help/about dialog themable
Just the hardcoded colors used, the rest of the dialog will be themed by Qt.
This commit is contained in:
@ -3,6 +3,8 @@
|
|||||||
|
|
||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
|
#include "help_about_dialog_theme.h"
|
||||||
|
|
||||||
struct ToolbarThemeTemplates {
|
struct ToolbarThemeTemplates {
|
||||||
QString toolbarQSS = "QToolBar { border: none; background: %1; }\n"
|
QString toolbarQSS = "QToolBar { border: none; background: %1; }\n"
|
||||||
"QToolBar::separator { background: %2; width: 1px; margin: 5px 4px; }\n"
|
"QToolBar::separator { background: %2; width: 1px; margin: 5px 4px; }\n"
|
||||||
@ -128,6 +130,7 @@ struct Theme {
|
|||||||
ToolbarTheme toolbar;
|
ToolbarTheme toolbar;
|
||||||
ViewerTheme viewer;
|
ViewerTheme viewer;
|
||||||
GoToFlowWidgetTheme goToFlowWidget;
|
GoToFlowWidgetTheme goToFlowWidget;
|
||||||
|
HelpAboutDialogTheme helpAboutDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // THEME_H
|
#endif // THEME_H
|
||||||
|
|||||||
@ -45,6 +45,7 @@ struct ThemeParams {
|
|||||||
ToolbarParams toolbarParams;
|
ToolbarParams toolbarParams;
|
||||||
ViewerParams viewerParams;
|
ViewerParams viewerParams;
|
||||||
GoToFlowWidgetParams goToFlowWidgetParams;
|
GoToFlowWidgetParams goToFlowWidgetParams;
|
||||||
|
HelpAboutDialogTheme helpAboutDialogParams;
|
||||||
};
|
};
|
||||||
|
|
||||||
void setToolbarIconPair(QIcon &icon,
|
void setToolbarIconPair(QIcon &icon,
|
||||||
@ -152,6 +153,10 @@ Theme makeTheme(const ThemeParams ¶ms)
|
|||||||
theme.goToFlowWidget.goToIcon = QIcon(goToIconPath);
|
theme.goToFlowWidget.goToIcon = QIcon(goToIconPath);
|
||||||
// end GoToFlowWidget
|
// end GoToFlowWidget
|
||||||
|
|
||||||
|
// HelpAboutDialog
|
||||||
|
theme.helpAboutDialog = params.helpAboutDialogParams;
|
||||||
|
// end HelpAboutDialog
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +217,9 @@ ThemeParams classicThemeParams()
|
|||||||
|
|
||||||
params.goToFlowWidgetParams = goToFlowWidgetParams;
|
params.goToFlowWidgetParams = goToFlowWidgetParams;
|
||||||
|
|
||||||
|
params.helpAboutDialogParams.headingColor = QColor(0x302f2d);
|
||||||
|
params.helpAboutDialogParams.linkColor = QColor(0xC19441);
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -256,6 +264,9 @@ ThemeParams lightThemeParams()
|
|||||||
|
|
||||||
params.goToFlowWidgetParams = goToFlowWidgetParams;
|
params.goToFlowWidgetParams = goToFlowWidgetParams;
|
||||||
|
|
||||||
|
params.helpAboutDialogParams.headingColor = QColor(0x302f2d);
|
||||||
|
params.helpAboutDialogParams.linkColor = QColor(0xC19441);
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -300,6 +311,9 @@ ThemeParams darkThemeParams()
|
|||||||
|
|
||||||
params.goToFlowWidgetParams = goToFlowWidgetParams;
|
params.goToFlowWidgetParams = goToFlowWidgetParams;
|
||||||
|
|
||||||
|
params.helpAboutDialogParams.headingColor = QColor(0xE0E0E0);
|
||||||
|
params.helpAboutDialogParams.linkColor = QColor(0xD4A84B);
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
#include <QtGui>
|
#include <QtGui>
|
||||||
|
|
||||||
#include "yacreader_icon.h"
|
#include "yacreader_icon.h"
|
||||||
|
#include "help_about_dialog_theme.h"
|
||||||
|
|
||||||
struct ComicVineThemeTemplates {
|
struct ComicVineThemeTemplates {
|
||||||
QString defaultLabelQSS = "QLabel {color:%1; font-size:12px;font-family:Arial;}";
|
QString defaultLabelQSS = "QLabel {color:%1; font-size:12px;font-family:Arial;}";
|
||||||
@ -130,6 +131,7 @@ struct ComicVineTheme {
|
|||||||
struct Theme {
|
struct Theme {
|
||||||
ComicFlowColors comicFlow;
|
ComicFlowColors comicFlow;
|
||||||
ComicVineTheme comicVine;
|
ComicVineTheme comicVine;
|
||||||
|
HelpAboutDialogTheme helpAboutDialog;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // THEME_H
|
#endif // THEME_H
|
||||||
|
|||||||
@ -54,6 +54,7 @@ struct ThemeParams {
|
|||||||
|
|
||||||
ComicFlowColors comicFlowColors;
|
ComicFlowColors comicFlowColors;
|
||||||
ComicVineParams comicVineParams;
|
ComicVineParams comicVineParams;
|
||||||
|
HelpAboutDialogTheme helpAboutDialogParams;
|
||||||
};
|
};
|
||||||
|
|
||||||
Theme makeTheme(const ThemeParams ¶ms)
|
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.rowUpIcon = { QIcon(recolor(t.rowUpIcon, cv.rowIconColor)), t.rowIconSize };
|
||||||
theme.comicVine.rowDownIcon = { QIcon(recolor(t.rowDownIcon, cv.rowIconColor)), t.rowIconSize };
|
theme.comicVine.rowDownIcon = { QIcon(recolor(t.rowDownIcon, cv.rowIconColor)), t.rowIconSize };
|
||||||
|
|
||||||
|
// HelpAboutDialog
|
||||||
|
theme.helpAboutDialog = params.helpAboutDialogParams;
|
||||||
|
// end HelpAboutDialog
|
||||||
|
|
||||||
return theme;
|
return theme;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +199,9 @@ ThemeParams classicThemeParams()
|
|||||||
params.comicFlowColors = cf;
|
params.comicFlowColors = cf;
|
||||||
params.comicVineParams = cv;
|
params.comicVineParams = cv;
|
||||||
|
|
||||||
|
params.helpAboutDialogParams.headingColor = QColor(0x302f2d);
|
||||||
|
params.helpAboutDialogParams.linkColor = QColor(0xC19441);
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -255,6 +263,9 @@ ThemeParams lightThemeParams()
|
|||||||
params.comicFlowColors = cf;
|
params.comicFlowColors = cf;
|
||||||
params.comicVineParams = cv;
|
params.comicVineParams = cv;
|
||||||
|
|
||||||
|
params.helpAboutDialogParams.headingColor = QColor(0x302f2d);
|
||||||
|
params.helpAboutDialogParams.linkColor = QColor(0xC19441);
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,5 +327,8 @@ ThemeParams darkThemeParams()
|
|||||||
params.comicFlowColors = cf;
|
params.comicFlowColors = cf;
|
||||||
params.comicVineParams = cv;
|
params.comicVineParams = cv;
|
||||||
|
|
||||||
|
params.helpAboutDialogParams.headingColor = QColor(0xE0E0E0);
|
||||||
|
params.helpAboutDialogParams.linkColor = QColor(0xD4A84B);
|
||||||
|
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|||||||
11
common/themes/shared/help_about_dialog_theme.h
Normal file
11
common/themes/shared/help_about_dialog_theme.h
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
#ifndef HELP_ABOUT_DIALOG_THEME_H
|
||||||
|
#define HELP_ABOUT_DIALOG_THEME_H
|
||||||
|
|
||||||
|
#include <QColor>
|
||||||
|
|
||||||
|
struct HelpAboutDialogTheme {
|
||||||
|
QColor headingColor;
|
||||||
|
QColor linkColor;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // HELP_ABOUT_DIALOG_THEME_H
|
||||||
@ -1,4 +1,5 @@
|
|||||||
INCLUDEPATH += $$PWD
|
INCLUDEPATH += $$PWD \
|
||||||
|
$$PWD/shared
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
$$PWD/icon_utils.h \
|
$$PWD/icon_utils.h \
|
||||||
@ -6,6 +7,7 @@ HEADERS += \
|
|||||||
$$PWD/theme_manager.h \
|
$$PWD/theme_manager.h \
|
||||||
$$PWD/themable.h \
|
$$PWD/themable.h \
|
||||||
$$PWD/yacreader_icon.h \
|
$$PWD/yacreader_icon.h \
|
||||||
|
$$PWD/shared/help_about_dialog_theme.h \
|
||||||
|
|
||||||
|
|
||||||
SOURCES += \
|
SOURCES += \
|
||||||
|
|||||||
@ -50,6 +50,8 @@ HelpAboutDialog::HelpAboutDialog(QWidget *parent)
|
|||||||
resize(500, heightDesktopResolution * 0.83);
|
resize(500, heightDesktopResolution * 0.83);
|
||||||
|
|
||||||
loadSystemInfo();
|
loadSystemInfo();
|
||||||
|
|
||||||
|
initTheme(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
HelpAboutDialog::HelpAboutDialog(const QString &pathAbout, const QString &pathHelp, QWidget *parent)
|
HelpAboutDialog::HelpAboutDialog(const QString &pathAbout, const QString &pathHelp, QWidget *parent)
|
||||||
@ -67,14 +69,14 @@ void HelpAboutDialog::loadAboutInformation(const QString &path)
|
|||||||
buildNumber = BUILD_NUMBER;
|
buildNumber = BUILD_NUMBER;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
aboutText->setHtml(fileToString(path).arg(VERSION, buildNumber));
|
aboutHtmlContent = fileToString(path).arg(VERSION, buildNumber);
|
||||||
aboutText->moveCursor(QTextCursor::Start);
|
applyHtmlTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HelpAboutDialog::loadHelp(const QString &path)
|
void HelpAboutDialog::loadHelp(const QString &path)
|
||||||
{
|
{
|
||||||
helpText->setHtml(fileToString(path));
|
helpHtmlContent = fileToString(path);
|
||||||
helpText->moveCursor(QTextCursor::Start);
|
applyHtmlTheme();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString HelpAboutDialog::fileToString(const QString &path)
|
QString HelpAboutDialog::fileToString(const QString &path)
|
||||||
@ -104,3 +106,34 @@ void HelpAboutDialog::loadSystemInfo()
|
|||||||
|
|
||||||
systemInfoText->setText(text);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -3,12 +3,17 @@
|
|||||||
|
|
||||||
#include <QDialog>
|
#include <QDialog>
|
||||||
|
|
||||||
|
#include "themable.h"
|
||||||
|
|
||||||
class QTabWidget;
|
class QTabWidget;
|
||||||
class QTextBrowser;
|
class QTextBrowser;
|
||||||
|
|
||||||
class HelpAboutDialog : public QDialog
|
class HelpAboutDialog : public QDialog, protected Themable
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
protected:
|
||||||
|
void applyTheme(const Theme &theme) override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
HelpAboutDialog(QWidget *parent = 0);
|
HelpAboutDialog(QWidget *parent = 0);
|
||||||
HelpAboutDialog(const QString &pathAbout, const QString &pathHelp, QWidget *parent = 0);
|
HelpAboutDialog(const QString &pathAbout, const QString &pathHelp, QWidget *parent = 0);
|
||||||
@ -23,6 +28,10 @@ private:
|
|||||||
QTextBrowser *systemInfoText;
|
QTextBrowser *systemInfoText;
|
||||||
QString fileToString(const QString &path);
|
QString fileToString(const QString &path);
|
||||||
void loadSystemInfo();
|
void loadSystemInfo();
|
||||||
|
void applyHtmlTheme();
|
||||||
|
|
||||||
|
QString aboutHtmlContent;
|
||||||
|
QString helpHtmlContent;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // HELP_ABOUT_DIALOG_H
|
#endif // HELP_ABOUT_DIALOG_H
|
||||||
|
|||||||
Reference in New Issue
Block a user