Sayonara Player
PlayerPluginBase.h
1 /* PlayerPlugin.h */
2 
3 /* Copyright (C) 2011-2019 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 "Gui/Utils/Widgets/Widget.h"
25 #include "Gui/Utils/Shortcuts/ShortcutWidget.h"
26 #include "Utils/Pimpl.h"
27 
28 class QAction;
29 
36 namespace PlayerPlugin
37 {
38  class Handler;
39  class Base :
40  public Gui::Widget,
41  public ShortcutWidget
42  {
43  friend class Handler;
44 
45  Q_OBJECT
46 
47  private:
48  PIMPL(Base)
49 
50  public:
51  explicit Base(QWidget *parent=nullptr);
52  virtual ~Base();
53 
54  virtual void skin_changed() override;
55 
56 
57  signals:
64  void sig_action_triggered(bool checked);
65 
70  void sig_reload(PlayerPlugin::Base* plugin);
71 
72  void sig_opened();
73 
74 
75  private slots:
81  void action_triggered(bool checked);
82 
83  private:
84 
88  void set_ui_initialized();
89 
90 
94  virtual void language_changed() final override;
95 
99  virtual void init_ui()=0;
100 
101 
102  protected:
103 
104  virtual void finalize_initialization();
105 
110  bool is_ui_initialized() const;
111  virtual void assign_ui_vars();
112 
113  virtual void retranslate_ui()=0;
114 
115  template<typename T, typename UiClass>
116  void setup_parent(T* widget, UiClass** ui)
117  {
118  if(is_ui_initialized()){
119  return;
120  }
121 
122  *ui = new UiClass();
123  (*ui)->setupUi(widget);
124 
125  assign_ui_vars();
126  finalize_initialization();
127  }
128 
133  void closeEvent(QCloseEvent* e) override;
134  void showEvent(QShowEvent* e) override;
135 
136 
137  public:
138 
143  virtual QAction* get_action() const final;
144 
145 
150  virtual QString get_name() const=0;
151 
156  virtual QString get_display_name() const=0;
157 
158 
162  virtual bool is_title_shown() const;
163 
169  virtual bool has_loading_bar() const;
170  };
171 }
172 
173 Q_DECLARE_INTERFACE(PlayerPlugin::Base, "com.sayonara-player.playerplugin")
174 
175 #endif // PLAYERPLUGIN_H
Definition: PlayerPluginBase.h:39
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:33
void closeEvent(QCloseEvent *e) override
Event fired when closed overrides QWidget::closeEvent.
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: GUI_Player.h:41
virtual QAction * get_action() const final
needed by the player ui, final
void sig_reload(PlayerPlugin::Base *plugin)
emitted when reloading is requested, after firing this signal the plugin will be painted new...
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() wi...
Definition: Widget.h:38
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
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:32
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