Sayonara Player
GUI_TrayIcon.h
1 /* GUI_TrayIcon.h */
2 
3 /* Copyright (C) 2011-2017 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 
34 class QTimer;
35 class QAction;
36 class MetaData;
37 
38 class GUI_TrayIcon;
39 
41  public Gui::WidgetTemplate<QMenu>
42 {
43  friend class GUI_TrayIcon;
44 
45  Q_OBJECT
46  PIMPL(TrayIconContextMenu)
47 
48  signals:
49  void sig_show_clicked();
50  void sig_close_clicked();
51 
52  private:
53  // all here called by GUI_TrayIcon
54  explicit TrayIconContextMenu(QWidget* parent=nullptr);
56 
57  void set_enable_fwd(bool b);
58 
59  protected:
60  void language_changed() override;
61  void skin_changed() override;
62 
63  private slots:
64  void playstate_changed(PlayState state);
65  void mute_changed(bool muted);
66 
67  void mute_clicked();
68  void current_song_clicked();
69 };
70 
71 
75 class GUI_TrayIcon :
76  public QSystemTrayIcon,
78 {
79  Q_OBJECT
80  PIMPL(GUI_TrayIcon)
81 
82 public:
83  explicit GUI_TrayIcon(QObject *parent=nullptr);
84  virtual ~GUI_TrayIcon();
85 
86  bool event ( QEvent * e ) override;
87  void set_enable_fwd(bool b);
88 
89  void notify(const MetaData& md) override;
90  void notify(const QString &title, const QString &message, const QString &image_path) override;
91 
92  QString name() const override;
93  QString display_name() const override;
94 
95 signals:
96 
101  void sig_wheel_changed(int delta);
102  void sig_hide_clicked();
103  void sig_close_clicked();
104  void sig_show_clicked();
105 
106 protected:
107  void language_changed();
108 
109 private slots:
110  void playstate_changed(PlayState state);
111 
112  void s_show_tray_icon_changed();
113 
114 private:
115  void init_context_menu();
116 };
117 
118 #endif
Definition: NotificationInterface.h:30
void notify(const MetaData &md) override
notify when Metadata has been changed
Definition: GUI_TrayIcon.h:75
PlayState
The PlayState enum.
Definition: PlayState.h:28
Definition: GUI_TrayIcon.h:40
The MetaData class.
Definition: MetaData.h:48
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:47
QString name() const override
get name of notification interface
void sig_wheel_changed(int delta)