diff --git a/src/globalsearch/globalsearchpopup.cpp b/src/globalsearch/globalsearchpopup.cpp index 443ae526a..380c6517b 100644 --- a/src/globalsearch/globalsearchpopup.cpp +++ b/src/globalsearch/globalsearchpopup.cpp @@ -1,5 +1,7 @@ #include "globalsearchpopup.h" +#include + #include "ui/iconloader.h" GlobalSearchPopup::GlobalSearchPopup(QWidget* parent) @@ -7,10 +9,16 @@ GlobalSearchPopup::GlobalSearchPopup(QWidget* parent) ui_(new Ui_GlobalSearchPopup) { ui_->setupUi(this); + Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Popup; + setWindowFlags(flags); + ui_->previous->setIcon(IconLoader::Load("media-skip-backward")); ui_->next->setIcon(IconLoader::Load("media-skip-forward")); ui_->play_pause->setIcon(IconLoader::Load("media-playback-start")); ui_->stop->setIcon(IconLoader::Load("media-playback-stop")); + + QShortcut* shortcut = new QShortcut(QKeySequence::Close, this); + connect(shortcut, SIGNAL(activated()), SLOT(close())); } void GlobalSearchPopup::Init(LibraryBackendInterface* library) { @@ -20,3 +28,7 @@ void GlobalSearchPopup::Init(LibraryBackendInterface* library) { connect(ui_->search_widget, SIGNAL(AddToPlaylist(QMimeData*)), SIGNAL(AddToPlaylist(QMimeData*))); } + +void GlobalSearchPopup::setFocus(Qt::FocusReason reason) { + ui_->search_widget->setFocus(reason); +} diff --git a/src/globalsearch/globalsearchpopup.h b/src/globalsearch/globalsearchpopup.h index 2ffd040f9..dfa03371f 100644 --- a/src/globalsearch/globalsearchpopup.h +++ b/src/globalsearch/globalsearchpopup.h @@ -16,6 +16,9 @@ class GlobalSearchPopup : public QDialog { void Init(LibraryBackendInterface* library); + // QWidget + void setFocus(Qt::FocusReason reason = Qt::PopupFocusReason); + signals: void AddToPlaylist(QMimeData*); diff --git a/src/globalsearch/globalsearchwidget.cpp b/src/globalsearch/globalsearchwidget.cpp index 21c4d6199..772ec6fbc 100644 --- a/src/globalsearch/globalsearchwidget.cpp +++ b/src/globalsearch/globalsearchwidget.cpp @@ -318,6 +318,10 @@ bool GlobalSearchWidget::eventFilter(QObject* o, QEvent* e) { return false; } +void GlobalSearchWidget::setFocus(Qt::FocusReason reason) { + ui_->search->setFocus(reason); +} + void GlobalSearchWidget::LazyLoadArt(const QModelIndex& proxy_index) { if (!proxy_index.isValid() || proxy_index.data(Role_LazyLoadingArt).isValid()) { return; diff --git a/src/globalsearch/globalsearchwidget.h b/src/globalsearch/globalsearchwidget.h index cfa1cc75f..47e48905a 100644 --- a/src/globalsearch/globalsearchwidget.h +++ b/src/globalsearch/globalsearchwidget.h @@ -55,6 +55,7 @@ public: // QWidget bool eventFilter(QObject* o, QEvent* e); + void setFocus(Qt::FocusReason reason); signals: void AddToPlaylist(QMimeData* data); diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 6f5526149..661cbf7cf 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -2250,4 +2250,5 @@ void MainWindow::ShowGlobalSearch() { css_loader->SetStyleSheet(popup, ":mainwindow.css"); connect(popup, SIGNAL(AddToPlaylist(QMimeData*)), SLOT(AddToPlaylist(QMimeData*))); popup->show(); + popup->setFocus(); }