--- a/src/qtgui/uiprefs_w.cpp
+++ b/src/qtgui/uiprefs_w.cpp
@@ -1,5 +1,5 @@
#ifndef lint
-static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.7 2006-09-22 10:46:26 dockes Exp $ (C) 2005 J.F.Dockes";
+static char rcsid[] = "@(#$Id: uiprefs_w.cpp,v 1.8 2006-11-07 08:57:11 dockes Exp $ (C) 2005 J.F.Dockes";
#endif
/*
* This program is free software; you can redistribute it and/or modify
@@ -49,76 +49,6 @@
void UIPrefsDialog::init()
{
- // Entries per result page spinbox
- pageLenSB->setValue(prefs.respagesize);
- // Show icons checkbox
- useIconsCB->setChecked(prefs.showicons);
- autoSearchCB->setChecked(prefs.autoSearchOnWS);
- syntlenSB->setValue(prefs.syntAbsLen);
- syntctxSB->setValue(prefs.syntAbsCtx);
-
- initStartAdvCB->setChecked(prefs.startWithAdvSearchOpen);
- initStartSortCB->setChecked(prefs.startWithSortToolOpen);
-
- // Result list font family and size
- reslistFontFamily = prefs.reslistfontfamily;
- reslistFontSize = prefs.reslistfontsize;
- QString s;
- if (prefs.reslistfontfamily.length() == 0) {
- reslistFontPB->setText(this->font().family() + "-" +
- s.setNum(this->font().pointSize()));
- } else {
- reslistFontPB->setText(reslistFontFamily + "-" +
- s.setNum(reslistFontSize));
- }
- helpBrowserLE->setText(prefs.htmlBrowser);
- // Stemming language combobox
- stemLangCMB->insertItem(tr("(no stemming)"));
- list<string> langs;
- string reason;
- if (!maybeOpenDb(reason)) {
- QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
- exit(1);
- }
- langs = rcldb->getStemLangs();
-
- int i = 0, cur = -1;
- for (list<string>::const_iterator it = langs.begin();
- it != langs.end(); it++) {
- stemLangCMB->
- insertItem(QString::fromAscii(it->c_str(), it->length()));
- i++;
- if (cur == -1) {
- if (!strcmp(prefs.queryStemLang.ascii(), it->c_str()))
- cur = i;
- }
- }
- if (cur < 0)
- cur = 0;
- stemLangCMB->setCurrentItem(cur);
-
- autoPhraseCB->setChecked(prefs.ssearchAutoPhrase);
-
- buildAbsCB->setChecked(prefs.queryBuildAbstract);
- if (!prefs.queryBuildAbstract) {
- replAbsCB->setEnabled(false);
- }
- replAbsCB->setChecked(prefs.queryReplaceAbstract);
-
- // Initialize the extra indexes listboxes
- QStringList ql;
- for (list<string>::iterator it = prefs.allExtraDbs.begin();
- it != prefs.allExtraDbs.end(); it++) {
- ql.append(QString::fromLocal8Bit(it->c_str()));
- }
- allDbsLB->insertStringList(ql);
- ql.clear();
- for (list<string>::iterator it = prefs.activeExtraDbs.begin();
- it != prefs.activeExtraDbs.end(); it++) {
- ql.append(QString::fromLocal8Bit(it->c_str()));
- }
- actDbsLB->insertStringList(ql);
- ql.clear();
connect(reslistFontPB, SIGNAL(clicked()), this, SLOT(showFontDialog()));
connect(helpBrowserPB, SIGNAL(clicked()), this, SLOT(showBrowserDialog()));
@@ -137,6 +67,82 @@
replAbsCB, SLOT(setEnabled(bool)));
}
+// Update dialog state from stored prefs
+void UIPrefsDialog::setFromPrefs()
+{
+ // Entries per result page spinbox
+ pageLenSB->setValue(prefs.respagesize);
+ // Show icons checkbox
+ useIconsCB->setChecked(prefs.showicons);
+ autoSearchCB->setChecked(prefs.autoSearchOnWS);
+ syntlenSB->setValue(prefs.syntAbsLen);
+ syntctxSB->setValue(prefs.syntAbsCtx);
+
+ initStartAdvCB->setChecked(prefs.startWithAdvSearchOpen);
+ initStartSortCB->setChecked(prefs.startWithSortToolOpen);
+
+ // Result list font family and size
+ reslistFontFamily = prefs.reslistfontfamily;
+ reslistFontSize = prefs.reslistfontsize;
+ QString s;
+ if (prefs.reslistfontfamily.length() == 0) {
+ reslistFontPB->setText(this->font().family() + "-" +
+ s.setNum(this->font().pointSize()));
+ } else {
+ reslistFontPB->setText(reslistFontFamily + "-" +
+ s.setNum(reslistFontSize));
+ }
+ helpBrowserLE->setText(prefs.htmlBrowser);
+
+ // Stemming language combobox
+ stemLangCMB->clear();
+ stemLangCMB->insertItem(tr("(no stemming)"));
+ list<string> langs;
+ string reason;
+ if (!maybeOpenDb(reason)) {
+ QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
+ exit(1);
+ }
+ langs = rcldb->getStemLangs();
+ int i = 0, cur = -1;
+ for (list<string>::const_iterator it = langs.begin();
+ it != langs.end(); it++) {
+ stemLangCMB->
+ insertItem(QString::fromAscii(it->c_str(), it->length()));
+ i++;
+ if (cur == -1) {
+ if (!strcmp(prefs.queryStemLang.ascii(), it->c_str()))
+ cur = i;
+ }
+ }
+ if (cur < 0)
+ cur = 0;
+ stemLangCMB->setCurrentItem(cur);
+
+ autoPhraseCB->setChecked(prefs.ssearchAutoPhrase);
+
+ buildAbsCB->setChecked(prefs.queryBuildAbstract);
+ replAbsCB->setEnabled(prefs.queryBuildAbstract);
+ replAbsCB->setChecked(prefs.queryReplaceAbstract);
+
+ // Initialize the extra indexes listboxes
+ QStringList ql;
+ for (list<string>::iterator it = prefs.allExtraDbs.begin();
+ it != prefs.allExtraDbs.end(); it++) {
+ ql.append(QString::fromLocal8Bit(it->c_str()));
+ }
+ allDbsLB->clear();
+ allDbsLB->insertStringList(ql);
+ ql.clear();
+ for (list<string>::iterator it = prefs.activeExtraDbs.begin();
+ it != prefs.activeExtraDbs.end(); it++) {
+ ql.append(QString::fromLocal8Bit(it->c_str()));
+ }
+ actDbsLB->clear();
+ actDbsLB->insertStringList(ql);
+ ql.clear();
+}
+
void UIPrefsDialog::accept()
{
prefs.showicons = useIconsCB->isChecked();
@@ -183,6 +189,11 @@
maybeOpenDb(reason, true);
emit uiprefsDone();
QDialog::accept();
+}
+void UIPrefsDialog::reject()
+{
+ setFromPrefs();
+ QDialog::reject();
}
void UIPrefsDialog::showFontDialog()