Skip to content

Commit

Permalink
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 should handle the
application state change activate signal which will fire when the dock
icon is clicked (it abstracts app delegate
applicationShouldHandleReopen).

This was originally fixed with
audacious-media-player/audacious-plugins#174 but it is cleaner to
decouple from any one window/skin implementation via connecting
aud_ui_show to the QApplication directly.
  • Loading branch information
jkl1337 committed Nov 22, 2024
1 parent ba31914 commit e174b5b
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/libaudqt/audqt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#include <libaudcore/audstrings.h>
#include <libaudcore/i18n.h>
#include <libaudcore/interface.h>
#include <libaudcore/runtime.h>

#include "libaudqt-internal.h"
Expand Down Expand Up @@ -181,10 +182,17 @@ EXPORT void init()
// to use 9 pt in most places so let's try to do the same.
QApplication::setFont(QApplication::font("QMenu"));
#endif
#ifdef Q_OS_MAC // Mac-specific font tweaks
#ifdef Q_OS_MAC
// Mac-specific font tweaks
QApplication::setFont(QApplication::font("QSmallFont"), "QDialog");
QApplication::setFont(QApplication::font("QSmallFont"), "QTreeView");
QApplication::setFont(QApplication::font("QTipLabel"), "QStatusBar");

// Handle MacOS dock activation (AppKit applicationShouldHandleReopen)
QObject::connect(qapp, &QApplication::applicationStateChanged, [](auto state) {
if (state == Qt::ApplicationState::ApplicationActive)
aud_ui_show(true);
});
#endif
}

Expand Down

0 comments on commit e174b5b

Please sign in to comment.