Sayonara Player
PlayerPlugin.h
1 /* PlayerPlugin.h */
2 
3 /* Copyright (C) 2011-2017 Lucio Carreras
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 PLAYERPLUGIN_H
22 #define PLAYERPLUGIN_H
23 
24 #include "Utils/Pimpl.h"
25 
26 #include "GUI/Utils/Widgets/Widget.h"
27 #include "GUI/Utils/Shortcuts/ShortcutWidget.h"
28 
29 class QAction;
30 
37 namespace PlayerPlugin
38 {
39  class Handler;
40  class Base :
41  public Gui::Widget,
42  public ShortcutWidget
43  {
44  friend class Handler;
45 
46  Q_OBJECT
47 
48  private:
49  PIMPL(Base)
50 
51  public:
52  explicit Base(QWidget *parent=nullptr);
53  virtual ~Base();
54 
55  virtual void skin_changed() override;
56 
57 
58  signals:
65  void sig_action_triggered(bool checked);
66 
71  void sig_reload(Base*);
72 
76  void sig_closed();
77 
78  void sig_opened();
79 
80 
81  private slots:
87  void action_triggered(bool checked);
88 
89  private:
90 
94  void set_ui_initialized();
95  void finalize_initialization();
96 
100  virtual void language_changed() final override;
101 
105  virtual void init_ui()=0;
106 
107 
108  protected:
109 
114  bool is_ui_initialized() const;
115  virtual void assign_ui_vars();
116 
117  virtual void retranslate_ui()=0;
118 
119  template<typename T, typename UiClass>
120  void setup_parent(T* widget, UiClass** ui)
121  {
122  if(is_ui_initialized()){
123  return;
124  }
125 
126  *ui = new UiClass();
127  (*ui)->setupUi(widget);
128 
129  assign_ui_vars();
130  finalize_initialization();
131  }
132 
137  void closeEvent(QCloseEvent* e) override;
138 
139  void showEvent(QShowEvent* e) override;
140 
141 
142  public:
147  virtual QSize get_size() const final;
148 
153  virtual QAction* get_action() const final;
154 
155 
160  virtual QString get_name() const=0;
161 
166  virtual QString get_display_name() const=0;
167 
168 
172  virtual bool is_title_shown() const;
173 
179  virtual bool has_loading_bar() const;
180 
181 
187  QString get_shortcut_text(const QString &shortcut_identifier) const override;
188  };
189 }
190 
191 Q_DECLARE_INTERFACE(PlayerPlugin::Base, "com.sayonara-player.playerplugin")
192 
193 #endif // PLAYERPLUGIN_H
Definition: PlayerPlugin.h:40
bool is_ui_initialized() const
Check if ui already was initialized.
virtual bool is_title_shown() const
indicates if title bar is shown or not
Definition: PlayerPluginHandler.h:34
void closeEvent(QCloseEvent *e) override
Event fired when closed overrides QWidget::closeEvent.
void sig_reload(Base *)
emitted when reloading is requested, after firing this signal the plugin will be painted new...
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: GUI_Player.h:40
virtual QAction * get_action() const final
needed by the player ui, final
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() wi...
Definition: Widget.h:38
QString get_shortcut_text(const QString &shortcut_identifier) const override
get translated text of shortcut (overridden)
virtual bool has_loading_bar() const
indicates if the widget has a loading bar. If yes, there will be reserved some extra space at the bot...
virtual QString get_name() const =0
must be overwritten
void sig_closed()
emitted when plugin is closed
virtual QSize get_size() const final
needed by the player ui, final
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:30
void sig_action_triggered(bool checked)
signal is emitted when the plugin action is triggered also emitted for when closeEvent is fired ...
virtual QString get_display_name() const =0
must be overwritten