added option for external CSS style sheet for Snippets window
This commit is contained in:
parent
bb3e25d925
commit
a2fa6a433f
8 changed files with 82 additions and 15 deletions
|
@ -153,7 +153,8 @@ void rwSettings(bool writing)
|
|||
|
||||
SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext",
|
||||
String, "");
|
||||
SETTING_RW(prefs.stylesheetFile, "/Recoll/prefs/stylesheet", String, "");
|
||||
SETTING_RW(prefs.qssFile, "/Recoll/prefs/stylesheet", String, "");
|
||||
SETTING_RW(prefs.snipCssFile, "/Recoll/prefs/snippets/cssfile", String, "");
|
||||
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
||||
"english");
|
||||
SETTING_RW(prefs.useDesktopOpen, "/Recoll/prefs/useDesktopOpen",
|
||||
|
|
|
@ -60,7 +60,8 @@ class PrefsPack {
|
|||
// Date strftime format
|
||||
QString reslistdateformat;
|
||||
string creslistdateformat;
|
||||
QString stylesheetFile;
|
||||
QString qssFile;
|
||||
QString snipCssFile;
|
||||
QString queryStemLang;
|
||||
int mainwidth;
|
||||
int mainheight;
|
||||
|
|
|
@ -338,8 +338,8 @@ int main(int argc, char **argv)
|
|||
havereadsettings = true;
|
||||
// fprintf(stderr, "Settings done\n");
|
||||
|
||||
if (!prefs.stylesheetFile.isEmpty()) {
|
||||
applyStyleSheet(prefs.stylesheetFile);
|
||||
if (!prefs.qssFile.isEmpty()) {
|
||||
applyStyleSheet(prefs.qssFile);
|
||||
}
|
||||
QIcon icon;
|
||||
icon.addFile(QString::fromUtf8(":/images/recoll.png"));
|
||||
|
|
|
@ -1983,5 +1983,5 @@ bool RclMain::eventFilter(QObject *, QEvent *event)
|
|||
|
||||
void RclMain::applyStyleSheet()
|
||||
{
|
||||
::applyStyleSheet(prefs.stylesheetFile);
|
||||
::applyStyleSheet(prefs.qssFile);
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ using namespace std;
|
|||
#ifdef SNIPPETS_WEBKIT
|
||||
#include <QWebSettings>
|
||||
#include <QWebFrame>
|
||||
#include <QUrl>
|
||||
#else
|
||||
#include <QTextBrowser>
|
||||
#endif
|
||||
|
@ -100,6 +101,8 @@ void SnippetsW::init()
|
|||
ws->setFontFamily(QWebSettings::StandardFont, prefs.reslistfontfamily);
|
||||
ws->setFontSize(QWebSettings::DefaultFontSize, prefs.reslistfontsize);
|
||||
}
|
||||
if (!prefs.snipCssFile.isEmpty())
|
||||
ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
|
||||
#else
|
||||
connect(browser, SIGNAL(anchorClicked(const QUrl &)),
|
||||
this, SLOT(linkWasClicked(const QUrl &)));
|
||||
|
@ -135,7 +138,9 @@ void SnippetsW::init()
|
|||
oss <<
|
||||
"<html><head>"
|
||||
"<meta http-equiv=\"content-type\" "
|
||||
"content=\"text/html; charset=utf-8\"></head>"
|
||||
"content=\"text/html; charset=utf-8\">"
|
||||
"<link type=\"text/css\" rel=\"stylesheet\" href=\"/tmp/style.css\">"
|
||||
"</head>"
|
||||
"<body>"
|
||||
"<table style='overflow-x: scroll; white-space: nowrap'>"
|
||||
;
|
||||
|
|
|
@ -394,6 +394,40 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="tLSTL">
|
||||
<property name="text">
|
||||
<string>Snippets window CSS file</string>
|
||||
</property>
|
||||
<property name="wordWrap">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="snipCssPB">
|
||||
<property name="toolTip">
|
||||
<string>Opens a dialog to select the Snippets window CSS style sheet file</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Choose</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="resetSnipCssPB">
|
||||
<property name="toolTip">
|
||||
<string>Resets the Snippets window style</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Reset</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
|
|
|
@ -62,8 +62,11 @@ 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(snipCssPB, SIGNAL(clicked()),this, SLOT(showSnipCssDialog()));
|
||||
connect(resetSnipCssPB, SIGNAL(clicked()), this, SLOT(resetSnipCss()));
|
||||
|
||||
connect(idxLV, SIGNAL(itemSelectionChanged()),
|
||||
this, SLOT(extradDbSelectChanged()));
|
||||
|
@ -142,14 +145,22 @@ void UIPrefsDialog::setFromPrefs()
|
|||
}
|
||||
|
||||
// Style sheet
|
||||
stylesheetFile = prefs.stylesheetFile;
|
||||
if (stylesheetFile.isEmpty()) {
|
||||
qssFile = prefs.qssFile;
|
||||
if (qssFile.isEmpty()) {
|
||||
stylesheetPB->setText(tr("Choose"));
|
||||
} else {
|
||||
string nm = path_getsimple((const char *)stylesheetFile.toLocal8Bit());
|
||||
string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
|
||||
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||
}
|
||||
|
||||
snipCssFile = prefs.snipCssFile;
|
||||
if (snipCssFile.isEmpty()) {
|
||||
snipCssPB->setText(tr("Choose"));
|
||||
} else {
|
||||
string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
|
||||
snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||
}
|
||||
|
||||
paraFormat = prefs.reslistformat;
|
||||
headerText = prefs.reslistheadertext;
|
||||
|
||||
|
@ -225,8 +236,9 @@ void UIPrefsDialog::accept()
|
|||
|
||||
prefs.reslistfontfamily = reslistFontFamily;
|
||||
prefs.reslistfontsize = reslistFontSize;
|
||||
prefs.stylesheetFile = stylesheetFile;
|
||||
prefs.qssFile = qssFile;
|
||||
QTimer::singleShot(0, m_mainWindow, SLOT(applyStyleSheet()));
|
||||
prefs.snipCssFile = snipCssFile;
|
||||
prefs.reslistformat = paraFormat;
|
||||
prefs.reslistheadertext = headerText;
|
||||
if (prefs.reslistformat.trimmed().isEmpty()) {
|
||||
|
@ -364,16 +376,27 @@ void UIPrefsDialog::showFontDialog()
|
|||
|
||||
void UIPrefsDialog::showStylesheetDialog()
|
||||
{
|
||||
stylesheetFile = myGetFileName(false, "Select stylesheet file", true);
|
||||
string nm = path_getsimple((const char *)stylesheetFile.toLocal8Bit());
|
||||
qssFile = myGetFileName(false, "Select stylesheet file", true);
|
||||
string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
|
||||
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||
}
|
||||
|
||||
void UIPrefsDialog::resetStylesheet()
|
||||
{
|
||||
stylesheetFile = "";
|
||||
qssFile = "";
|
||||
stylesheetPB->setText(tr("Choose"));
|
||||
}
|
||||
void UIPrefsDialog::showSnipCssDialog()
|
||||
{
|
||||
snipCssFile = myGetFileName(false, "Select snippets window CSS file", true);
|
||||
string nm = path_getsimple((const char *)snipCssFile.toLocal8Bit());
|
||||
snipCssPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||
}
|
||||
void UIPrefsDialog::resetSnipCss()
|
||||
{
|
||||
snipCssFile = "";
|
||||
snipCssPB->setText(tr("Choose"));
|
||||
}
|
||||
|
||||
void UIPrefsDialog::resetReslistFont()
|
||||
{
|
||||
|
|
|
@ -40,7 +40,8 @@ public:
|
|||
|
||||
QString reslistFontFamily;
|
||||
int reslistFontSize;
|
||||
QString stylesheetFile;
|
||||
QString qssFile;
|
||||
QString snipCssFile;
|
||||
|
||||
virtual void init();
|
||||
|
||||
|
@ -48,7 +49,9 @@ public slots:
|
|||
virtual void showFontDialog();
|
||||
virtual void resetReslistFont();
|
||||
virtual void showStylesheetDialog();
|
||||
virtual void showSnipCssDialog();
|
||||
virtual void resetStylesheet();
|
||||
virtual void resetSnipCss();
|
||||
virtual void showViewAction();
|
||||
virtual void showViewAction(const QString& mt);
|
||||
virtual void addExtraDbPB_clicked();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue