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 "Components/PlayManager/PlayState.h"
26 
27 #include "Gui/Utils/Widgets/WidgetTemplate.h"
28 #include "Utils/Pimpl.h"
29 
30 #include <QSystemTrayIcon>
31 #include <QMenu>
32 
33 class GUI_TrayIcon;
34 class QTimer;
35 
37  public Gui::WidgetTemplate<QMenu>
38 {
39  friend class GUI_TrayIcon;
40 
41  Q_OBJECT
42  PIMPL(TrayIconContextMenu)
43 
44  signals:
45  void sigShowClicked();
46  void sigCloseClicked();
47 
48  private:
49  // all here called by GUI_TrayIcon
50  explicit TrayIconContextMenu(QWidget* parent=nullptr);
51  ~TrayIconContextMenu() override;
52 
53  void setForwardEnabled(bool b);
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(QObject* parent=nullptr);
90  ~GUI_TrayIcon() override;
91 
92  bool event(QEvent* e) override;
93  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
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:28
GUI_TrayIcon::notify
void notify(const MetaData &md) override
notify when Metadata has been changed
NotificationInterface
Definition: NotificationInterface.h:30
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:84
GUI_TrayIcon::name
QString name() const override
get name of notification interface
TrayIconContextMenu
Definition: GUI_TrayIcon.h:36
MetaData
The MetaData class.
Definition: MetaData.h:45
GUI_TrayIcon
Definition: GUI_TrayIcon.h:71