From 67f9c95a9b292c135b216bca4c1c2d869170dc2b Mon Sep 17 00:00:00 2001 From: dockes Date: Tue, 24 Feb 2009 18:30:08 +0000 Subject: [PATCH] implement option to display the catg filter as a toolbar combobox --- src/qtgui/guiutils.cpp | 1 + src/qtgui/guiutils.h | 3 +++ src/qtgui/rclmain_w.cpp | 17 ++++++++++++++++- src/qtgui/uiprefs.ui | 11 +++++++++++ src/qtgui/uiprefs_w.cpp | 2 ++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/qtgui/guiutils.cpp b/src/qtgui/guiutils.cpp index 965ada71..5f895e56 100644 --- a/src/qtgui/guiutils.cpp +++ b/src/qtgui/guiutils.cpp @@ -103,6 +103,7 @@ void rwSettings(bool writing) SETTING_RW(prefs.autoSearchOnWS, "/Recoll/prefs/reslist/autoSearchOnWS", Bool, false); + SETTING_RW(prefs.catgToolBar, "/Recoll/prefs/catgToolBar", Bool, false); SETTING_RW(prefs.ssearchAutoPhrase, "/Recoll/prefs/ssearchAutoPhrase", Bool, false); SETTING_RW(prefs.respagesize, "/Recoll/prefs/reslist/pagelen", Num, 8); diff --git a/src/qtgui/guiutils.h b/src/qtgui/guiutils.h index e8e90d6e..ba157fef 100644 --- a/src/qtgui/guiutils.h +++ b/src/qtgui/guiutils.h @@ -60,6 +60,9 @@ extern bool startHelpBrowser(const string& url = ""); class PrefsPack { public: bool autoSearchOnWS; + // Decide if we display the doc category filter control as a + // toolbar+combobox or as a button group under simple search + bool catgToolBar; int respagesize; int maxhltextmbs; QString reslistfontfamily; diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 7a37146d..2d681fca 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -43,6 +43,8 @@ using std::pair; #else #include #define QFileDialog Q3FileDialog +#include +#define QToolBar Q3ToolBar #endif #include @@ -165,6 +167,14 @@ void RclMain::init() } preferencesMenu->setItemChecked(curid, true); + // Toolbar+combobox version of the category selector + QComboBox *catgCMB = 0; + if (prefs.catgToolBar) { + catgCMB = new QComboBox(FALSE, new QToolBar(this), "catCMB"); + catgCMB->insertItem(tr("All")); + catgCMB->setToolTip(tr("Document category filter")); + } + // Document categories buttons catgBGRP->setColumnLayout(1, Qt::Vertical); list cats; @@ -178,9 +188,12 @@ void RclMain::init() QString catgnm = QString::fromUtf8(it->c_str(), it->length()); m_catgbutvec.push_back(*it); but->setText(tr(catgnm)); + if (prefs.catgToolBar && catgCMB) + catgCMB->insertItem(tr(catgnm)); } catgBGRP->setButton(0); - + if (prefs.catgToolBar) + catgBGRP->hide(); // Connections connect(sSearch, SIGNAL(startSearch(RefCntr)), this, SLOT(startSearch(RefCntr))); @@ -243,6 +256,8 @@ void RclMain::init() connect(queryPrefsAction, SIGNAL(activated()), this, SLOT(showUIPrefs())); connect(extIdxAction, SIGNAL(activated()), this, SLOT(showExtIdxDialog())); connect(catgBGRP, SIGNAL(clicked(int)), this, SLOT(catgFilter(int))); + if (prefs.catgToolBar && catgCMB) + connect(catgCMB, SIGNAL(activated(int)), this, SLOT(catgFilter(int))); #if (QT_VERSION < 0x040000) nextPageAction->setIconSet(createIconSet("nextpage.png")); diff --git a/src/qtgui/uiprefs.ui b/src/qtgui/uiprefs.ui index fe5e8285..f3fe8b32 100644 --- a/src/qtgui/uiprefs.ui +++ b/src/qtgui/uiprefs.ui @@ -284,6 +284,17 @@ Choose editor applications + + + catgToolBarCB + + + Display category filter as toolbar instead of button panel (needs restart). + + + false + + autoSearchCB diff --git a/src/qtgui/uiprefs_w.cpp b/src/qtgui/uiprefs_w.cpp index c281e208..cfdf1dcf 100644 --- a/src/qtgui/uiprefs_w.cpp +++ b/src/qtgui/uiprefs_w.cpp @@ -98,6 +98,7 @@ void UIPrefsDialog::setFromPrefs() pageLenSB->setValue(prefs.respagesize); collapseDupsCB->setChecked(prefs.collapseDuplicates); maxHLTSB->setValue(prefs.maxhltextmbs); + catgToolBarCB->setChecked(prefs.catgToolBar); autoSearchCB->setChecked(prefs.autoSearchOnWS); syntlenSB->setValue(prefs.syntAbsLen); syntctxSB->setValue(prefs.syntAbsCtx); @@ -171,6 +172,7 @@ void UIPrefsDialog::setFromPrefs() void UIPrefsDialog::accept() { prefs.autoSearchOnWS = autoSearchCB->isChecked(); + prefs.catgToolBar = catgToolBarCB->isChecked(); prefs.respagesize = pageLenSB->value(); prefs.collapseDuplicates = collapseDupsCB->isChecked(); prefs.maxhltextmbs = maxHLTSB->value();