Improve the behaviour of the search popup on Mac.
This commit is contained in:
parent
58dae530f2
commit
55fc18fcc7
@ -701,6 +701,7 @@ if(APPLE)
|
|||||||
list(APPEND HEADERS widgets/maclineedit.h)
|
list(APPEND HEADERS widgets/maclineedit.h)
|
||||||
list(APPEND SOURCES core/macglobalshortcutbackend.mm)
|
list(APPEND SOURCES core/macglobalshortcutbackend.mm)
|
||||||
list(APPEND SOURCES devices/macdevicelister.mm)
|
list(APPEND SOURCES devices/macdevicelister.mm)
|
||||||
|
list(APPEND SOURCES globalsearch/globalsearchpopup.mm)
|
||||||
list(APPEND SOURCES ui/globalshortcutgrabber.mm)
|
list(APPEND SOURCES ui/globalshortcutgrabber.mm)
|
||||||
list(APPEND SOURCES ui/macscreensaver.cpp)
|
list(APPEND SOURCES ui/macscreensaver.cpp)
|
||||||
list(APPEND SOURCES ui/macsystemtrayicon.mm)
|
list(APPEND SOURCES ui/macsystemtrayicon.mm)
|
||||||
|
@ -19,24 +19,26 @@
|
|||||||
|
|
||||||
#include <QShortcut>
|
#include <QShortcut>
|
||||||
|
|
||||||
|
#include "core/logging.h"
|
||||||
#include "core/player.h"
|
#include "core/player.h"
|
||||||
#include "ui/iconloader.h"
|
#include "ui/iconloader.h"
|
||||||
|
|
||||||
GlobalSearchPopup::GlobalSearchPopup(QWidget* parent)
|
GlobalSearchPopup::GlobalSearchPopup(QWidget* parent)
|
||||||
: QDialog(parent),
|
: QWidget(parent),
|
||||||
|
mac_psn_(NULL),
|
||||||
ui_(new Ui_GlobalSearchPopup) {
|
ui_(new Ui_GlobalSearchPopup) {
|
||||||
ui_->setupUi(this);
|
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint;
|
||||||
|
|
||||||
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Popup;
|
|
||||||
setWindowFlags(flags);
|
setWindowFlags(flags);
|
||||||
|
|
||||||
|
ui_->setupUi(this);
|
||||||
|
|
||||||
ui_->previous->setIcon(IconLoader::Load("media-skip-backward"));
|
ui_->previous->setIcon(IconLoader::Load("media-skip-backward"));
|
||||||
ui_->next->setIcon(IconLoader::Load("media-skip-forward"));
|
ui_->next->setIcon(IconLoader::Load("media-skip-forward"));
|
||||||
ui_->play_pause->setIcon(IconLoader::Load("media-playback-start"));
|
ui_->play_pause->setIcon(IconLoader::Load("media-playback-start"));
|
||||||
ui_->stop->setIcon(IconLoader::Load("media-playback-stop"));
|
ui_->stop->setIcon(IconLoader::Load("media-playback-stop"));
|
||||||
|
|
||||||
QShortcut* shortcut = new QShortcut(QKeySequence::Close, this);
|
QShortcut* shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||||
connect(shortcut, SIGNAL(activated()), SLOT(close()));
|
connect(shortcut, SIGNAL(activated()), SLOT(hide()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GlobalSearchPopup::Init(LibraryBackendInterface* library, Player* player) {
|
void GlobalSearchPopup::Init(LibraryBackendInterface* library, Player* player) {
|
||||||
@ -55,3 +57,18 @@ void GlobalSearchPopup::Init(LibraryBackendInterface* library, Player* player) {
|
|||||||
void GlobalSearchPopup::setFocus(Qt::FocusReason reason) {
|
void GlobalSearchPopup::setFocus(Qt::FocusReason reason) {
|
||||||
ui_->search_widget->setFocus(reason);
|
ui_->search_widget->setFocus(reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GlobalSearchPopup::showEvent(QShowEvent* e) {
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
StorePreviousProcess();
|
||||||
|
#endif
|
||||||
|
QWidget::showEvent(e);
|
||||||
|
raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSearchPopup::hide() {
|
||||||
|
#ifdef Q_OS_DARWIN
|
||||||
|
ActivatePreviousProcess();
|
||||||
|
#endif
|
||||||
|
QWidget::hide();
|
||||||
|
}
|
||||||
|
@ -26,8 +26,9 @@
|
|||||||
|
|
||||||
class LibraryBackendInterface;
|
class LibraryBackendInterface;
|
||||||
class Player;
|
class Player;
|
||||||
|
class ProcessSerialNumber;
|
||||||
|
|
||||||
class GlobalSearchPopup : public QDialog {
|
class GlobalSearchPopup : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
explicit GlobalSearchPopup(QWidget* parent = 0);
|
explicit GlobalSearchPopup(QWidget* parent = 0);
|
||||||
@ -37,8 +38,21 @@ class GlobalSearchPopup : public QDialog {
|
|||||||
// QWidget
|
// QWidget
|
||||||
void setFocus(Qt::FocusReason reason = Qt::PopupFocusReason);
|
void setFocus(Qt::FocusReason reason = Qt::PopupFocusReason);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
void showEvent(QShowEvent* e);
|
||||||
|
|
||||||
|
protected slots:
|
||||||
|
void hide();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void StorePreviousProcess();
|
||||||
|
void ActivatePreviousProcess();
|
||||||
|
|
||||||
|
ProcessSerialNumber* mac_psn_;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void AddToPlaylist(QMimeData*);
|
void AddToPlaylist(QMimeData*);
|
||||||
|
void Closed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
boost::scoped_ptr<Ui_GlobalSearchPopup> ui_;
|
boost::scoped_ptr<Ui_GlobalSearchPopup> ui_;
|
||||||
|
14
src/globalsearch/globalsearchpopup.mm
Normal file
14
src/globalsearch/globalsearchpopup.mm
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#include "globalsearchpopup.h"
|
||||||
|
|
||||||
|
#include "ApplicationServices/ApplicationServices.h"
|
||||||
|
|
||||||
|
void GlobalSearchPopup::StorePreviousProcess() {
|
||||||
|
mac_psn_ = new ProcessSerialNumber;
|
||||||
|
GetFrontProcess(mac_psn_);
|
||||||
|
}
|
||||||
|
|
||||||
|
void GlobalSearchPopup::ActivatePreviousProcess() {
|
||||||
|
SetFrontProcess(mac_psn_);
|
||||||
|
delete mac_psn_;
|
||||||
|
mac_psn_ = NULL;
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>GlobalSearchPopup</class>
|
<class>GlobalSearchPopup</class>
|
||||||
<widget class="QDialog" name="GlobalSearchPopup">
|
<widget class="QWidget" name="GlobalSearchPopup">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>446</width>
|
<width>446</width>
|
||||||
<height>253</height>
|
<height>195</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -32,12 +32,6 @@
|
|||||||
<property name="sizeType">
|
<property name="sizeType">
|
||||||
<enum>QSizePolicy::Minimum</enum>
|
<enum>QSizePolicy::Minimum</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="sizeHint" stdset="0">
|
|
||||||
<size>
|
|
||||||
<width>20</width>
|
|
||||||
<height>40</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
</spacer>
|
</spacer>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user