summaryrefslogtreecommitdiffstats
path: root/searchdialog.cpp
diff options
context:
space:
mode:
authorArno <arno@disconnect.de>2018-02-03 04:19:54 +0100
committerArno <arno@disconnect.de>2018-02-03 04:20:57 +0100
commit65c61cf5ef74ef4be386e0e6a9bc056f34bc6adc (patch)
tree0681f3e281b2331f3aebb68aea881dff1d7e11d0 /searchdialog.cpp
parenta36cd9c8b352e94fd9e3be4f90ea6255b0c40618 (diff)
downloadShemovCleaner-65c61cf5ef74ef4be386e0e6a9bc056f34bc6adc.tar.gz
ShemovCleaner-65c61cf5ef74ef4be386e0e6a9bc056f34bc6adc.tar.bz2
ShemovCleaner-65c61cf5ef74ef4be386e0e6a9bc056f34bc6adc.zip
Add keyboard shortcuts in SearchDialog
CTRL+F: search filename CTRL+L: select all and focus search CTRL+M: search actor CTRL+T: search title CTRL+X: hide Unfortunately, it's surprisingly hard to capture CTRL+A, so I chose CTRL +M (m for model) for actor search. CTRL+A is consumed by some other Widget and never reaches SearchDialog. Maybe an EventFilter in the parent or the MainWindow would work, but that's not worth it.
Diffstat (limited to 'searchdialog.cpp')
-rw-r--r--searchdialog.cpp22
1 files changed, 20 insertions, 2 deletions
diff --git a/searchdialog.cpp b/searchdialog.cpp
index 0cb442c..04fbf18 100644
--- a/searchdialog.cpp
+++ b/searchdialog.cpp
@@ -22,10 +22,11 @@ SearchDialog::SearchDialog(QWidget *parent, Qt::WindowFlags f) : QDialog(parent,
//search bar
QLabel *typeL = new QLabel(tr("Search by:"));
mTypeSel = new QComboBox;
- mTypeSel->addItem(tr("Title"), Title);
- mTypeSel->addItem(tr("Filename"), Filename);
mTypeSel->addItem(tr("Actor"), Actors);
+ mTypeSel->addItem(tr("Filename"), Filename);
+ mTypeSel->addItem(tr("Title"), Title);
connect(mTypeSel, QOverload<int>::of(&QComboBox::activated), this, &SearchDialog::doSearch);
+ connect(mTypeSel, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &SearchDialog::doSearch);
mSearch = new QLineEdit;
QPushButton *goB = new QPushButton(tr("Go!"));
connect(goB, &QPushButton::clicked, this, &SearchDialog::doSearch);
@@ -321,6 +322,23 @@ void SearchDialog::keyPressEvent(QKeyEvent *e){
hide();
goto exit;
}
+ if(e->key() == Qt::Key_L && (e->modifiers() & Qt::ControlModifier)){
+ mSearch->selectAll();
+ mSearch->setFocus();
+ goto exit;
+ }
+ if(e->key() == Qt::Key_M && (e->modifiers() & Qt::ControlModifier)){
+ mTypeSel->setCurrentIndex(0);
+ goto exit;
+ }
+ if(e->key() == Qt::Key_F && (e->modifiers() & Qt::ControlModifier)){
+ mTypeSel->setCurrentIndex(1);
+ goto exit;
+ }
+ if(e->key() == Qt::Key_T && (e->modifiers() & Qt::ControlModifier)){
+ mTypeSel->setCurrentIndex(2);
+ goto exit;
+ }
return QDialog::keyPressEvent(e);
exit: