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",
|
SETTING_RW(prefs.reslistheadertext, "/Recoll/prefs/reslist/headertext",
|
||||||
String, "");
|
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,
|
SETTING_RW(prefs.queryStemLang, "/Recoll/prefs/query/stemLang", String,
|
||||||
"english");
|
"english");
|
||||||
SETTING_RW(prefs.useDesktopOpen, "/Recoll/prefs/useDesktopOpen",
|
SETTING_RW(prefs.useDesktopOpen, "/Recoll/prefs/useDesktopOpen",
|
||||||
|
|
|
@ -60,7 +60,8 @@ class PrefsPack {
|
||||||
// Date strftime format
|
// Date strftime format
|
||||||
QString reslistdateformat;
|
QString reslistdateformat;
|
||||||
string creslistdateformat;
|
string creslistdateformat;
|
||||||
QString stylesheetFile;
|
QString qssFile;
|
||||||
|
QString snipCssFile;
|
||||||
QString queryStemLang;
|
QString queryStemLang;
|
||||||
int mainwidth;
|
int mainwidth;
|
||||||
int mainheight;
|
int mainheight;
|
||||||
|
|
|
@ -338,8 +338,8 @@ int main(int argc, char **argv)
|
||||||
havereadsettings = true;
|
havereadsettings = true;
|
||||||
// fprintf(stderr, "Settings done\n");
|
// fprintf(stderr, "Settings done\n");
|
||||||
|
|
||||||
if (!prefs.stylesheetFile.isEmpty()) {
|
if (!prefs.qssFile.isEmpty()) {
|
||||||
applyStyleSheet(prefs.stylesheetFile);
|
applyStyleSheet(prefs.qssFile);
|
||||||
}
|
}
|
||||||
QIcon icon;
|
QIcon icon;
|
||||||
icon.addFile(QString::fromUtf8(":/images/recoll.png"));
|
icon.addFile(QString::fromUtf8(":/images/recoll.png"));
|
||||||
|
|
|
@ -1983,5 +1983,5 @@ bool RclMain::eventFilter(QObject *, QEvent *event)
|
||||||
|
|
||||||
void RclMain::applyStyleSheet()
|
void RclMain::applyStyleSheet()
|
||||||
{
|
{
|
||||||
::applyStyleSheet(prefs.stylesheetFile);
|
::applyStyleSheet(prefs.qssFile);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,7 @@ using namespace std;
|
||||||
#ifdef SNIPPETS_WEBKIT
|
#ifdef SNIPPETS_WEBKIT
|
||||||
#include <QWebSettings>
|
#include <QWebSettings>
|
||||||
#include <QWebFrame>
|
#include <QWebFrame>
|
||||||
|
#include <QUrl>
|
||||||
#else
|
#else
|
||||||
#include <QTextBrowser>
|
#include <QTextBrowser>
|
||||||
#endif
|
#endif
|
||||||
|
@ -100,6 +101,8 @@ void SnippetsW::init()
|
||||||
ws->setFontFamily(QWebSettings::StandardFont, prefs.reslistfontfamily);
|
ws->setFontFamily(QWebSettings::StandardFont, prefs.reslistfontfamily);
|
||||||
ws->setFontSize(QWebSettings::DefaultFontSize, prefs.reslistfontsize);
|
ws->setFontSize(QWebSettings::DefaultFontSize, prefs.reslistfontsize);
|
||||||
}
|
}
|
||||||
|
if (!prefs.snipCssFile.isEmpty())
|
||||||
|
ws->setUserStyleSheetUrl(QUrl::fromLocalFile(prefs.snipCssFile));
|
||||||
#else
|
#else
|
||||||
connect(browser, SIGNAL(anchorClicked(const QUrl &)),
|
connect(browser, SIGNAL(anchorClicked(const QUrl &)),
|
||||||
this, SLOT(linkWasClicked(const QUrl &)));
|
this, SLOT(linkWasClicked(const QUrl &)));
|
||||||
|
@ -135,7 +138,9 @@ void SnippetsW::init()
|
||||||
oss <<
|
oss <<
|
||||||
"<html><head>"
|
"<html><head>"
|
||||||
"<meta http-equiv=\"content-type\" "
|
"<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>"
|
"<body>"
|
||||||
"<table style='overflow-x: scroll; white-space: nowrap'>"
|
"<table style='overflow-x: scroll; white-space: nowrap'>"
|
||||||
;
|
;
|
||||||
|
|
|
@ -394,6 +394,40 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</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>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
|
|
@ -62,8 +62,11 @@ void UIPrefsDialog::init()
|
||||||
connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
|
connect(viewActionPB, SIGNAL(clicked()), this, SLOT(showViewAction()));
|
||||||
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
|
||||||
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
connect(resetFontPB, SIGNAL(clicked()), this, SLOT(resetReslistFont()));
|
||||||
connect(stylesheetPB, SIGNAL(clicked()), this, SLOT(showStylesheetDialog()));
|
|
||||||
|
connect(stylesheetPB, SIGNAL(clicked()),this, SLOT(showStylesheetDialog()));
|
||||||
connect(resetSSPB, SIGNAL(clicked()), this, SLOT(resetStylesheet()));
|
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()),
|
connect(idxLV, SIGNAL(itemSelectionChanged()),
|
||||||
this, SLOT(extradDbSelectChanged()));
|
this, SLOT(extradDbSelectChanged()));
|
||||||
|
@ -142,14 +145,22 @@ void UIPrefsDialog::setFromPrefs()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Style sheet
|
// Style sheet
|
||||||
stylesheetFile = prefs.stylesheetFile;
|
qssFile = prefs.qssFile;
|
||||||
if (stylesheetFile.isEmpty()) {
|
if (qssFile.isEmpty()) {
|
||||||
stylesheetPB->setText(tr("Choose"));
|
stylesheetPB->setText(tr("Choose"));
|
||||||
} else {
|
} else {
|
||||||
string nm = path_getsimple((const char *)stylesheetFile.toLocal8Bit());
|
string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
|
||||||
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
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;
|
paraFormat = prefs.reslistformat;
|
||||||
headerText = prefs.reslistheadertext;
|
headerText = prefs.reslistheadertext;
|
||||||
|
|
||||||
|
@ -225,8 +236,9 @@ void UIPrefsDialog::accept()
|
||||||
|
|
||||||
prefs.reslistfontfamily = reslistFontFamily;
|
prefs.reslistfontfamily = reslistFontFamily;
|
||||||
prefs.reslistfontsize = reslistFontSize;
|
prefs.reslistfontsize = reslistFontSize;
|
||||||
prefs.stylesheetFile = stylesheetFile;
|
prefs.qssFile = qssFile;
|
||||||
QTimer::singleShot(0, m_mainWindow, SLOT(applyStyleSheet()));
|
QTimer::singleShot(0, m_mainWindow, SLOT(applyStyleSheet()));
|
||||||
|
prefs.snipCssFile = snipCssFile;
|
||||||
prefs.reslistformat = paraFormat;
|
prefs.reslistformat = paraFormat;
|
||||||
prefs.reslistheadertext = headerText;
|
prefs.reslistheadertext = headerText;
|
||||||
if (prefs.reslistformat.trimmed().isEmpty()) {
|
if (prefs.reslistformat.trimmed().isEmpty()) {
|
||||||
|
@ -364,16 +376,27 @@ void UIPrefsDialog::showFontDialog()
|
||||||
|
|
||||||
void UIPrefsDialog::showStylesheetDialog()
|
void UIPrefsDialog::showStylesheetDialog()
|
||||||
{
|
{
|
||||||
stylesheetFile = myGetFileName(false, "Select stylesheet file", true);
|
qssFile = myGetFileName(false, "Select stylesheet file", true);
|
||||||
string nm = path_getsimple((const char *)stylesheetFile.toLocal8Bit());
|
string nm = path_getsimple((const char *)qssFile.toLocal8Bit());
|
||||||
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
stylesheetPB->setText(QString::fromLocal8Bit(nm.c_str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void UIPrefsDialog::resetStylesheet()
|
void UIPrefsDialog::resetStylesheet()
|
||||||
{
|
{
|
||||||
stylesheetFile = "";
|
qssFile = "";
|
||||||
stylesheetPB->setText(tr("Choose"));
|
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()
|
void UIPrefsDialog::resetReslistFont()
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,7 +40,8 @@ public:
|
||||||
|
|
||||||
QString reslistFontFamily;
|
QString reslistFontFamily;
|
||||||
int reslistFontSize;
|
int reslistFontSize;
|
||||||
QString stylesheetFile;
|
QString qssFile;
|
||||||
|
QString snipCssFile;
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
|
||||||
|
@ -48,7 +49,9 @@ public slots:
|
||||||
virtual void showFontDialog();
|
virtual void showFontDialog();
|
||||||
virtual void resetReslistFont();
|
virtual void resetReslistFont();
|
||||||
virtual void showStylesheetDialog();
|
virtual void showStylesheetDialog();
|
||||||
|
virtual void showSnipCssDialog();
|
||||||
virtual void resetStylesheet();
|
virtual void resetStylesheet();
|
||||||
|
virtual void resetSnipCss();
|
||||||
virtual void showViewAction();
|
virtual void showViewAction();
|
||||||
virtual void showViewAction(const QString& mt);
|
virtual void showViewAction(const QString& mt);
|
||||||
virtual void addExtraDbPB_clicked();
|
virtual void addExtraDbPB_clicked();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue