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:
luisangelsm
2026-01-25 10:25:00 +01:00
parent 07718e50db
commit 6b3fcc63d3
8 changed files with 94 additions and 6 deletions

View File

@ -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);
}
}