GUI: reapply stylesheet when changed

This commit is contained in:
Jean-Francois Dockes
2012-03-25 08:59:07 +02:00
parent 1912ecd452
commit 247435084c
9 changed files with 58 additions and 31 deletions
+14 -5
View File
@@ -173,6 +173,19 @@ static void sigcleanup(int)
exit(1);
}
void applyStyleSheet(const QString& ssfname)
{
const char *cfname = (const char *)ssfname.toLocal8Bit();
LOGDEB0(("Applying style sheet: [%s]\n", cfname));
if (cfname && *cfname) {
string stylesheet;
file_to_string(cfname, stylesheet);
qApp->setStyleSheet(QString::fromAscii(stylesheet.c_str()));
} else {
qApp->setStyleSheet(QString());
}
}
extern void qInitImages_recoll();
static const char *thisprog;
@@ -316,11 +329,7 @@ int main(int argc, char **argv)
// fprintf(stderr, "Settings done\n");
if (!prefs.stylesheetFile.isEmpty()) {
string stylesheet;
file_to_string((const char *)prefs.stylesheetFile.toLocal8Bit(),
stylesheet);
if (!stylesheet.empty())
app.setStyleSheet(QString::fromAscii(stylesheet.c_str()));
applyStyleSheet(prefs.stylesheetFile);
}
// Create main window and set its size to previous session's
+7 -2
View File
@@ -954,7 +954,7 @@ void RclMain::showRTITool(bool modal)
void RclMain::showUIPrefs()
{
if (uiprefs == 0) {
uiprefs = new UIPrefsDialog(0);
uiprefs = new UIPrefsDialog(this);
connect(new QShortcut(quitKeySeq, uiprefs), SIGNAL (activated()),
this, SLOT (fileExit()));
connect(uiprefs, SIGNAL(uiprefsDone()), this, SLOT(setUIPrefs()));
@@ -970,7 +970,7 @@ void RclMain::showUIPrefs()
void RclMain::showExtIdxDialog()
{
if (uiprefs == 0) {
uiprefs = new UIPrefsDialog(0);
uiprefs = new UIPrefsDialog(this);
connect(new QShortcut(quitKeySeq, uiprefs), SIGNAL (activated()),
this, SLOT (fileExit()));
connect(uiprefs, SIGNAL(uiprefsDone()), this, SLOT(setUIPrefs()));
@@ -1822,3 +1822,8 @@ bool RclMain::eventFilter(QObject *, QEvent *event)
}
return false;
}
void RclMain::applyStyleSheet()
{
::applyStyleSheet(prefs.stylesheetFile);
}
+1
View File
@@ -132,6 +132,7 @@ public slots:
virtual void onSortDataChanged(DocSeqSortSpec);
virtual void resultCount(int);
virtual void showQueryDetails();
virtual void applyStyleSheet();
signals:
void docSourceChanged(RefCntr<DocSequence>);
+4
View File
@@ -22,6 +22,8 @@
#include "rcldb.h"
#include "ptmutex.h"
#include <QString>
// Misc declarations in need of sharing between the UI files
// Open the database if needed. We now force a close/open by default
@@ -42,6 +44,8 @@ extern Rcl::Db *rcldb;
extern int recollNeedsExit;
extern void startManual(const string& helpindex);
extern void applyStyleSheet(const QString&);
#ifdef RCL_USE_ASPELL
class Aspell;
extern Aspell *aspell;
+3
View File
@@ -40,6 +40,7 @@
#include <qwhatsthis.h>
#include <qtextedit.h>
#include <qlist.h>
#include <QTimer>
#include "recoll.h"
#include "guiutils.h"
@@ -50,6 +51,7 @@
#include "viewaction_w.h"
#include "debuglog.h"
#include "editdialog.h"
#include "rclmain_w.h"
void UIPrefsDialog::init()
{
@@ -204,6 +206,7 @@ void UIPrefsDialog::accept()
prefs.reslistfontfamily = reslistFontFamily;
prefs.reslistfontsize = reslistFontSize;
prefs.stylesheetFile = stylesheetFile;
QTimer::singleShot(0, m_mainWindow, SLOT(applyStyleSheet()));
prefs.reslistformat = paraFormat;
prefs.reslistheadertext = headerText;
if (prefs.reslistformat.trimmed().isEmpty()) {
+4 -3
View File
@@ -23,14 +23,15 @@
class QDialog;
class ViewAction;
class RclMain;
class UIPrefsDialog : public QDialog, public Ui::uiPrefsDialogBase
{
Q_OBJECT
public:
UIPrefsDialog(QDialog* parent = 0)
: QDialog(parent)
UIPrefsDialog(RclMain* parent)
: QDialog((QWidget*)parent), m_mainWindow(parent)
{
setupUi(this);
init();
@@ -71,7 +72,7 @@ private:
QString headerText;
void setFromPrefs();
ViewAction *m_viewAction;
RclMain *m_mainWindow;
};
#endif /* _UIPREFS_W_H_INCLUDED_ */