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  void setDisplayNames();
55 
56  private slots:
57  void playstateChanged(PlayState state);
58  void muteChanged(bool muted);
59 
60  void muteClicked();
61  void currentSongClicked();
62 
63  protected:
64  void languageChanged() override;
65  void skinChanged() override;
66 };
67 
68 
72 class GUI_TrayIcon :
73  public QSystemTrayIcon,
75 {
76  Q_OBJECT
77  PIMPL(GUI_TrayIcon)
78 
79  signals:
84  void sigWheelChanged(int delta);
85  void sigHideClicked();
86  void sigCloseClicked();
87  void sigShowClicked();
88 
89  public:
90  explicit GUI_TrayIcon(QObject* parent=nullptr);
91  ~GUI_TrayIcon() override;
92 
93  bool event(QEvent* e) override;
94  [[maybe_unused]] void setForwardEnabled(bool b);
95 
96  void notify(const MetaData& md) override;
97  void notify(const QString& title, const QString& message, const QString& image_path) override;
98 
99  QString name() const override;
100  QString displayName() const override;
101 
102  private:
103  void initContextMenu();
104 
105  private slots:
106  void playstateChanged(PlayState state);
107  void showTrayIconChanged();
108 
109  protected:
110  void languageChanged();
111 };
112 
113 #endif
PlayState
PlayState
The PlayState enum.
Definition: PlayState.h:29
GUI_TrayIcon::notify
void notify(const MetaData &md) override
notify when Metadata has been changed
NotificationInterface
Definition: NotificationInterface.h:31
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:38
MetaData
The MetaData class.
Definition: MetaData.h:47
GUI_TrayIcon
Definition: GUI_TrayIcon.h:75