Skip to content

Commit

Permalink
qtui: Make UI appear on Qt::ApplicationActive for macOS
Browse files Browse the repository at this point in the history
If the status icon plugin is used with close to system tray
the UI main window is closed. On macOS there is not an easy
way to make it reappear. The system tray activation trigger
is disabled on macOS. This is for good reason due to one
button mouse support and that this usually is intended to
open the status/tray menu. Instead we can handle the
application state change activate signal which will fire
when the dock icon is clicked.
  • Loading branch information
jkl1337 authored Nov 22, 2024
1 parent fd4cf41 commit 2f2d537
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/qtui/main_window.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <libaudcore/drct.h>
#include <libaudcore/i18n.h>
#include <libaudcore/interface.h>
#include <libaudcore/plugins.h>
#include <libaudcore/runtime.h>

Expand All @@ -38,6 +39,7 @@
#include <QBoxLayout>
#include <QCloseEvent>
#include <QDockWidget>
#include <QGuiApplication>
#include <QLabel>
#include <QMenuBar>
#include <QSettings>
Expand Down Expand Up @@ -221,6 +223,13 @@ MainWindow::MainWindow()

/* set initial keyboard focus on the playlist */
m_playlist_tabs->currentPlaylistWidget()->setFocus(Qt::OtherFocusReason);

#ifdef Q_OS_MAC
QObject::connect(qGuiApp, &QGuiApplication::applicationStateChanged, this, [](auto state) {
if (state == Qt::ApplicationState::ApplicationActive)
aud_ui_show(true);
});
#endif
}

MainWindow::~MainWindow()
Expand Down

0 comments on commit 2f2d537

Please sign in to comment.