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() 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:
142  virtual QSize get_size() const final;
143 
148  virtual QAction* get_action() const final;
149 
150 
155  virtual QString get_name() const=0;
156 
161  virtual QString get_display_name() const=0;
162 
163 
167  virtual bool is_title_shown() const;
168 
174  virtual bool has_loading_bar() const;
175 
176 
182  QString get_shortcut_text(const QString &shortcut_identifier) const override;
183 };
184 
185 Q_DECLARE_INTERFACE(PlayerPluginInterface, "com.sayonara-player.playerplugin")
186 
187 #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