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