Sayonara Player
PlayerPluginBase.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(PlayerPlugin::Base* plugin);
72 
73  void sig_opened();
74 
75 
76  private slots:
82  void action_triggered(bool checked);
83 
84  private:
85 
89  void set_ui_initialized();
90  void finalize_initialization();
91 
95  virtual void language_changed() final override;
96 
100  virtual void init_ui()=0;
101 
102 
103  protected:
104 
109  bool is_ui_initialized() const;
110  virtual void assign_ui_vars();
111 
112  virtual void retranslate_ui()=0;
113 
114  template<typename T, typename UiClass>
115  void setup_parent(T* widget, UiClass** ui)
116  {
117  if(is_ui_initialized()){
118  return;
119  }
120 
121  *ui = new UiClass();
122  (*ui)->setupUi(widget);
123 
124  assign_ui_vars();
125  finalize_initialization();
126  }
127 
132  void closeEvent(QCloseEvent* e) override;
133 
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: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:35
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:43
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() \nT...
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