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 "Helper/Pimpl.h"
25 
26 #include "GUI/Helper/SayonaraWidget/SayonaraWidget.h"
27 #include "GUI/Helper/Shortcuts/ShortcutWidget.h"
28 
29 class QAction;
31 
39  public SayonaraWidget,
40  public ShortcutWidget
41 {
42  friend class PlayerPluginHandler;
43 
44  Q_OBJECT
45 
46 private:
48 
49 
50 public:
51  explicit PlayerPluginInterface(QWidget *parent=nullptr);
52  virtual ~PlayerPluginInterface();
53 
54 
55 signals:
62  void sig_action_triggered(PlayerPluginInterface* plugin, bool checked);
63 
69 
73  void sig_closed();
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() override=0;
96 
100  virtual void init_ui()=0;
101 
102 
103 protected:
104 
109  bool is_ui_initialized() const;
110 
111 
112  template<typename T, typename UiClass>
113  void setup_parent(T* widget, UiClass** ui){
114  if(is_ui_initialized()){
115  return;
116  }
117 
118  *ui = new UiClass();
119  (*ui)->setupUi(widget);
120 
121  finalize_initialization();
122  }
123 
128  void closeEvent(QCloseEvent* e) override;
129 
130  void showEvent(QShowEvent* e) override;
131 
132 
133 public:
138  virtual QSize get_size() const final;
139 
144  virtual QAction* get_action() const final;
145 
146 
151  virtual QString get_name() const=0;
152 
157  virtual QString get_display_name() const=0;
158 
159 
163  virtual bool is_title_shown() const;
164 
170  virtual bool has_loading_bar() const;
171 
172 
178  QString get_shortcut_text(const QString &shortcut_identifier) const override;
179 };
180 
181 Q_DECLARE_INTERFACE(PlayerPluginInterface, "com.sayonara-player.playerplugin")
182 
183 #endif // PLAYERPLUGIN_H
virtual bool is_title_shown() const
indicates if title bar is shown or not
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_display_name() const =0
must be overwritten
virtual QSize get_size() const final
needed by the player ui, final
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() wi...
Definition: SayonaraWidget.h:36
void sig_action_triggered(PlayerPluginInterface *plugin, bool checked)
signal is emitted when the plugin action is triggered also emitted for when closeEvent is fired ...
QString get_shortcut_text(const QString &shortcut_identifier) const override
get translated text of shortcut (overridden)
virtual QAction * get_action() const final
needed by the player ui, final
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: PlayerPlugin.h:38
void sig_reload(PlayerPluginInterface *)
emitted when reloading is requested, after firing this signal the plugin will be painted new...
virtual QString get_name() const =0
must be overwritten
void closeEvent(QCloseEvent *e) override
Event fired when closed overrides QWidget::closeEvent.
Definition: PlayerPluginHandler.h:32
bool is_ui_initialized() const
Check if ui already was initialized.
void sig_closed()
emitted when plugin is closed
Interface that should be implemented when using configurable shortcuts.
Definition: ShortcutWidget.h:30