From e800ca071abcf5477dad1951a345cb8b61c756b4 Mon Sep 17 00:00:00 2001 From: dockes Date: Wed, 28 Jan 2009 16:56:36 +0000 Subject: [PATCH] F1 context-enhanced help --- src/qtgui/advsearch_w.cpp | 26 ++++++++++++++++++++++++-- src/qtgui/advsearch_w.h | 1 + src/qtgui/main.cpp | 7 ++++--- src/qtgui/preview_w.cpp | 6 ++++++ src/qtgui/rclmain_w.cpp | 18 +++++++++++++----- src/qtgui/rclmain_w.h | 1 + src/qtgui/recoll.h | 3 +-- src/qtgui/recoll.pro.in | 2 ++ src/qtgui/reslist.cpp | 4 ++++ src/qtgui/sort_w.cpp | 5 ++++- src/qtgui/spell_w.cpp | 4 ++++ 11 files changed, 64 insertions(+), 13 deletions(-) diff --git a/src/qtgui/advsearch_w.cpp b/src/qtgui/advsearch_w.cpp index 41e6cf98..c6739a6c 100644 --- a/src/qtgui/advsearch_w.cpp +++ b/src/qtgui/advsearch_w.cpp @@ -25,13 +25,16 @@ static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.21 2008-09-25 06:00:24 dockes #include #include #include +#include #if (QT_VERSION < 0x040000) #include #include +#define Q34EVOVERRIDE QEvent::AccelOverride #else #include #include +#define Q34EVOVERRIDE QEvent::ShortcutOverride #endif #include @@ -57,6 +60,7 @@ using std::unique; #include "debuglog.h" #include "searchdata.h" #include "guiutils.h" +#include "rclhelp.h" extern RclConfig *rclconfig; @@ -68,6 +72,11 @@ static map cat_rtranslations; void AdvSearch::init() { + (void)new HelpClient(this); + HelpClient::installMap(this->name(), "RCL.SEARCH.COMPLEX"); + + this->installEventFilter(this); + // signals and slots connections connect(delFiltypPB, SIGNAL(clicked()), this, SLOT(delFiltypPB_clicked())); connect(searchPB, SIGNAL(clicked()), this, SLOT(runSearch())); @@ -108,6 +117,7 @@ void AdvSearch::init() } } } + (*m_clauseWins.begin())->wordsLE->setFocus(); // Initialize lists of accepted and ignored mime types from config // and settings @@ -116,7 +126,7 @@ void AdvSearch::init() restrictCtCB->setEnabled(false); restrictCtCB->setChecked(m_ignByCats); fillFileTypes(); - setHelpIndex("RCL.SEARCH.COMPLEX"); + subtreeCMB->insertStringList(prefs.asearchSubdirHist); subtreeCMB->setEditText(""); @@ -146,6 +156,19 @@ void AdvSearch::init() cat_rtranslations[tr("other")] = QString::fromUtf8("other"); } +bool AdvSearch::eventFilter(QObject *, QEvent *event) +{ + // LOGDEB(("AdvSearch::eventFilter. Type %d\n", (int)event->type())); + if (event->type() == QEvent::KeyPress || event->type() == Q34EVOVERRIDE) { + QKeyEvent *ke = static_cast(event); + if (ke->key() == Qt::Key_Q && (ke->state() & Qt::ControlButton)) { + recollNeedsExit = 1; + return true; + } + } + return false; +} + void AdvSearch::saveCnf() { // Save my state @@ -158,7 +181,6 @@ void AdvSearch::saveCnf() bool AdvSearch::close() { - setHelpIndex("RCL.SEARCH.SIMPLE"); saveCnf(); return QWidget::close(); } diff --git a/src/qtgui/advsearch_w.h b/src/qtgui/advsearch_w.h index 23f39102..8b0190e8 100644 --- a/src/qtgui/advsearch_w.h +++ b/src/qtgui/advsearch_w.h @@ -59,6 +59,7 @@ public: init(); } ~AdvSearch(){} + virtual bool eventFilter(QObject *target, QEvent *event); public slots: virtual void delFiltypPB_clicked(); diff --git a/src/qtgui/main.cpp b/src/qtgui/main.cpp index 5e6163be..96bda342 100644 --- a/src/qtgui/main.cpp +++ b/src/qtgui/main.cpp @@ -89,10 +89,11 @@ int recollNeedsExit; int startIndexingAfterConfig; RclMain *mainWindow; static string recollsharedir; -const char *g_helpIndex; -void setHelpIndex(const char *index) + +void startManual(const string& helpindex) { - g_helpIndex = index; + if (mainWindow) + mainWindow->startManual(helpindex); } bool maybeOpenDb(string &reason, bool force) diff --git a/src/qtgui/preview_w.cpp b/src/qtgui/preview_w.cpp index abd17a5b..586536c3 100644 --- a/src/qtgui/preview_w.cpp +++ b/src/qtgui/preview_w.cpp @@ -85,6 +85,9 @@ using std::pair; #define QTEXTPARAGRAPH Q3TextParagraph #define QTEXTSTRINGCHAR Q3TextStringChar #endif + +#include "rclhelp.h" + // QTextEdit's scrollToAnchor() is supposed to make the anchor visible, but // actually, it only moves to the top of the paragraph containing the anchor. // As we only have one paragraph, this doesnt' help a lot (qt3 and qt4) @@ -189,6 +192,9 @@ void Preview::init() pvTab->setCornerWidget(bt); + (void)new HelpClient(this); + HelpClient::installMap(this->name(), "RCL.SEARCH.PREVIEW"); + // signals and slots connections connect(searchTextLine, SIGNAL(textChanged(const QString&)), this, SLOT(searchTextLine_textChanged(const QString&))); diff --git a/src/qtgui/rclmain_w.cpp b/src/qtgui/rclmain_w.cpp index 6f179bec..421d3096 100644 --- a/src/qtgui/rclmain_w.cpp +++ b/src/qtgui/rclmain_w.cpp @@ -84,6 +84,7 @@ using std::pair; using namespace confgui; #include "rclmain_w.h" +#include "rclhelp.h" #include "moc_rclmain_w.cpp" extern "C" int XFlush(void *); @@ -119,6 +120,9 @@ void RclMain::init() spellform = 0; m_idxStatusAck = false; + (void)new HelpClient(this); + HelpClient::installMap(this->name(), "RCL.SEARCH.SIMPLE"); + // Set the focus to the search terms entry: sSearch->queryText->setFocus(); @@ -161,8 +165,6 @@ void RclMain::init() } preferencesMenu->setItemChecked(curid, true); - setHelpIndex("RCL.SEARCH.SIMPLE"); - // Document categories buttons catgBGRP->setColumnLayout(1, Qt::Vertical); list cats; @@ -984,6 +986,11 @@ void RclMain::startNativeViewer(Rcl::Doc doc) } void RclMain::startManual() +{ + startManual(string()); +} + +void RclMain::startManual(const string& index) { QString msg = tr("Starting html help browser "); statusBar()->message(msg, 3000); @@ -993,10 +1000,10 @@ void RclMain::startManual() doc.url = path_cat(doc.url, "doc"); doc.url = path_cat(doc.url, "usermanual.html"); LOGDEB(("RclMain::startManual: help index is %s\n", - g_helpIndex?g_helpIndex:"(null)")); - if (g_helpIndex && *g_helpIndex) { + index.empty()?"(null)":index.c_str())); + if (!index.empty()) { doc.url += "#"; - doc.url += g_helpIndex; + doc.url += index; } doc.mimetype = "text/html"; startNativeViewer(doc); @@ -1110,3 +1117,4 @@ void RclMain::catgFilter(int id) resList->setFilterParams(spec); resList->setDocSource(); } + diff --git a/src/qtgui/rclmain_w.h b/src/qtgui/rclmain_w.h index 2705bade..c2e25248 100644 --- a/src/qtgui/rclmain_w.h +++ b/src/qtgui/rclmain_w.h @@ -84,6 +84,7 @@ public slots: virtual void showAboutDialog(); virtual void showMissingHelpers(); virtual void startManual(); + virtual void startManual(const string&); virtual void showDocHistory(); virtual void showExtIdxDialog(); virtual void showUIPrefs(); diff --git a/src/qtgui/recoll.h b/src/qtgui/recoll.h index c0410197..3b53b469 100644 --- a/src/qtgui/recoll.h +++ b/src/qtgui/recoll.h @@ -34,8 +34,7 @@ extern Rcl::Db *rcldb; extern int recollNeedsExit; extern int startIndexingAfterConfig; // 1st startup extern RclHistory *g_dynconf; -extern const char *g_helpIndex; -extern void setHelpIndex(const char *index); +extern void startManual(const string& helpindex); #ifdef RCL_USE_ASPELL class Aspell; diff --git a/src/qtgui/recoll.pro.in b/src/qtgui/recoll.pro.in index 4a27a9d3..0ccb3d79 100644 --- a/src/qtgui/recoll.pro.in +++ b/src/qtgui/recoll.pro.in @@ -9,6 +9,7 @@ HEADERS += \ preview_w.h \ rclmain_w.h \ reslist.h \ + rclhelp.h \ sort_w.h \ searchclause_w.h \ ssearch_w.h \ @@ -25,6 +26,7 @@ SOURCES += \ rclmain_w.cpp \ reslist.cpp \ advsearch_w.cpp \ + rclhelp.cpp \ spell_w.cpp \ preview_w.cpp \ sort_w.cpp \ diff --git a/src/qtgui/reslist.cpp b/src/qtgui/reslist.cpp index f0a999b2..4e5d372f 100644 --- a/src/qtgui/reslist.cpp +++ b/src/qtgui/reslist.cpp @@ -45,6 +45,7 @@ static char rcsid[] = "@(#$Id: reslist.cpp,v 1.52 2008-12-17 15:12:08 dockes Exp #include "reslist.h" #include "moc_reslist.cpp" +#include "rclhelp.h" #ifndef MIN #define MIN(A,B) ((A) < (B) ? (A) : (B)) @@ -69,6 +70,9 @@ ResList::ResList(QWidget* parent, const char* name) setTabChangesFocus(true); + (void)new HelpClient(this); + HelpClient::installMap(this->name(), "RCL.SEARCH.RESLIST"); + // signals and slots connections connect(this, SIGNAL(linkClicked(const QString &, int)), this, SLOT(linkWasClicked(const QString &, int))); diff --git a/src/qtgui/sort_w.cpp b/src/qtgui/sort_w.cpp index 06e64620..1b077748 100644 --- a/src/qtgui/sort_w.cpp +++ b/src/qtgui/sort_w.cpp @@ -26,7 +26,7 @@ static char rcsid[] = "@(#$Id: sort_w.cpp,v 1.7 2008-09-28 14:20:50 dockes Exp $ #include "sortseq.h" #include "debuglog.h" #include "guiutils.h" - +#include "rclhelp.h" #include "sort_w.h" void SortForm::init() @@ -70,6 +70,9 @@ void SortForm::init() fldCMB2->setCurrentItem(v < 3 ? v : 0); descCB2->setChecked(d !=0 ? true : false); + (void)new HelpClient(this); + HelpClient::installMap(this->name(), "RCL.SEARCH.SORT"); + // signals and slots connections connect(applyPB, SIGNAL(clicked()), this, SLOT(apply())); connect(closePB, SIGNAL(clicked()), this, SLOT(close())); diff --git a/src/qtgui/spell_w.cpp b/src/qtgui/spell_w.cpp index 6f64eb72..44c91756 100644 --- a/src/qtgui/spell_w.cpp +++ b/src/qtgui/spell_w.cpp @@ -44,6 +44,7 @@ static char rcsid[] = "@(#$Id: spell_w.cpp,v 1.11 2007-02-19 16:28:05 dockes Exp #include "spell_w.h" #include "guiutils.h" #include "rcldb.h" +#include "rclhelp.h" #ifdef RCL_USE_ASPELL #include "rclaspell.h" @@ -81,6 +82,9 @@ void SpellW::init() } stemLangCMB->setEnabled(expTypeCMB->currentItem()==2); + (void)new HelpClient(this); + HelpClient::installMap(this->name(), "RCL.SEARCH.TERMEXPLORER"); + // signals and slots connections connect(baseWordLE, SIGNAL(textChanged(const QString&)), this, SLOT(wordChanged(const QString&)));