mirror of
https://github.com/clementine-player/Clementine
synced 2025-02-01 11:56:45 +01:00
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 SOURCES core/macglobalshortcutbackend.mm)
|
||||
list(APPEND SOURCES devices/macdevicelister.mm)
|
||||
list(APPEND SOURCES globalsearch/globalsearchpopup.mm)
|
||||
list(APPEND SOURCES ui/globalshortcutgrabber.mm)
|
||||
list(APPEND SOURCES ui/macscreensaver.cpp)
|
||||
list(APPEND SOURCES ui/macsystemtrayicon.mm)
|
||||
|
@ -19,24 +19,26 @@
|
||||
|
||||
#include <QShortcut>
|
||||
|
||||
#include "core/logging.h"
|
||||
#include "core/player.h"
|
||||
#include "ui/iconloader.h"
|
||||
|
||||
GlobalSearchPopup::GlobalSearchPopup(QWidget* parent)
|
||||
: QDialog(parent),
|
||||
: QWidget(parent),
|
||||
mac_psn_(NULL),
|
||||
ui_(new Ui_GlobalSearchPopup) {
|
||||
ui_->setupUi(this);
|
||||
|
||||
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Popup;
|
||||
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint;
|
||||
setWindowFlags(flags);
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
||||
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()));
|
||||
QShortcut* shortcut = new QShortcut(QKeySequence(Qt::Key_Escape), this);
|
||||
connect(shortcut, SIGNAL(activated()), SLOT(hide()));
|
||||
}
|
||||
|
||||
void GlobalSearchPopup::Init(LibraryBackendInterface* library, Player* player) {
|
||||
@ -55,3 +57,18 @@ void GlobalSearchPopup::Init(LibraryBackendInterface* library, Player* player) {
|
||||
void GlobalSearchPopup::setFocus(Qt::FocusReason 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 Player;
|
||||
class ProcessSerialNumber;
|
||||
|
||||
class GlobalSearchPopup : public QDialog {
|
||||
class GlobalSearchPopup : public QWidget {
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GlobalSearchPopup(QWidget* parent = 0);
|
||||
@ -37,8 +38,21 @@ class GlobalSearchPopup : public QDialog {
|
||||
// QWidget
|
||||
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:
|
||||
void AddToPlaylist(QMimeData*);
|
||||
void Closed();
|
||||
|
||||
private:
|
||||
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"?>
|
||||
<ui version="4.0">
|
||||
<class>GlobalSearchPopup</class>
|
||||
<widget class="QDialog" name="GlobalSearchPopup">
|
||||
<widget class="QWidget" name="GlobalSearchPopup">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>446</width>
|
||||
<height>253</height>
|
||||
<height>195</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -32,12 +32,6 @@
|
||||
<property name="sizeType">
|
||||
<enum>QSizePolicy::Minimum</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
|
Loading…
x
Reference in New Issue
Block a user