GUI: move the code managing the dark mode css into guiutils
This commit is contained in:
parent
572e37c36f
commit
ecf775e306
@ -26,6 +26,7 @@
|
|||||||
#include "pathut.h"
|
#include "pathut.h"
|
||||||
#include "base64.h"
|
#include "base64.h"
|
||||||
#include "advshist.h"
|
#include "advshist.h"
|
||||||
|
#include "readfile.h"
|
||||||
|
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
#include <QStringList>
|
#include <QStringList>
|
||||||
@ -421,10 +422,32 @@ void rwSettings(bool writing)
|
|||||||
prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str()));
|
prefs.asearchSubdirHist.push_back(u8s2qs(dbd.c_str()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!writing) {
|
||||||
|
prefs.setupDarkCSS();
|
||||||
|
}
|
||||||
if (!writing)
|
if (!writing)
|
||||||
havereadsettings = true;
|
havereadsettings = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PrefsPack::setupDarkCSS()
|
||||||
|
{
|
||||||
|
if (!darkMode) {
|
||||||
|
darkreslistheadertext.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nullptr == theconfig) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
string fn = path_cat(
|
||||||
|
path_cat(theconfig->getDatadir(), "examples"), "recoll-dark.css");
|
||||||
|
string data;
|
||||||
|
string reason;
|
||||||
|
if (!file_to_string(fn, data, &reason)) {
|
||||||
|
std::cerr << "Recoll: Could not read: " << fn << "\n";
|
||||||
|
}
|
||||||
|
darkreslistheadertext = u8s2qs(data);
|
||||||
|
}
|
||||||
|
|
||||||
string PrefsPack::stemlang()
|
string PrefsPack::stemlang()
|
||||||
{
|
{
|
||||||
string stemLang(qs2utf8s(prefs.queryStemLang));
|
string stemLang(qs2utf8s(prefs.queryStemLang));
|
||||||
|
|||||||
@ -173,6 +173,8 @@ public:
|
|||||||
|
|
||||||
std::string stemlang();
|
std::string stemlang();
|
||||||
|
|
||||||
|
void setupDarkCSS();
|
||||||
|
|
||||||
// MIME types for which we prefer to use stored text from preview
|
// MIME types for which we prefer to use stored text from preview
|
||||||
// rather than extracting the possibly nicer HTML because the
|
// rather than extracting the possibly nicer HTML because the
|
||||||
// extractor is very slow. This is compiled in and there is no UI
|
// extractor is very slow. This is compiled in and there is no UI
|
||||||
|
|||||||
@ -331,11 +331,7 @@ void RclMain::showExtIdxDialog()
|
|||||||
|
|
||||||
void RclMain::showAboutDialog()
|
void RclMain::showAboutDialog()
|
||||||
{
|
{
|
||||||
QString darkcss;
|
QString vstring = QString("<html><head>") + prefs.darkreslistheadertext + "</head><body>" +
|
||||||
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>";
|
||||||
|
|||||||
@ -530,22 +530,6 @@ 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::resultCount(int n)
|
void RclMain::resultCount(int n)
|
||||||
{
|
{
|
||||||
actionSortByDateAsc->setEnabled(n>0);
|
actionSortByDateAsc->setEnabled(n>0);
|
||||||
|
|||||||
@ -89,7 +89,6 @@ public:
|
|||||||
return m_indexerState;
|
return m_indexerState;
|
||||||
}
|
}
|
||||||
void enableTrayIcon(bool onoff);
|
void enableTrayIcon(bool onoff);
|
||||||
QString readDarkCSS();
|
|
||||||
void setupToolbars();
|
void setupToolbars();
|
||||||
void setupStatusBar();
|
void setupStatusBar();
|
||||||
void buildMenus();
|
void buildMenus();
|
||||||
|
|||||||
@ -400,11 +400,7 @@ void UIPrefsDialog::accept()
|
|||||||
prefs.reslistfontfamily = reslistFontFamily;
|
prefs.reslistfontfamily = reslistFontFamily;
|
||||||
prefs.reslistfontsize = reslistFontSize;
|
prefs.reslistfontsize = reslistFontSize;
|
||||||
prefs.darkMode = darkMode;
|
prefs.darkMode = darkMode;
|
||||||
if (darkMode) {
|
prefs.setupDarkCSS();
|
||||||
prefs.darkreslistheadertext = m_mainWindow->readDarkCSS();
|
|
||||||
} else {
|
|
||||||
prefs.darkreslistheadertext.clear();
|
|
||||||
}
|
|
||||||
prefs.qssFile = qssFile;
|
prefs.qssFile = qssFile;
|
||||||
QTimer::singleShot(0, m_mainWindow, SLOT(applyStyleSheet()));
|
QTimer::singleShot(0, m_mainWindow, SLOT(applyStyleSheet()));
|
||||||
prefs.snipCssFile = snipCssFile;
|
prefs.snipCssFile = snipCssFile;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user