user prefs tweaks. Allow switching stemlang from ui
This commit is contained in:
+39
-58
@@ -1,5 +1,5 @@
|
||||
#ifndef lint
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.25 2005-12-15 13:41:10 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.26 2005-12-15 14:39:57 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
@@ -37,6 +37,8 @@ int recollNeedsExit;
|
||||
string tmpdir;
|
||||
string iconsdir;
|
||||
RclDHistory *history;
|
||||
static string dbdir;
|
||||
static RecollMain *mainWindow;
|
||||
|
||||
/////////////////////////
|
||||
// Global variables for user preferences. These are set in the user preference
|
||||
@@ -49,8 +51,39 @@ QString prefs_queryStemLang;
|
||||
int prefs_mainwidth;
|
||||
int prefs_mainheight;
|
||||
bool prefs_ssall;
|
||||
|
||||
static string dbdir;
|
||||
|
||||
#define SETTING_RW(var, nm, tp, def) \
|
||||
if (writing) { \
|
||||
settings.writeEntry(nm , var); \
|
||||
} else { \
|
||||
var = settings.read##tp##Entry(nm, def); \
|
||||
}
|
||||
|
||||
static void rwSettings(bool writing)
|
||||
{
|
||||
if (writing) {
|
||||
if (!mainWindow)
|
||||
return;
|
||||
prefs_mainwidth = mainWindow->width();
|
||||
prefs_mainheight = mainWindow->height();
|
||||
prefs_ssall = mainWindow->allTermsCB->isChecked();
|
||||
}
|
||||
|
||||
QSettings settings;
|
||||
settings.setPath("Recoll.org", "Recoll");
|
||||
|
||||
SETTING_RW(prefs_mainwidth, "/Recoll/geometry/width", Num, 590);
|
||||
SETTING_RW(prefs_mainheight, "/Recoll/geometry/height", Num, 810);
|
||||
SETTING_RW(prefs_ssall, "/Recoll/prefs/simpleSearchAll", Bool, false);
|
||||
SETTING_RW(prefs_showicons, "/Recoll/prefs/reslist/showicons", Bool, true);
|
||||
SETTING_RW(prefs_respagesize, "/Recoll/prefs/reslist/pagelen", Num, 8);
|
||||
SETTING_RW(prefs_reslistfontfamily, "/Recoll/prefs/reslist/fontFamily", ,
|
||||
"");
|
||||
SETTING_RW(prefs_reslistfontsize, "/Recoll/prefs/reslist/fontSize", Num,
|
||||
0);
|
||||
SETTING_RW(prefs_queryStemLang, "/Recoll/prefs/query/stemLang", ,
|
||||
"english");
|
||||
}
|
||||
|
||||
bool maybeOpenDb(string &reason)
|
||||
{
|
||||
@@ -66,62 +99,9 @@ bool maybeOpenDb(string &reason)
|
||||
return true;
|
||||
}
|
||||
|
||||
RecollMain *mainWindow;
|
||||
|
||||
#define SETTING_RW(var, nm, tp, def) { \
|
||||
if (writing) { \
|
||||
settings.writeEntry(#nm , var); \
|
||||
} else { \
|
||||
var = settings.read##tp(#nm, def) \
|
||||
}
|
||||
|
||||
static void saveSettings()
|
||||
{
|
||||
if (!mainWindow)
|
||||
return;
|
||||
prefs_mainwidth = mainWindow->width();
|
||||
prefs_mainheight = mainWindow->height();
|
||||
prefs_ssall = mainWindow->allTermsCB->isChecked();
|
||||
|
||||
QSettings settings;
|
||||
settings.setPath("Recoll.org", "Recoll");
|
||||
|
||||
settings.writeEntry("/Recoll/geometry/width", prefs_mainwidth);
|
||||
settings.writeEntry("/Recoll/geometry/height", prefs_mainheight);
|
||||
settings.writeEntry("/Recoll/prefs/simpleSearchAll", prefs_ssall);
|
||||
settings.writeEntry("/Recoll/prefs/reslist/showicons", prefs_showicons);
|
||||
settings.writeEntry("/Recoll/prefs/reslist/pagelen", prefs_respagesize);
|
||||
settings.writeEntry("/Recoll/prefs/reslist/fontFamily",
|
||||
prefs_reslistfontfamily);
|
||||
settings.writeEntry("/Recoll/prefs/reslist/fontSize",
|
||||
prefs_reslistfontsize);;
|
||||
settings.writeEntry("/Recoll/prefs/query/stemLang", prefs_queryStemLang);;
|
||||
}
|
||||
|
||||
static void readSettings()
|
||||
{
|
||||
// Restore some settings from previous session
|
||||
QSettings settings;
|
||||
settings.setPath("Recoll.org", "Recoll");
|
||||
|
||||
prefs_mainwidth = settings.readNumEntry("/Recoll/geometry/width", 590);
|
||||
prefs_mainheight = settings.readNumEntry("/Recoll/geometry/height", 810);
|
||||
prefs_ssall = settings.readBoolEntry("/Recoll/prefs/simpleSearchAll", 0);
|
||||
prefs_showicons =
|
||||
settings.readBoolEntry("/Recoll/prefs/reslist/showicons", true);
|
||||
prefs_respagesize =
|
||||
settings.readNumEntry("/Recoll/prefs/reslist/pagelen", 8);
|
||||
prefs_reslistfontfamily =
|
||||
settings.readEntry("/Recoll/prefs/reslist/fontFamily", "");
|
||||
prefs_reslistfontsize =
|
||||
settings.readNumEntry("/Recoll/prefs/reslist/fontSize", 0);;
|
||||
prefs_queryStemLang =
|
||||
settings.readEntry("/Recoll/prefs/query/stemLang", "english");
|
||||
}
|
||||
|
||||
void recollCleanup()
|
||||
{
|
||||
saveSettings();
|
||||
rwSettings(true);
|
||||
stop_idxthread();
|
||||
delete rcldb;
|
||||
rcldb = 0;
|
||||
@@ -153,11 +133,12 @@ int main( int argc, char ** argv )
|
||||
qt.load( QString( "qt_" ) + QTextCodec::locale(), "." );
|
||||
a.installTranslator( &qt );
|
||||
|
||||
readSettings();
|
||||
rwSettings(false);
|
||||
|
||||
// Create main window and set its size to previous session's
|
||||
RecollMain w;
|
||||
mainWindow = &w;
|
||||
|
||||
QSize s(prefs_mainwidth, prefs_mainheight);
|
||||
w.resize(s);
|
||||
w.allTermsCB->setChecked(prefs_ssall);
|
||||
|
||||
+2
-3
@@ -1,6 +1,6 @@
|
||||
#ifndef _RECOLL_H_INCLUDED_
|
||||
#define _RECOLL_H_INCLUDED_
|
||||
/* @(#$Id: recoll.h,v 1.8 2005-12-14 16:15:39 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
/* @(#$Id: recoll.h,v 1.9 2005-12-15 14:39:57 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
|
||||
// Misc declarations in need of sharing between the UI files
|
||||
extern void recollCleanup();
|
||||
extern void getQueryStemming(bool &dostem, std::string &stemlang);
|
||||
extern bool maybeOpenDb(std::string &reason);
|
||||
|
||||
extern RclConfig *rclconfig;
|
||||
@@ -27,6 +26,6 @@ extern bool prefs_showicons;
|
||||
extern int prefs_respagesize;
|
||||
extern QString prefs_reslistfontfamily;
|
||||
extern int prefs_reslistfontsize;
|
||||
|
||||
extern QString prefs_queryStemLang;
|
||||
|
||||
#endif /* _RECOLL_H_INCLUDED_ */
|
||||
|
||||
@@ -169,7 +169,7 @@
|
||||
<action name="toolsSort_parametersAction"/>
|
||||
</item>
|
||||
<item text="&Preferences" name="Preferences">
|
||||
<action name="preferencesUser_InterfaceAction"/>
|
||||
<action name="preferencesQuery_PrefsAction"/>
|
||||
</item>
|
||||
<separator/>
|
||||
<item text="&Help" name="Help">
|
||||
@@ -329,13 +329,13 @@
|
||||
</action>
|
||||
<action>
|
||||
<property name="name">
|
||||
<cstring>preferencesUser_InterfaceAction</cstring>
|
||||
<cstring>preferencesQuery_PrefsAction</cstring>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>&User Interface</string>
|
||||
<string>&Query configuration</string>
|
||||
</property>
|
||||
<property name="menuText">
|
||||
<string>&User Interface</string>
|
||||
<string>&Query configuration</string>
|
||||
</property>
|
||||
</action>
|
||||
</actions>
|
||||
@@ -425,7 +425,7 @@
|
||||
<slot>showResultPage()</slot>
|
||||
</connection>
|
||||
<connection>
|
||||
<sender>preferencesUser_InterfaceAction</sender>
|
||||
<sender>preferencesQuery_PrefsAction</sender>
|
||||
<signal>activated()</signal>
|
||||
<receiver>RecollMain</receiver>
|
||||
<slot>showUIPrefs()</slot>
|
||||
@@ -448,8 +448,6 @@
|
||||
<variable>int reslist_car;</variable>
|
||||
<variable>bool reslist_waitingdbl;</variable>
|
||||
<variable>bool reslist_dblclck;</variable>
|
||||
<variable>bool dostem;</variable>
|
||||
<variable>std::string stemlang;</variable>
|
||||
<variable>Preview *curPreview;</variable>
|
||||
<variable>advsearch *asearchform;</variable>
|
||||
<variable>SortForm *sortform;</variable>
|
||||
|
||||
@@ -32,6 +32,7 @@ using std::pair;
|
||||
#include <qcheckbox.h>
|
||||
#include <qfontdialog.h>
|
||||
#include <qspinbox.h>
|
||||
#include <qcombobox.h>
|
||||
|
||||
#include "recoll.h"
|
||||
#include "debuglog.h"
|
||||
@@ -59,7 +60,6 @@ void RecollMain::init()
|
||||
reslist_car = -1;
|
||||
reslist_waitingdbl = false;
|
||||
reslist_dblclck = false;
|
||||
dostem = false;
|
||||
curPreview = 0;
|
||||
asearchform = 0;
|
||||
sortform = 0;
|
||||
@@ -377,13 +377,12 @@ void RecollMain::startAdvSearch(Rcl::AdvSearchData sdata)
|
||||
QMessageBox::critical(0, "Recoll", QString(reason.c_str()));
|
||||
exit(1);
|
||||
}
|
||||
if (stemlang.empty())
|
||||
getQueryStemming(dostem, stemlang);
|
||||
|
||||
reslist_winfirst = -1;
|
||||
|
||||
if (!rcldb->setQuery(sdata, dostem ?
|
||||
Rcl::Db::QO_STEM : Rcl::Db::QO_NONE, stemlang))
|
||||
if (!rcldb->setQuery(sdata, prefs_queryStemLang.length() > 0 ?
|
||||
Rcl::Db::QO_STEM : Rcl::Db::QO_NONE,
|
||||
prefs_queryStemLang.ascii()))
|
||||
return;
|
||||
curPreview = 0;
|
||||
if (docsource)
|
||||
@@ -591,7 +590,9 @@ void RecollMain::showResultPage()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (reslist_winfirst >= 0 && (reslist_winfirst + prefs_respagesize >= resCnt)) {
|
||||
if (reslist_winfirst < 0 ||
|
||||
(reslist_winfirst >= 0 &&
|
||||
reslist_winfirst + prefs_respagesize >= resCnt)) {
|
||||
nextPageAction->setEnabled(false);
|
||||
} else {
|
||||
nextPageAction->setEnabled(true);
|
||||
@@ -823,15 +824,19 @@ void RecollMain::setUIPrefs()
|
||||
LOGDEB(("Recollmain::setUIPrefs\n"));
|
||||
prefs_showicons = uiprefs->useIconsCB->isChecked();
|
||||
prefs_respagesize = uiprefs->pageLenSB->value();
|
||||
|
||||
prefs_reslistfontfamily = uiprefs->reslistFontFamily;
|
||||
prefs_reslistfontsize = uiprefs->reslistFontSize;
|
||||
|
||||
if (prefs_reslistfontfamily.length()) {
|
||||
QFont nfont(prefs_reslistfontfamily, prefs_reslistfontsize);
|
||||
reslistTE->setFont(nfont);
|
||||
} else {
|
||||
reslistTE->setFont(this->font());
|
||||
}
|
||||
|
||||
if (uiprefs->stemLangCMB->currentItem() == 0) {
|
||||
prefs_queryStemLang = "";
|
||||
} else {
|
||||
prefs_queryStemLang = uiprefs->stemLangCMB->currentText();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user