1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 12:02:48 +01:00

Remove global search popup frame and show on top when triggered.

This commit is contained in:
John Maguire 2011-09-01 15:41:47 +01:00
parent 914eb59215
commit ee9b9501ed
5 changed files with 21 additions and 0 deletions

View File

@ -1,5 +1,7 @@
#include "globalsearchpopup.h"
#include <QShortcut>
#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);
}

View File

@ -16,6 +16,9 @@ class GlobalSearchPopup : public QDialog {
void Init(LibraryBackendInterface* library);
// QWidget
void setFocus(Qt::FocusReason reason = Qt::PopupFocusReason);
signals:
void AddToPlaylist(QMimeData*);

View File

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

View File

@ -55,6 +55,7 @@ public:
// QWidget
bool eventFilter(QObject* o, QEvent* e);
void setFocus(Qt::FocusReason reason);
signals:
void AddToPlaylist(QMimeData* data);

View File

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