implement default styles for dark mode, and allow enabling them (both GUI and HTML) in one step through menu entry
This commit is contained in:
parent
a6c53ff651
commit
3541ba49f1
@ -220,6 +220,7 @@ void rwSettings(bool writing)
|
|||||||
|
|
||||||
SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext",
|
SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext",
|
||||||
String, "");
|
String, "");
|
||||||
|
SETTING_RW(prefs.darkMode, "/Recoll/prefs/darkMode", Bool, 0);
|
||||||
SETTING_RW(prefs.qssFile, "/Recoll/prefs/stylesheet", String, "");
|
SETTING_RW(prefs.qssFile, "/Recoll/prefs/stylesheet", String, "");
|
||||||
SETTING_RW(prefs.snipCssFile, "/Recoll/prefs/snippets/cssfile", String, "");
|
SETTING_RW(prefs.snipCssFile, "/Recoll/prefs/snippets/cssfile", String, "");
|
||||||
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
||||||
|
|||||||
@ -131,6 +131,8 @@ class PrefsPack {
|
|||||||
QString synFile;
|
QString synFile;
|
||||||
bool synFileEnable;
|
bool synFileEnable;
|
||||||
|
|
||||||
|
bool darkMode;
|
||||||
|
|
||||||
QStringList restableFields;
|
QStringList restableFields;
|
||||||
vector<int> restableColWidths;
|
vector<int> restableColWidths;
|
||||||
|
|
||||||
|
|||||||
@ -117,6 +117,8 @@
|
|||||||
<addaction name="queryPrefsAction"/>
|
<addaction name="queryPrefsAction"/>
|
||||||
<addaction name="extIdxAction"/>
|
<addaction name="extIdxAction"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
<addaction name="enbDarkModeAction"/>
|
||||||
|
<addaction name="separator"/>
|
||||||
<addaction name="enbSynAction"/>
|
<addaction name="enbSynAction"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
</widget>
|
</widget>
|
||||||
@ -415,6 +417,20 @@
|
|||||||
<cstring>enbSynAction</cstring>
|
<cstring>enbSynAction</cstring>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="enbDarkModeAction">
|
||||||
|
<property name="checkable">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>Use default dark mode</string>
|
||||||
|
</property>
|
||||||
|
<property name="iconText">
|
||||||
|
<string>Dark mode</string>
|
||||||
|
</property>
|
||||||
|
<property name="name" stdset="0">
|
||||||
|
<cstring>enbDarkModeAction</cstring>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
<action name="toggleFullScreenAction">
|
<action name="toggleFullScreenAction">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Full Screen</string>
|
<string>&Full Screen</string>
|
||||||
|
|||||||
@ -68,6 +68,7 @@
|
|||||||
#include "systray.h"
|
#include "systray.h"
|
||||||
#include "rclmain_w.h"
|
#include "rclmain_w.h"
|
||||||
#include "rclhelp.h"
|
#include "rclhelp.h"
|
||||||
|
#include "readfile.h"
|
||||||
#include "moc_rclmain_w.cpp"
|
#include "moc_rclmain_w.cpp"
|
||||||
|
|
||||||
using std::pair;
|
using std::pair;
|
||||||
@ -162,6 +163,7 @@ void RclMain::init()
|
|||||||
|
|
||||||
enbSynAction->setDisabled(prefs.synFile.isEmpty());
|
enbSynAction->setDisabled(prefs.synFile.isEmpty());
|
||||||
enbSynAction->setChecked(prefs.synFileEnable);
|
enbSynAction->setChecked(prefs.synFileEnable);
|
||||||
|
enbDarkModeAction->setChecked(prefs.darkMode);
|
||||||
|
|
||||||
// Stemming language menu
|
// Stemming language menu
|
||||||
g_stringNoStem = tr("(no stemming)");
|
g_stringNoStem = tr("(no stemming)");
|
||||||
@ -360,6 +362,8 @@ void RclMain::init()
|
|||||||
this, SLOT(showExtIdxDialog()));
|
this, SLOT(showExtIdxDialog()));
|
||||||
connect(enbSynAction, SIGNAL(toggled(bool)),
|
connect(enbSynAction, SIGNAL(toggled(bool)),
|
||||||
this, SLOT(setSynEnabled(bool)));
|
this, SLOT(setSynEnabled(bool)));
|
||||||
|
connect(enbDarkModeAction, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(setDarkModeEnabled(bool)));
|
||||||
|
|
||||||
connect(toggleFullScreenAction, SIGNAL(triggered()),
|
connect(toggleFullScreenAction, SIGNAL(triggered()),
|
||||||
this, SLOT(toggleFullScreen()));
|
this, SLOT(toggleFullScreen()));
|
||||||
@ -478,6 +482,61 @@ void RclMain::setSynEnabled(bool on)
|
|||||||
uiprefs->synFileCB->setChecked(prefs.synFileEnable);
|
uiprefs->synFileCB->setChecked(prefs.synFileEnable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RclMain::setDarkModeEnabled(bool on)
|
||||||
|
{
|
||||||
|
string fn;
|
||||||
|
|
||||||
|
if (on) {
|
||||||
|
if (!prefs.reslistheadertext.isEmpty() || !prefs.qssFile.isEmpty()) {
|
||||||
|
QString message =
|
||||||
|
tr("This will replace the current contents of the result list"
|
||||||
|
" header string and GUI qss file name. Continue ?");
|
||||||
|
switch(QMessageBox::warning(0, "Recoll", message,
|
||||||
|
"Yes", "No", 0, 0, 1)) {
|
||||||
|
case 0:
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
goto resetcheckednosigs;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
string datadir = theconfig->getDatadir();
|
||||||
|
fn = path_cat(path_cat(datadir, "examples"), "recoll-dark.qss");
|
||||||
|
if (!path_readable(fn)) {
|
||||||
|
goto unreadable;
|
||||||
|
}
|
||||||
|
prefs.qssFile = u8s2qs(fn);
|
||||||
|
fn = path_cat(path_cat(datadir, "examples"), "recoll-dark.css");
|
||||||
|
string data;
|
||||||
|
string reason;
|
||||||
|
if (!file_to_string(fn, data, &reason)) {
|
||||||
|
goto unreadable;
|
||||||
|
}
|
||||||
|
prefs.reslistheadertext = u8s2qs(data);
|
||||||
|
} else {
|
||||||
|
prefs.reslistheadertext.clear();
|
||||||
|
prefs.qssFile.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
applyStyleSheet();
|
||||||
|
prefs.darkMode = on;
|
||||||
|
if (uiprefs) {
|
||||||
|
uiprefs->resetStylesheet(prefs.qssFile);
|
||||||
|
}
|
||||||
|
QMessageBox::warning(0, "Recoll", tr("You will need to run a query to "
|
||||||
|
"complete the display change."));
|
||||||
|
return;
|
||||||
|
|
||||||
|
unreadable:
|
||||||
|
QMessageBox::warning(0, "Recoll", tr("Could not read: ") + u8s2qs(fn));
|
||||||
|
prefs.reslistheadertext.clear();
|
||||||
|
prefs.qssFile.clear();
|
||||||
|
// And reset checkbox state:
|
||||||
|
resetcheckednosigs:
|
||||||
|
bool oldState = enbDarkModeAction->blockSignals(true);
|
||||||
|
enbDarkModeAction->setChecked(!on);
|
||||||
|
enbDarkModeAction->blockSignals(oldState);
|
||||||
|
}
|
||||||
|
|
||||||
void RclMain::resultCount(int n)
|
void RclMain::resultCount(int n)
|
||||||
{
|
{
|
||||||
actionSortByDateAsc->setEnabled(n>0);
|
actionSortByDateAsc->setEnabled(n>0);
|
||||||
|
|||||||
@ -113,6 +113,7 @@ public slots:
|
|||||||
virtual void showDocHistory();
|
virtual void showDocHistory();
|
||||||
virtual void showExtIdxDialog();
|
virtual void showExtIdxDialog();
|
||||||
virtual void setSynEnabled(bool);
|
virtual void setSynEnabled(bool);
|
||||||
|
virtual void setDarkModeEnabled(bool);
|
||||||
virtual void showUIPrefs();
|
virtual void showUIPrefs();
|
||||||
virtual void showIndexConfig();
|
virtual void showIndexConfig();
|
||||||
virtual void execIndexConfig();
|
virtual void execIndexConfig();
|
||||||
|
|||||||
@ -469,10 +469,14 @@ void UIPrefsDialog::showStylesheetDialog()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPrefsDialog::resetStylesheet()
|
void UIPrefsDialog::resetStylesheet(QString fn)
|
||||||
{
|
{
|
||||||
qssFile = "";
|
qssFile = fn;
|
||||||
stylesheetPB->setText(tr("Choose"));
|
if (fn.isEmpty()) {
|
||||||
|
stylesheetPB->setText(tr("Choose"));
|
||||||
|
} else {
|
||||||
|
stylesheetPB->setText(fn);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void UIPrefsDialog::showSnipCssDialog()
|
void UIPrefsDialog::showSnipCssDialog()
|
||||||
{
|
{
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public slots:
|
|||||||
virtual void showStylesheetDialog();
|
virtual void showStylesheetDialog();
|
||||||
virtual void showSynFileDialog();
|
virtual void showSynFileDialog();
|
||||||
virtual void showSnipCssDialog();
|
virtual void showSnipCssDialog();
|
||||||
virtual void resetStylesheet();
|
virtual void resetStylesheet(QString fn = QString());
|
||||||
virtual void resetSnipCss();
|
virtual void resetSnipCss();
|
||||||
virtual void showViewAction();
|
virtual void showViewAction();
|
||||||
virtual void showViewAction(const QString& mt);
|
virtual void showViewAction(const QString& mt);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
/* Result list HTML Header insert */
|
<!-- Result list HTML Header insert -->
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user