Skip to content

Commit

Permalink
statusicon-qt: Set basic tooltip
Browse files Browse the repository at this point in the history
Even though we override the QSystemTrayIcon::event() method,
it is never called by Qt (at least on Linux). And therefore our
custom info popop is not shown. Set a proper tooltip as workaround.
  • Loading branch information
radioactiveman committed Dec 28, 2023
1 parent 9dbbf3f commit ea8da23
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/statusicon-qt/statusicon.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@
#include <QSystemTrayIcon>
#include <QWheelEvent>

class StatusIcon : public GeneralPlugin {
class StatusIcon : public GeneralPlugin
{
public:
static const char about[];
static const char * const defaults[];
Expand All @@ -53,6 +54,8 @@ class StatusIcon : public GeneralPlugin {
bool init ();
void cleanup ();

private:
static void title_changed (void * data, void * user_data);
static void window_closed (void * data, void * user_data);
static void activate (QSystemTrayIcon::ActivationReason);
static void open_files ();
Expand Down Expand Up @@ -188,13 +191,15 @@ bool StatusIcon::init ()
tray->setContextMenu (menu);
tray->show ();

hook_associate ("title change", title_changed, nullptr);
hook_associate ("window close", window_closed, nullptr);

return true;
}

void StatusIcon::cleanup ()
{
hook_dissociate ("title change", title_changed);
hook_dissociate ("window close", window_closed);

/* Prevent accidentally hiding the interface by disabling
Expand All @@ -211,6 +216,12 @@ void StatusIcon::cleanup ()
audqt::cleanup ();
}

void StatusIcon::title_changed (void * data, void * user_data)
{
const char * title = aud_drct_get_title ();
tray->setToolTip (title);
}

void StatusIcon::window_closed (void * data, void * user_data)
{
bool * handled = (bool *) data;
Expand Down

0 comments on commit ea8da23

Please sign in to comment.