Sayonara Player
PlayerPluginBase.h
1 /* PlayerPlugin.h */
2 
3 /* Copyright (C) 2011-2020 Michael Lugmair (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() override;
51 
52  signals:
59  void sigActionTriggered(bool checked);
60 
65  void sigReload(PlayerPlugin::Base* plugin);
66 
67  void sigOpened();
68 
69 
70  private slots:
76  void actionTriggered(bool checked);
77 
78  private:
79 
83  void setUiInitialized();
84 
85 
89  virtual void languageChanged() final override;
90 
94  virtual void initUi()=0;
95 
96 
97  protected:
98 
99  virtual void finalizeInitialization();
100 
105  virtual bool isUiInitialized() const;
106  virtual void assignUiVariables();
107 
108  virtual void skinChanged() override;
109  virtual void retranslate()=0;
110 
111  template<typename T, typename UiClass>
112  void setupParent(T* widget, UiClass** ui)
113  {
114  if(isUiInitialized()){
115  return;
116  }
117 
118  *ui = new UiClass();
119  (*ui)->setupUi(widget);
120 
121  assignUiVariables();
122  finalizeInitialization();
123  }
124 
125  void closeEvent(QCloseEvent* e) override;
126  void showEvent(QShowEvent* e) override;
127 
128 
129  public:
130 
135  virtual QAction* pluginAction() const final;
136 
137 
142  virtual QString name() const=0;
143 
148  virtual QString displayName() const=0;
149 
150 
154  virtual bool hasTitle() const;
155 
161  virtual bool hasLoadingBar() const;
162  };
163 }
164 
165 Q_DECLARE_INTERFACE(PlayerPlugin::Base, "com.sayonara-player.playerplugin")
166 
167 #endif // PLAYERPLUGIN_H
Definition: PlayerPluginBase.h:38
virtual QString name() const =0
must be overwritten
virtual QAction * pluginAction() const final
needed by the player ui, final
void sigReload(PlayerPlugin::Base *plugin)
emitted when reloading is requested, after firing this signal the plugin will be painted new....
void sigActionTriggered(bool checked)
signal is emitted when the plugin action is triggered also emitted for when closeEvent is fired
Definition: PlayerPluginHandler.h:33
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: GUI_Player.h:41
virtual bool isUiInitialized() const
Check if ui already was initialized.
virtual bool hasLoadingBar() const
indicates if the widget has a loading bar. If yes, there will be reserved some extra space at the bot...
virtual QString displayName() const =0
must be overwritten
Widget with Settings connection. Also contains triggers for language_changed() and skin_changed() \nT...
Definition: Widget.h:37
virtual bool hasTitle() const
indicates if title bar is shown or not