From aeb21594c540ecab7bbd2c7a37d9e2fcec13b286 Mon Sep 17 00:00:00 2001 From: Arno Date: Fri, 2 Feb 2018 07:51:09 +0100 Subject: Add CTRL+S shortcut for SearchDialog If in FileWidget, show and raise SearchDialog on CTRL+s, hide it on CTRL +x. Show busy cursor while searching. --- searchdialog.cpp | 17 +++++++++++++++++ searchdialog.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/searchdialog.cpp b/searchdialog.cpp index ff469ee..79beb0f 100644 --- a/searchdialog.cpp +++ b/searchdialog.cpp @@ -11,6 +11,8 @@ #include #include #include +#include +#include #include "searchdialog.h" #include "helper.h" @@ -81,6 +83,7 @@ SearchDialog::~SearchDialog(){ void SearchDialog::doSearch(){ int type = mTypeSel->currentData().toInt(); + qApp->setOverrideCursor(Qt::BusyCursor); if(type == Title){ doSearchTitle(); }else if(type == Filename){ @@ -88,16 +91,19 @@ void SearchDialog::doSearch(){ }else if(type == Actors){ doSearchActor(); } + qApp->restoreOverrideCursor(); } void SearchDialog::doResult(const QModelIndex &cur, const QModelIndex &prev){ Q_UNUSED(prev) int type = mTypeSel->currentData().toInt(); + qApp->setOverrideCursor(Qt::BusyCursor); if(type == Title || type == Filename){ doResultName(cur, type); }else if(type == Actors){ doResultActor(cur); } + qApp->restoreOverrideCursor(); } void SearchDialog::doSearchTitle(){ @@ -293,6 +299,17 @@ void SearchDialog::readSettings(){ } } +void SearchDialog::keyPressEvent(QKeyEvent *e){ + if(e->key() == Qt::Key_X && (e->modifiers() & Qt::ControlModifier)){ + hide(); + goto exit; + } + return QDialog::keyPressEvent(e); + + exit: + e->accept(); +} + void SearchDialog::doChild(QStandardItem *item, int childMode){ QStringList res; QIcon aIcon; diff --git a/searchdialog.h b/searchdialog.h index efe081e..0ef4aad 100644 --- a/searchdialog.h +++ b/searchdialog.h @@ -29,6 +29,9 @@ class SearchDialog : public QDialog { void writeSettings(); void readSettings(); + protected: + virtual void keyPressEvent(QKeyEvent *e); + private: void doChild(QStandardItem *item, int childMode); void doActorGenres(QStandardItem *item); -- cgit v1.2.3-70-g09d2