Extract dark css reading code in separate method for reuse in about widget
This commit is contained in:
parent
a6e30371a4
commit
6b7f2ff876
@ -331,7 +331,11 @@ void RclMain::showExtIdxDialog()
|
|||||||
|
|
||||||
void RclMain::showAboutDialog()
|
void RclMain::showAboutDialog()
|
||||||
{
|
{
|
||||||
QString vstring = QString("<html><head>") + prefs.reslistheadertext + "</head><body>" +
|
QString darkcss;
|
||||||
|
if (prefs.darkMode) {
|
||||||
|
darkcss = readDarkCSS();
|
||||||
|
}
|
||||||
|
QString vstring = QString("<html><head>") + darkcss + "</head><body>" +
|
||||||
u8s2qs(Rcl::version_string()) +
|
u8s2qs(Rcl::version_string()) +
|
||||||
"<br><a href='https://www.recoll.org'>www.recoll.org</a>" +
|
"<br><a href='https://www.recoll.org'>www.recoll.org</a>" +
|
||||||
"<br><a href='https://www.xapian.org'>www.xapian.org</a>";
|
"<br><a href='https://www.xapian.org'>www.xapian.org</a>";
|
||||||
|
|||||||
@ -485,6 +485,22 @@ void RclMain::setSynEnabled(bool on)
|
|||||||
uiprefs->synFileCB->setChecked(prefs.synFileEnable);
|
uiprefs->synFileCB->setChecked(prefs.synFileEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString RclMain::readDarkCSS()
|
||||||
|
{
|
||||||
|
if (nullptr == theconfig) {
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
string fn = path_cat(
|
||||||
|
path_cat(theconfig->getDatadir(), "examples"), "recoll-dark.css");
|
||||||
|
string data;
|
||||||
|
string reason;
|
||||||
|
if (!file_to_string(fn, data, &reason)) {
|
||||||
|
QMessageBox::warning(0, "Recoll", tr("Could not read: ") + u8s2qs(fn));
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
return u8s2qs(data);
|
||||||
|
}
|
||||||
|
|
||||||
void RclMain::setDarkModeEnabled(bool on)
|
void RclMain::setDarkModeEnabled(bool on)
|
||||||
{
|
{
|
||||||
string fn;
|
string fn;
|
||||||
@ -508,13 +524,8 @@ void RclMain::setDarkModeEnabled(bool on)
|
|||||||
goto unreadable;
|
goto unreadable;
|
||||||
}
|
}
|
||||||
prefs.qssFile = u8s2qs(fn);
|
prefs.qssFile = u8s2qs(fn);
|
||||||
fn = path_cat(path_cat(datadir, "examples"), "recoll-dark.css");
|
|
||||||
string data;
|
prefs.reslistheadertext = readDarkCSS();
|
||||||
string reason;
|
|
||||||
if (!file_to_string(fn, data, &reason)) {
|
|
||||||
goto unreadable;
|
|
||||||
}
|
|
||||||
prefs.reslistheadertext = u8s2qs(data);
|
|
||||||
} else {
|
} else {
|
||||||
prefs.reslistheadertext.clear();
|
prefs.reslistheadertext.clear();
|
||||||
prefs.qssFile.clear();
|
prefs.qssFile.clear();
|
||||||
|
|||||||
@ -88,6 +88,7 @@ public:
|
|||||||
return m_indexerState;
|
return m_indexerState;
|
||||||
}
|
}
|
||||||
void enableTrayIcon(bool onoff);
|
void enableTrayIcon(bool onoff);
|
||||||
|
QString readDarkCSS();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual void fileExit();
|
virtual void fileExit();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user