QT GUI: added shortcut to return focus to the search entry
This commit is contained in:
parent
e041b99860
commit
13e2413011
@ -40,6 +40,13 @@ using std::pair;
|
|||||||
#include <qpopupmenu.h>
|
#include <qpopupmenu.h>
|
||||||
#include <qradiobutton.h>
|
#include <qradiobutton.h>
|
||||||
#include <qbuttongroup.h>
|
#include <qbuttongroup.h>
|
||||||
|
#include <qaccel.h>
|
||||||
|
#undef RCLQT4
|
||||||
|
#define RCLQT3 1
|
||||||
|
#else
|
||||||
|
#undef RCLQT3
|
||||||
|
#define RCLQT4 1
|
||||||
|
#include <qshortcut.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <qtabwidget.h>
|
#include <qtabwidget.h>
|
||||||
@ -58,7 +65,6 @@ using std::pair;
|
|||||||
#include <qiconset.h>
|
#include <qiconset.h>
|
||||||
#include <qapplication.h>
|
#include <qapplication.h>
|
||||||
#include <qcursor.h>
|
#include <qcursor.h>
|
||||||
|
|
||||||
#include "recoll.h"
|
#include "recoll.h"
|
||||||
#include "debuglog.h"
|
#include "debuglog.h"
|
||||||
#include "mimehandler.h"
|
#include "mimehandler.h"
|
||||||
@ -87,7 +93,7 @@ extern "C" int XFlush(void *);
|
|||||||
QString g_stringAllStem, g_stringNoStem;
|
QString g_stringAllStem, g_stringNoStem;
|
||||||
|
|
||||||
// Taken from qt designer. Don't know why it's needed.
|
// Taken from qt designer. Don't know why it's needed.
|
||||||
#if (QT_VERSION < 0x040000)
|
#if RCLQT3
|
||||||
static QIconSet createIconSet(const QString &name)
|
static QIconSet createIconSet(const QString &name)
|
||||||
{
|
{
|
||||||
QIconSet ic(QPixmap::fromMimeSource(name));
|
QIconSet ic(QPixmap::fromMimeSource(name));
|
||||||
@ -167,13 +173,25 @@ void RclMain::init()
|
|||||||
}
|
}
|
||||||
preferencesMenu->setItemChecked(curid, true);
|
preferencesMenu->setItemChecked(curid, true);
|
||||||
|
|
||||||
|
// A shortcut to get the focus back to the search entry.
|
||||||
|
QKeySequence seq("Ctrl+Shift+s");
|
||||||
|
#if RCLQT4
|
||||||
|
QShortcut *sc = new QShortcut(seq, this);
|
||||||
|
connect(sc, SIGNAL (activated()), this, SLOT (focusToSearch()));
|
||||||
|
#else
|
||||||
|
QAccel *sc = new QAccel(this);
|
||||||
|
sc->insertItem(seq);
|
||||||
|
connect(sc, SIGNAL (activated(int)), this, SLOT (focusToSearch()));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// Toolbar+combobox version of the category selector
|
// Toolbar+combobox version of the category selector
|
||||||
QComboBox *catgCMB = 0;
|
QComboBox *catgCMB = 0;
|
||||||
if (prefs.catgToolBar) {
|
if (prefs.catgToolBar) {
|
||||||
QToolBar *catgToolBar = new QToolBar(this);
|
QToolBar *catgToolBar = new QToolBar(this);
|
||||||
catgCMB = new QComboBox(FALSE, catgToolBar, "catCMB");
|
catgCMB = new QComboBox(FALSE, catgToolBar, "catCMB");
|
||||||
catgCMB->insertItem(tr("All"));
|
catgCMB->insertItem(tr("All"));
|
||||||
#if (QT_VERSION >= 0x040000)
|
#if RCLQT4
|
||||||
catgToolBar->setObjectName(QString::fromUtf8("catgToolBar"));
|
catgToolBar->setObjectName(QString::fromUtf8("catgToolBar"));
|
||||||
catgCMB->setToolTip(tr("Document category filter"));
|
catgCMB->setToolTip(tr("Document category filter"));
|
||||||
catgToolBar->addWidget(catgCMB);
|
catgToolBar->addWidget(catgCMB);
|
||||||
@ -182,7 +200,7 @@ void RclMain::init()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Document categories buttons
|
// Document categories buttons
|
||||||
#if (QT_VERSION < 0x040000)
|
#if RCLQT3
|
||||||
catgBGRP->setColumnLayout(1, Qt::Vertical);
|
catgBGRP->setColumnLayout(1, Qt::Vertical);
|
||||||
connect(catgBGRP, SIGNAL(clicked(int)), this, SLOT(catgFilter(int)));
|
connect(catgBGRP, SIGNAL(clicked(int)), this, SLOT(catgFilter(int)));
|
||||||
#else
|
#else
|
||||||
@ -206,12 +224,12 @@ void RclMain::init()
|
|||||||
but->setText(tr(catgnm));
|
but->setText(tr(catgnm));
|
||||||
if (prefs.catgToolBar && catgCMB)
|
if (prefs.catgToolBar && catgCMB)
|
||||||
catgCMB->insertItem(tr(catgnm));
|
catgCMB->insertItem(tr(catgnm));
|
||||||
#if (QT_VERSION >= 0x040000)
|
#if RCLQT4
|
||||||
bgrphbox->addWidget(but);
|
bgrphbox->addWidget(but);
|
||||||
bgrp->addButton(but, bgrpid++);
|
bgrp->addButton(but, bgrpid++);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#if (QT_VERSION < 0x040000)
|
#if RCLQT3
|
||||||
catgBGRP->setButton(0);
|
catgBGRP->setButton(0);
|
||||||
#else
|
#else
|
||||||
catgBGRP->setLayout(bgrphbox);
|
catgBGRP->setLayout(bgrphbox);
|
||||||
@ -222,7 +240,7 @@ void RclMain::init()
|
|||||||
// Connections
|
// Connections
|
||||||
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
connect(sSearch, SIGNAL(startSearch(RefCntr<Rcl::SearchData>)),
|
||||||
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
|
this, SLOT(startSearch(RefCntr<Rcl::SearchData>)));
|
||||||
#if QT_VERSION >= 0x040000
|
#if RCLQT4
|
||||||
sSearch->queryText->installEventFilter(this);
|
sSearch->queryText->installEventFilter(this);
|
||||||
#else
|
#else
|
||||||
sSearch->queryText->lineEdit()->installEventFilter(this);
|
sSearch->queryText->lineEdit()->installEventFilter(this);
|
||||||
@ -291,7 +309,7 @@ void RclMain::init()
|
|||||||
// speeded up during indexing
|
// speeded up during indexing
|
||||||
periodictimer->start(1000);
|
periodictimer->start(1000);
|
||||||
|
|
||||||
#if (QT_VERSION < 0x040000)
|
#if RCLQT3
|
||||||
nextPageAction->setIconSet(createIconSet("nextpage.png"));
|
nextPageAction->setIconSet(createIconSet("nextpage.png"));
|
||||||
prevPageAction->setIconSet(createIconSet("prevpage.png"));
|
prevPageAction->setIconSet(createIconSet("prevpage.png"));
|
||||||
firstPageAction->setIconSet(createIconSet("firstpage.png"));
|
firstPageAction->setIconSet(createIconSet("firstpage.png"));
|
||||||
@ -369,6 +387,16 @@ void RclMain::initDbOpen()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RclMain::focusToSearch()
|
||||||
|
{
|
||||||
|
LOGDEB(("Giving focus to sSearch\n"));
|
||||||
|
sSearch->queryText->setFocus(
|
||||||
|
#if RCLQT4
|
||||||
|
Qt::ShortcutFocusReason
|
||||||
|
#endif
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
void RclMain::setStemLang(int id)
|
void RclMain::setStemLang(int id)
|
||||||
{
|
{
|
||||||
LOGDEB(("RclMain::setStemLang(%d)\n", id));
|
LOGDEB(("RclMain::setStemLang(%d)\n", id));
|
||||||
|
|||||||
@ -112,6 +112,7 @@ public slots:
|
|||||||
virtual void catgFilter(int);
|
virtual void catgFilter(int);
|
||||||
virtual void initDbOpen();
|
virtual void initDbOpen();
|
||||||
virtual void toggleFullScreen();
|
virtual void toggleFullScreen();
|
||||||
|
virtual void focusToSearch();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void stemLangChanged(const QString& lang);
|
void stemLangChanged(const QString& lang);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user