F1 context-enhanced help

This commit is contained in:
dockes 2009-01-28 16:56:36 +00:00
parent b5270894ce
commit e800ca071a
11 changed files with 64 additions and 13 deletions

View File

@ -25,13 +25,16 @@ static char rcsid[] = "@(#$Id: advsearch_w.cpp,v 1.21 2008-09-25 06:00:24 dockes
#include <qlineedit.h>
#include <qframe.h>
#include <qcheckbox.h>
#include <qevent.h>
#if (QT_VERSION < 0x040000)
#include <qcombobox.h>
#include <qlistbox.h>
#define Q34EVOVERRIDE QEvent::AccelOverride
#else
#include <q3combobox.h>
#include <q3listbox.h>
#define Q34EVOVERRIDE QEvent::ShortcutOverride
#endif
#include <qlayout.h>
@ -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<QString,QString> 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<QKeyEvent *>(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();
}

View File

@ -59,6 +59,7 @@ public:
init();
}
~AdvSearch(){}
virtual bool eventFilter(QObject *target, QEvent *event);
public slots:
virtual void delFiltypPB_clicked();

View File

@ -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)

View File

@ -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&)));

View File

@ -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<string> 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();
}

View File

@ -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();

View File

@ -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;

View File

@ -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 \

View File

@ -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)));

View File

@ -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()));

View File

@ -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&)));