user interface preferences settable from ui
This commit is contained in:
parent
be485e8059
commit
e859f6a71c
@ -1,5 +1,5 @@
|
|||||||
#ifndef lint
|
#ifndef lint
|
||||||
static char rcsid[] = "@(#$Id: main.cpp,v 1.23 2005-12-13 17:20:46 dockes Exp $ (C) 2005 J.F.Dockes";
|
static char rcsid[] = "@(#$Id: main.cpp,v 1.24 2005-12-14 16:15:39 dockes Exp $ (C) 2005 J.F.Dockes";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@ -35,10 +35,17 @@ RclConfig *rclconfig;
|
|||||||
Rcl::Db *rcldb;
|
Rcl::Db *rcldb;
|
||||||
int recollNeedsExit;
|
int recollNeedsExit;
|
||||||
string tmpdir;
|
string tmpdir;
|
||||||
bool showicons;
|
|
||||||
string iconsdir;
|
string iconsdir;
|
||||||
RclDHistory *history;
|
RclDHistory *history;
|
||||||
|
|
||||||
|
/////////////////////////
|
||||||
|
// Global variables for user preferences. These are set in the user preference
|
||||||
|
// dialog and saved restored to the appropriate place in the qt settings
|
||||||
|
bool prefs_showicons;
|
||||||
|
int prefs_respagesize = 8;
|
||||||
|
QString prefs_reslistfontfamily;
|
||||||
|
int prefs_reslistfontsize;
|
||||||
|
|
||||||
static string dbdir;
|
static string dbdir;
|
||||||
|
|
||||||
void getQueryStemming(bool &dostem, std::string &stemlang)
|
void getQueryStemming(bool &dostem, std::string &stemlang)
|
||||||
@ -79,6 +86,14 @@ void recollCleanup()
|
|||||||
settings.writeEntry("/Recoll/geometry/height", height);
|
settings.writeEntry("/Recoll/geometry/height", height);
|
||||||
settings.writeEntry("/Recoll/prefs/simpleSearchAll",
|
settings.writeEntry("/Recoll/prefs/simpleSearchAll",
|
||||||
mainWindow->allTermsCB->isChecked());
|
mainWindow->allTermsCB->isChecked());
|
||||||
|
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);;
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_idxthread();
|
stop_idxthread();
|
||||||
@ -115,10 +130,19 @@ int main( int argc, char ** argv )
|
|||||||
// Restore some settings from previous session
|
// Restore some settings from previous session
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.setPath("Recoll.org", "Recoll");
|
settings.setPath("Recoll.org", "Recoll");
|
||||||
int width = settings.readNumEntry( "/Recoll/geometry/width", 590);
|
int width = settings.readNumEntry("/Recoll/geometry/width", 590);
|
||||||
int height = settings.readNumEntry( "/Recoll/geometry/height", 810);
|
int height = settings.readNumEntry("/Recoll/geometry/height", 810);
|
||||||
bool ssall = settings.readBoolEntry( "/Recoll/prefs/simpleSearchAll", 0);
|
bool ssall = settings.readBoolEntry("/Recoll/prefs/simpleSearchAll", 0);
|
||||||
QSize s(width, height);
|
QSize s(width, height);
|
||||||
|
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);;
|
||||||
|
|
||||||
|
|
||||||
// Create main window and set its size to previous session's
|
// Create main window and set its size to previous session's
|
||||||
RecollMain w;
|
RecollMain w;
|
||||||
@ -152,8 +176,6 @@ int main( int argc, char ** argv )
|
|||||||
translatdir.c_str() );
|
translatdir.c_str() );
|
||||||
a.installTranslator( &translator );
|
a.installTranslator( &translator );
|
||||||
|
|
||||||
showicons = false;
|
|
||||||
rclconfig->getConfParam("showicons", &showicons);
|
|
||||||
rclconfig->getConfParam("iconsdir", iconsdir);
|
rclconfig->getConfParam("iconsdir", iconsdir);
|
||||||
if (iconsdir.empty()) {
|
if (iconsdir.empty()) {
|
||||||
iconsdir = path_cat(recollsharedir, "images");
|
iconsdir = path_cat(recollsharedir, "images");
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
#ifndef _RECOLL_H_INCLUDED_
|
#ifndef _RECOLL_H_INCLUDED_
|
||||||
#define _RECOLL_H_INCLUDED_
|
#define _RECOLL_H_INCLUDED_
|
||||||
/* @(#$Id: recoll.h,v 1.7 2005-11-28 15:31:01 dockes Exp $ (C) 2004 J.F.Dockes */
|
/* @(#$Id: recoll.h,v 1.8 2005-12-14 16:15:39 dockes Exp $ (C) 2004 J.F.Dockes */
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
@ -18,10 +18,15 @@ extern bool maybeOpenDb(std::string &reason);
|
|||||||
extern RclConfig *rclconfig;
|
extern RclConfig *rclconfig;
|
||||||
extern Rcl::Db *rcldb;
|
extern Rcl::Db *rcldb;
|
||||||
extern std::string tmpdir;
|
extern std::string tmpdir;
|
||||||
extern bool showicons;
|
|
||||||
extern string iconsdir;
|
extern string iconsdir;
|
||||||
extern RclDHistory *history;
|
extern RclDHistory *history;
|
||||||
extern int recollNeedsExit;
|
extern int recollNeedsExit;
|
||||||
|
|
||||||
|
class QString;
|
||||||
|
extern bool prefs_showicons;
|
||||||
|
extern int prefs_respagesize;
|
||||||
|
extern QString prefs_reslistfontfamily;
|
||||||
|
extern int prefs_reslistfontsize;
|
||||||
|
|
||||||
|
|
||||||
#endif /* _RECOLL_H_INCLUDED_ */
|
#endif /* _RECOLL_H_INCLUDED_ */
|
||||||
|
|||||||
@ -10,7 +10,8 @@ SOURCES += main.cpp \
|
|||||||
FORMS = recollmain.ui \
|
FORMS = recollmain.ui \
|
||||||
advsearch.ui \
|
advsearch.ui \
|
||||||
preview/preview.ui \
|
preview/preview.ui \
|
||||||
sort.ui
|
sort.ui \
|
||||||
|
uiprefs.ui
|
||||||
|
|
||||||
IMAGES = images/filenew \
|
IMAGES = images/filenew \
|
||||||
images/fileopen \
|
images/fileopen \
|
||||||
@ -36,7 +37,6 @@ unix {
|
|||||||
$(BSTATIC) $(LIBXAPIAN) $(LIBICONV) $(BDYNAMIC) \
|
$(BSTATIC) $(LIBXAPIAN) $(LIBICONV) $(BDYNAMIC) \
|
||||||
-lz
|
-lz
|
||||||
INCLUDEPATH += ../common ../index ../query ../unac ../utils
|
INCLUDEPATH += ../common ../index ../query ../unac ../utils
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UNAME = $$system(uname -s)
|
UNAME = $$system(uname -s)
|
||||||
|
|||||||
@ -168,6 +168,9 @@
|
|||||||
<action name="toolsAdvanced_SearchAction"/>
|
<action name="toolsAdvanced_SearchAction"/>
|
||||||
<action name="toolsSort_parametersAction"/>
|
<action name="toolsSort_parametersAction"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item text="&Preferences" name="Preferences">
|
||||||
|
<action name="preferencesUser_InterfaceAction"/>
|
||||||
|
</item>
|
||||||
<separator/>
|
<separator/>
|
||||||
<item text="&Help" name="Help">
|
<item text="&Help" name="Help">
|
||||||
<separator/>
|
<separator/>
|
||||||
@ -324,6 +327,17 @@
|
|||||||
<string>Previous page of results</string>
|
<string>Previous page of results</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action>
|
||||||
|
<property name="name">
|
||||||
|
<cstring>preferencesUser_InterfaceAction</cstring>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>&User Interface</string>
|
||||||
|
</property>
|
||||||
|
<property name="menuText">
|
||||||
|
<string>&User Interface</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</actions>
|
</actions>
|
||||||
<connections>
|
<connections>
|
||||||
<connection>
|
<connection>
|
||||||
@ -410,6 +424,12 @@
|
|||||||
<receiver>RecollMain</receiver>
|
<receiver>RecollMain</receiver>
|
||||||
<slot>showResultPage()</slot>
|
<slot>showResultPage()</slot>
|
||||||
</connection>
|
</connection>
|
||||||
|
<connection>
|
||||||
|
<sender>preferencesUser_InterfaceAction</sender>
|
||||||
|
<signal>activated()</signal>
|
||||||
|
<receiver>RecollMain</receiver>
|
||||||
|
<slot>showUIPrefs()</slot>
|
||||||
|
</connection>
|
||||||
</connections>
|
</connections>
|
||||||
<includes>
|
<includes>
|
||||||
<include location="local" impldecl="in declaration">sortseq.h</include>
|
<include location="local" impldecl="in declaration">sortseq.h</include>
|
||||||
@ -417,6 +437,7 @@
|
|||||||
<include location="local" impldecl="in declaration">recoll.h</include>
|
<include location="local" impldecl="in declaration">recoll.h</include>
|
||||||
<include location="local" impldecl="in declaration">advsearch.h</include>
|
<include location="local" impldecl="in declaration">advsearch.h</include>
|
||||||
<include location="local" impldecl="in declaration">sort.h</include>
|
<include location="local" impldecl="in declaration">sort.h</include>
|
||||||
|
<include location="local" impldecl="in declaration">uiprefs.h</include>
|
||||||
<include location="local" impldecl="in implementation">recollmain.ui.h</include>
|
<include location="local" impldecl="in implementation">recollmain.ui.h</include>
|
||||||
</includes>
|
</includes>
|
||||||
<variables>
|
<variables>
|
||||||
@ -432,6 +453,7 @@
|
|||||||
<variable>Preview *curPreview;</variable>
|
<variable>Preview *curPreview;</variable>
|
||||||
<variable>advsearch *asearchform;</variable>
|
<variable>advsearch *asearchform;</variable>
|
||||||
<variable>SortForm *sortform;</variable>
|
<variable>SortForm *sortform;</variable>
|
||||||
|
<variable>UIPrefsDialog *uiprefs;</variable>
|
||||||
<variable>int sortwidth;</variable>
|
<variable>int sortwidth;</variable>
|
||||||
<variable>RclSortSpec sortspecs;</variable>
|
<variable>RclSortSpec sortspecs;</variable>
|
||||||
<variable>DocSequence *docsource;</variable>
|
<variable>DocSequence *docsource;</variable>
|
||||||
@ -457,12 +479,14 @@
|
|||||||
<slot>showDocHistory()</slot>
|
<slot>showDocHistory()</slot>
|
||||||
<slot>searchTextChanged( const QString & text )</slot>
|
<slot>searchTextChanged( const QString & text )</slot>
|
||||||
<slot>sortDataChanged( int cnt, RclSortSpec spec )</slot>
|
<slot>sortDataChanged( int cnt, RclSortSpec spec )</slot>
|
||||||
|
<slot>showUIPrefs()</slot>
|
||||||
|
<slot>setUIPrefs()</slot>
|
||||||
</slots>
|
</slots>
|
||||||
<functions>
|
<functions>
|
||||||
<function access="private">init()</function>
|
<function access="private">init()</function>
|
||||||
<function returnType="bool">close( bool )</function>
|
<function returnType="bool">close( bool )</function>
|
||||||
<function access="private" returnType="bool">eventFilter( QObject * target, QEvent * event )</function>
|
<function access="private" returnType="bool">eventFilter( QObject * target, QEvent * event )</function>
|
||||||
<function access="private" returnType="int">reldocnumfromparnum( int parnum )</function>
|
<function access="private" returnType="int">reldocnumfromparnum( int par )</function>
|
||||||
<function access="private">startPreview( int docnum )</function>
|
<function access="private">startPreview( int docnum )</function>
|
||||||
<function access="private">startNativeViewer( int docnum )</function>
|
<function access="private">startNativeViewer( int docnum )</function>
|
||||||
</functions>
|
</functions>
|
||||||
|
|||||||
@ -30,6 +30,8 @@ using std::pair;
|
|||||||
#include <qwindowdefs.h>
|
#include <qwindowdefs.h>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qcheckbox.h>
|
#include <qcheckbox.h>
|
||||||
|
#include <qfontdialog.h>
|
||||||
|
#include <qspinbox.h>
|
||||||
|
|
||||||
#include "recoll.h"
|
#include "recoll.h"
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
@ -40,6 +42,7 @@ using std::pair;
|
|||||||
#include "advsearch.h"
|
#include "advsearch.h"
|
||||||
#include "rclversion.h"
|
#include "rclversion.h"
|
||||||
#include "sortseq.h"
|
#include "sortseq.h"
|
||||||
|
#include "uiprefs.h"
|
||||||
|
|
||||||
extern "C" int XFlush(void *);
|
extern "C" int XFlush(void *);
|
||||||
|
|
||||||
@ -47,10 +50,6 @@ extern "C" int XFlush(void *);
|
|||||||
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
#define MIN(A,B) ((A) < (B) ? (A) : (B))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Number of abstracts in a result page. This will avoid scrollbars
|
|
||||||
// with the default window size and font, most of the time.
|
|
||||||
static const int respagesize = 8;
|
|
||||||
|
|
||||||
void RecollMain::init()
|
void RecollMain::init()
|
||||||
{
|
{
|
||||||
reslist_winfirst = -1;
|
reslist_winfirst = -1;
|
||||||
@ -66,6 +65,7 @@ void RecollMain::init()
|
|||||||
sortform = 0;
|
sortform = 0;
|
||||||
docsource = 0;
|
docsource = 0;
|
||||||
sortwidth = 0;
|
sortwidth = 0;
|
||||||
|
uiprefs = 0;
|
||||||
|
|
||||||
// We manage pgup/down, but let ie the arrows for the editor to process
|
// We manage pgup/down, but let ie the arrows for the editor to process
|
||||||
reslistTE->installEventFilter(this);
|
reslistTE->installEventFilter(this);
|
||||||
@ -74,6 +74,12 @@ void RecollMain::init()
|
|||||||
|
|
||||||
// Set the focus to the search terms entry:
|
// Set the focus to the search terms entry:
|
||||||
queryText->setFocus();
|
queryText->setFocus();
|
||||||
|
|
||||||
|
// Set result list font according to user preferences.
|
||||||
|
if (prefs_reslistfontfamily.length()) {
|
||||||
|
QFont nfont(prefs_reslistfontfamily, prefs_reslistfontsize);
|
||||||
|
reslistTE->setFont(nfont);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We also want to get rid of the advanced search form and previews
|
// We also want to get rid of the advanced search form and previews
|
||||||
@ -419,7 +425,7 @@ void RecollMain::resultPageBack()
|
|||||||
{
|
{
|
||||||
if (reslist_winfirst <= 0)
|
if (reslist_winfirst <= 0)
|
||||||
return;
|
return;
|
||||||
reslist_winfirst -= 2*respagesize;
|
reslist_winfirst -= 2 * prefs_respagesize;
|
||||||
showResultPage();
|
showResultPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -441,7 +447,8 @@ void RecollMain::showResultPage()
|
|||||||
pageParaToReldocnums.clear();
|
pageParaToReldocnums.clear();
|
||||||
|
|
||||||
// If we are already on the last page, nothing to do:
|
// If we are already on the last page, nothing to do:
|
||||||
if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize > resCnt)) {
|
if (reslist_winfirst >= 0 &&
|
||||||
|
(reslist_winfirst + prefs_respagesize > resCnt)) {
|
||||||
nextPageAction->setEnabled(false);
|
nextPageAction->setEnabled(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -451,13 +458,13 @@ void RecollMain::showResultPage()
|
|||||||
prevPageAction->setEnabled(false);
|
prevPageAction->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
prevPageAction->setEnabled(true);
|
prevPageAction->setEnabled(true);
|
||||||
reslist_winfirst += respagesize;
|
reslist_winfirst += prefs_respagesize;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool gotone = false;
|
bool gotone = false;
|
||||||
reslistTE->clear();
|
reslistTE->clear();
|
||||||
|
|
||||||
int last = MIN(resCnt-reslist_winfirst, respagesize);
|
int last = MIN(resCnt-reslist_winfirst, prefs_respagesize);
|
||||||
|
|
||||||
|
|
||||||
// Insert results if any in result list window. We have to send
|
// Insert results if any in result list window. We have to send
|
||||||
@ -509,7 +516,7 @@ void RecollMain::showResultPage()
|
|||||||
result = "<p>";
|
result = "<p>";
|
||||||
|
|
||||||
string img_name;
|
string img_name;
|
||||||
if (showicons) {
|
if (prefs_showicons) {
|
||||||
string iconname = rclconfig->getMimeIconName(doc.mimetype);
|
string iconname = rclconfig->getMimeIconName(doc.mimetype);
|
||||||
if (iconname.empty())
|
if (iconname.empty())
|
||||||
iconname = "document";
|
iconname = "document";
|
||||||
@ -565,7 +572,7 @@ void RecollMain::showResultPage()
|
|||||||
/*"<img align=\"left\" source=\"myimage\">"*/
|
/*"<img align=\"left\" source=\"myimage\">"*/
|
||||||
"<b>No results found</b>"
|
"<b>No results found</b>"
|
||||||
"<br>"));
|
"<br>"));
|
||||||
reslist_winfirst -= respagesize;
|
reslist_winfirst -= prefs_respagesize;
|
||||||
if (reslist_winfirst < 0)
|
if (reslist_winfirst < 0)
|
||||||
reslist_winfirst = -1;
|
reslist_winfirst = -1;
|
||||||
}
|
}
|
||||||
@ -584,7 +591,7 @@ void RecollMain::showResultPage()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (reslist_winfirst >= 0 && (reslist_winfirst + respagesize >= resCnt)) {
|
if (reslist_winfirst >= 0 && (reslist_winfirst + prefs_respagesize >= resCnt)) {
|
||||||
nextPageAction->setEnabled(false);
|
nextPageAction->setEnabled(false);
|
||||||
} else {
|
} else {
|
||||||
nextPageAction->setEnabled(true);
|
nextPageAction->setEnabled(true);
|
||||||
@ -641,6 +648,22 @@ void RecollMain::showSortDialog()
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RecollMain::showUIPrefs()
|
||||||
|
{
|
||||||
|
if (uiprefs == 0) {
|
||||||
|
uiprefs = new UIPrefsDialog(0, tr("User interface preferences"), FALSE,
|
||||||
|
WStyle_Customize | WStyle_NormalBorder |
|
||||||
|
WStyle_Title | WStyle_SysMenu);
|
||||||
|
uiprefs->setSizeGripEnabled(FALSE);
|
||||||
|
connect(uiprefs, SIGNAL(uiprefsDone()), this, SLOT(setUIPrefs()));
|
||||||
|
uiprefs->show();
|
||||||
|
} else {
|
||||||
|
// Close and reopen, in hope that makes us visible...
|
||||||
|
uiprefs->close();
|
||||||
|
uiprefs->show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Open a preview window for a given document, or load it into new tab of
|
* Open a preview window for a given document, or load it into new tab of
|
||||||
* existing window.
|
* existing window.
|
||||||
@ -790,3 +813,25 @@ void RecollMain::sortDataChanged(int cnt, RclSortSpec spec)
|
|||||||
sortwidth = cnt;
|
sortwidth = cnt;
|
||||||
sortspecs = spec;
|
sortspecs = spec;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// This could be handled inside the dialog's accept(), but we may want to
|
||||||
|
// do something (ie: redisplay reslist?)
|
||||||
|
void RecollMain::setUIPrefs()
|
||||||
|
{
|
||||||
|
if (!uiprefs)
|
||||||
|
return;
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user