GUI: allow choosing a style sheet to be used by the recoll app
This commit is contained in:
@@ -152,6 +152,7 @@ void rwSettings(bool writing)
|
||||
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
|
||||
}
|
||||
}
|
||||
SETTING_RW(prefs.stylesheetFile, "/Recoll/prefs/stylesheet", String, "");
|
||||
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
||||
"english");
|
||||
SETTING_RW(prefs.useDesktopOpen,
|
||||
@@ -330,7 +331,7 @@ void rwSettings(bool writing)
|
||||
}
|
||||
}
|
||||
|
||||
QString myGetFileName(bool isdir, QString caption)
|
||||
QString myGetFileName(bool isdir, QString caption, bool filenosave)
|
||||
{
|
||||
LOGDEB1(("myFileDialog: isdir %d\n", isdir));
|
||||
QFileDialog dialog(0, caption);
|
||||
@@ -340,7 +341,10 @@ QString myGetFileName(bool isdir, QString caption)
|
||||
dialog.setOptions(QFileDialog::ShowDirsOnly);
|
||||
} else {
|
||||
dialog.setFileMode(QFileDialog::AnyFile);
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
if (filenosave)
|
||||
dialog.setAcceptMode(QFileDialog::AcceptOpen);
|
||||
else
|
||||
dialog.setAcceptMode(QFileDialog::AcceptSave);
|
||||
}
|
||||
dialog.setViewMode(QFileDialog::List);
|
||||
QFlags<QDir::Filter> flags = QDir::NoDotAndDotDot | QDir::Hidden;
|
||||
@@ -350,7 +354,6 @@ QString myGetFileName(bool isdir, QString caption)
|
||||
flags |= QDir::Dirs | QDir::Files;
|
||||
dialog.setFilter(flags);
|
||||
|
||||
|
||||
if (dialog.exec() == QDialog::Accepted) {
|
||||
return dialog.selectedFiles().value(0);
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ class PrefsPack {
|
||||
string creslistformat;
|
||||
// Abstract snippet separator
|
||||
QString abssep;
|
||||
QString stylesheetFile;
|
||||
QString queryStemLang;
|
||||
int mainwidth;
|
||||
int mainheight;
|
||||
@@ -136,6 +137,7 @@ extern QString g_stringAllStem, g_stringNoStem;
|
||||
|
||||
/** Specialized version of the qt file dialog. Can't use getOpenFile()
|
||||
etc. cause they hide dot files... */
|
||||
extern QString myGetFileName(bool isdir, QString caption = QString());
|
||||
extern QString myGetFileName(bool isdir, QString caption = QString(),
|
||||
bool filenosave = false);
|
||||
|
||||
#endif /* _GUIUTILS_H_INCLUDED_ */
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
#include "rclaspell.h"
|
||||
#endif
|
||||
#include "smallut.h"
|
||||
#include "readfile.h"
|
||||
|
||||
#include "recollq.h"
|
||||
|
||||
RclConfig *theconfig;
|
||||
@@ -315,6 +317,13 @@ int main(int argc, char **argv)
|
||||
havereadsettings = true;
|
||||
// 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()));
|
||||
}
|
||||
|
||||
// Create main window and set its size to previous session's
|
||||
RclMain w;
|
||||
|
||||
+58
-14
@@ -22,7 +22,7 @@
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
<number>0</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<attribute name="title">
|
||||
@@ -61,19 +61,6 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="collapseDupsCB">
|
||||
<property name="toolTip">
|
||||
<string>If checked, results with the same content under different names will only be shown once.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide duplicate results.</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
@@ -201,6 +188,40 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="tLSTL">
|
||||
<property name="text">
|
||||
<string>Style sheet</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="stylesheetPB">
|
||||
<property name="toolTip">
|
||||
<string>Opens a dialog to select the style sheet file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetSSPB">
|
||||
<property name="toolTip">
|
||||
<string>Resets the style sheet to default</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
@@ -323,6 +344,19 @@
|
||||
<string>Search parameters</string>
|
||||
</attribute>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
<widget class="QCheckBox" name="collapseDupsCB">
|
||||
<property name="toolTip">
|
||||
<string>If checked, results with the same content under different names will only be shown once.</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Hide duplicate results.</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QVBoxLayout">
|
||||
<item>
|
||||
@@ -342,6 +376,16 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Line" name="lineX">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::HLine</enum>
|
||||
</property>
|
||||
<property name="frameShadow">
|
||||
<enum>QFrame::Sunken</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="autoPhraseCB">
|
||||
<property name="toolTip">
|
||||
|
||||
@@ -57,6 +57,8 @@ void UIPrefsDialog::init()
|
||||
connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
|
||||
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
||||
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
||||
connect(stylesheetPB, SIGNAL(clicked()), this, SLOT(showStylesheetDialog()));
|
||||
connect(resetSSPB, SIGNAL(clicked()), this, SLOT(resetStylesheet()));
|
||||
|
||||
connect(addExtraDbPB, SIGNAL(clicked()),
|
||||
this, SLOT(addExtraDbPB_clicked()));
|
||||
@@ -116,6 +118,16 @@ void UIPrefsDialog::setFromPrefs()
|
||||
reslistFontPB->setText(reslistFontFamily + "-" +
|
||||
s.setNum(reslistFontSize));
|
||||
}
|
||||
|
||||
// Style sheet
|
||||
stylesheetFile = prefs.stylesheetFile;
|
||||
if (stylesheetFile.isEmpty()) {
|
||||
stylesheetPB->setText(tr("Choose"));
|
||||
} else {
|
||||
string nm = path_getsimple((const char *)stylesheetFile.toLocal8Bit());
|
||||
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||
}
|
||||
|
||||
rlfTE->setPlainText(prefs.reslistformat);
|
||||
|
||||
// Stemming language combobox
|
||||
@@ -185,11 +197,13 @@ void UIPrefsDialog::accept()
|
||||
|
||||
prefs.reslistfontfamily = reslistFontFamily;
|
||||
prefs.reslistfontsize = reslistFontSize;
|
||||
prefs.stylesheetFile = stylesheetFile;
|
||||
prefs.reslistformat = rlfTE->toPlainText();
|
||||
if (prefs.reslistformat.trimmed().isEmpty()) {
|
||||
prefs.reslistformat = prefs.dfltResListFormat;
|
||||
rlfTE->setPlainText(prefs.reslistformat);
|
||||
}
|
||||
|
||||
prefs.creslistformat = (const char*)prefs.reslistformat.toUtf8();
|
||||
|
||||
if (stemLangCMB->currentIndex() == 0) {
|
||||
@@ -289,6 +303,19 @@ void UIPrefsDialog::showFontDialog()
|
||||
}
|
||||
}
|
||||
|
||||
void UIPrefsDialog::showStylesheetDialog()
|
||||
{
|
||||
stylesheetFile = myGetFileName(false, "Select stylesheet file", true);
|
||||
string nm = path_getsimple((const char *)stylesheetFile.toLocal8Bit());
|
||||
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||
}
|
||||
|
||||
void UIPrefsDialog::resetStylesheet()
|
||||
{
|
||||
stylesheetFile = "";
|
||||
stylesheetPB->setText(tr("Choose"));
|
||||
}
|
||||
|
||||
void UIPrefsDialog::resetReslistFont()
|
||||
{
|
||||
reslistFontFamily = "";
|
||||
|
||||
@@ -39,14 +39,17 @@ public:
|
||||
|
||||
QString reslistFontFamily;
|
||||
int reslistFontSize;
|
||||
QString stylesheetFile;
|
||||
|
||||
virtual void init();
|
||||
|
||||
public slots:
|
||||
virtual void showFontDialog();
|
||||
virtual void resetReslistFont();
|
||||
virtual void showStylesheetDialog();
|
||||
virtual void resetStylesheet();
|
||||
virtual void showViewAction();
|
||||
virtual void showViewAction(const QString& mt);
|
||||
virtual void resetReslistFont();
|
||||
virtual void addExtraDbPB_clicked();
|
||||
virtual void delExtraDbPB_clicked();
|
||||
virtual void togExtraDbPB_clicked();
|
||||
|
||||
Reference in New Issue
Block a user