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 "Utils/Pimpl.h"
26 
27 class QAction;
28 
35 namespace PlayerPlugin
36 {
37  class Handler;
38  class Base :
39  public Gui::Widget
40  {
41  friend class Handler;
42 
43  Q_OBJECT
44 
45  private:
46  PIMPL(Base)
47 
48  public:
49  explicit Base(QWidget *parent=nullptr);
50  virtual ~Base();
51 
52  virtual void skin_changed() override;
53 
54 
55  signals:
62  void sig_action_triggered(bool checked);
63 
68  void sig_reload(PlayerPlugin::Base* plugin);
69 
70  void sig_opened();
71 
72 
73  private slots:
79  void action_triggered(bool checked);
80 
81  private:
82 
86  void set_ui_initialized();
87 
88 
92  virtual void language_changed() final override;
93 
97  virtual void init_ui()=0;
98 
99 
100  protected:
101 
102  virtual void finalize_initialization();
103 
108  bool is_ui_initialized() const;
109  virtual void assign_ui_vars();
110 
111  virtual void retranslate_ui()=0;
112 
113  template<typename T, typename UiClass>
114  void setup_parent(T* widget, UiClass** ui)
115  {
116  if(is_ui_initialized()){
117  return;
118  }
119 
120  *ui = new UiClass();
121  (*ui)->setupUi(widget);
122 
123  assign_ui_vars();
124  finalize_initialization();
125  }
126 
127  void closeEvent(QCloseEvent* e) override;
128  void showEvent(QShowEvent* e) override;
129 
130 
131  public:
132 
137  virtual QAction* get_action() const final;
138 
139 
144  virtual QString get_name() const=0;
145 
150  virtual QString get_display_name() const=0;
151 
152 
156  virtual bool is_title_shown() const;
157 
163  virtual bool has_loading_bar() const;
164  };
165 }
166 
167 Q_DECLARE_INTERFACE(PlayerPlugin::Base, "com.sayonara-player.playerplugin")
168 
169 #endif // PLAYERPLUGIN_H
PlayerPlugin::Base::is_ui_initialized
bool is_ui_initialized() const
Check if ui already was initialized.
PlayerPlugin::Base
Definition: PlayerPluginBase.h:38
PlayerPlugin::Base::has_loading_bar
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...
Gui::Widget
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() \nT...
Definition: Widget.h:37
PlayerPlugin::Handler
Definition: PlayerPluginHandler.h:33
PlayerPlugin::Base::sig_action_triggered
void sig_action_triggered(bool checked)
signal is emitted when the plugin action is triggered also emitted for when closeEvent is fired
PlayerPlugin::Base::get_name
virtual QString get_name() const =0
must be overwritten
PlayerPlugin::Base::get_action
virtual QAction * get_action() const final
needed by the player ui, final
PlayerPlugin
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: GUI_Player.h:41
PlayerPlugin::Base::sig_reload
void sig_reload(PlayerPlugin::Base *plugin)
emitted when reloading is requested, after firing this signal the plugin will be painted new....
PlayerPlugin::Base::is_title_shown
virtual bool is_title_shown() const
indicates if title bar is shown or not
PlayerPlugin::Base::get_display_name
virtual QString get_display_name() const =0
must be overwritten