Sayonara Player
GUI_TrayIcon.h
1 /* GUI_TrayIcon.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (Lucio Carreras) gleugner
4  *
5  * This file is part of sayonara player
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11 
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16 
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  */
20 
21 #ifndef GUI_TRAYICON_H
22 #define GUI_TRAYICON_H
23 
24 #include "Interfaces/Notification/NotificationHandler.h"
25 #include "Gui/Utils/Widgets/WidgetTemplate.h"
26 #include "Utils/Pimpl.h"
27 
28 #include <QSystemTrayIcon>
29 #include <QMenu>
30 
31 class GUI_TrayIcon;
32 class PlayManager;
33 class QTimer;
34 
36  public Gui::WidgetTemplate<QMenu>
37 {
38  friend class GUI_TrayIcon;
39 
40  Q_OBJECT
41  PIMPL(TrayIconContextMenu)
42 
43  signals:
44  void sigShowClicked();
45  void sigCloseClicked();
46 
47  private:
48  // all here called by GUI_TrayIcon
49  explicit TrayIconContextMenu(PlayManager* playManager, QWidget* parent=nullptr);
50  ~TrayIconContextMenu() override;
51 
52  void setForwardEnabled(bool b);
53  void setDisplayNames();
54 
55  private slots:
56  void playstateChanged(PlayState state);
57  void muteChanged(bool muted);
58 
59  void muteClicked();
60  void currentSongClicked();
61 
62  protected:
63  void languageChanged() override;
64  void skinChanged() override;
65 };
66 
67 
71 class GUI_TrayIcon :
72  public QSystemTrayIcon,
74 {
75  Q_OBJECT
76  PIMPL(GUI_TrayIcon)
77 
78  signals:
83  void sigWheelChanged(int delta);
84  void sigHideClicked();
85  void sigCloseClicked();
86  void sigShowClicked();
87 
88  public:
89  explicit GUI_TrayIcon(PlayManager* playManager, QObject* parent=nullptr);
90  ~GUI_TrayIcon() override;
91 
92  bool event(QEvent* e) override;
93  [[maybe_unused]] void setForwardEnabled(bool b);
94 
95  void notify(const MetaData& md) override;
96  void notify(const QString& title, const QString& message, const QString& image_path) override;
97 
98  QString name() const override;
99  QString displayName() const override;
100 
101  private:
102  void initContextMenu();
103 
104  private slots:
105  void playstateChanged(PlayState state);
106  void showTrayIconChanged();
107 
108  protected:
109  void languageChanged();
110 };
111 
112 #endif
GUI_TrayIcon::notify
void notify(const MetaData &md) override
notify when Metadata has been changed
NotificationInterface
Definition: NotificationInterface.h:31
PlayManager
Global handler for current playback state (Singleton)
Definition: PlayManager.h:36
GUI_TrayIcon::sigWheelChanged
void sigWheelChanged(int delta)
Gui::WidgetTemplate
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings.
Definition: WidgetTemplate.h:87
GUI_TrayIcon::notify
void notify(const QString &title, const QString &message, const QString &image_path) override
show standard notification
GUI_TrayIcon::name
QString name() const override
get name of notification interface
TrayIconContextMenu
Definition: GUI_TrayIcon.h:37
MetaData
The MetaData class.
Definition: MetaData.h:47
GUI_TrayIcon
Definition: GUI_TrayIcon.h:74