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 
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  virtual void finalizeInitialization();
99 
104  virtual bool isUiInitialized() const;
105  virtual void assignUiVariables();
106 
107  virtual void retranslate()=0;
108 
109  template<typename T, typename UiClass>
110  void setupParent(T* widget, UiClass** ui)
111  {
112  if(isUiInitialized()){
113  return;
114  }
115 
116  *ui = new UiClass();
117  (*ui)->setupUi(widget);
118 
119  assignUiVariables();
120  finalizeInitialization();
121  }
122 
123  void closeEvent(QCloseEvent* e) override;
124  void showEvent(QShowEvent* e) override;
125 
126 
127  public:
128 
133  virtual QAction* pluginAction() const final;
134 
135 
140  virtual QString name() const=0;
141 
146  virtual QString displayName() const=0;
147 
148 
152  virtual bool hasTitle() const;
153 
159  virtual bool hasLoadingBar() const;
160  };
161 }
162 
163 Q_DECLARE_INTERFACE(PlayerPlugin::Base, "com.sayonara-player.playerplugin")
164 
165 #endif // PLAYERPLUGIN_H
PlayerPlugin::Base::displayName
virtual QString displayName() const =0
must be overwritten
PlayerPlugin::Base
Definition: PlayerPluginBase.h:40
PlayerPlugin::Base::hasLoadingBar
virtual bool hasLoadingBar() 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:39
PlayerPlugin::Handler
Definition: PlayerPluginHandler.h:35
PlayerPlugin::Base::name
virtual QString name() const =0
must be overwritten
PlayerPlugin::Base::pluginAction
virtual QAction * pluginAction() const final
needed by the player ui, final
PlayerPlugin::Base::sigActionTriggered
void sigActionTriggered(bool checked)
signal is emitted when the plugin action is triggered also emitted for when closeEvent is fired
PlayerPlugin::Base::hasTitle
virtual bool hasTitle() const
indicates if title bar is shown or not
PlayerPlugin::Base::sigReload
void sigReload(PlayerPlugin::Base *plugin)
emitted when reloading is requested, after firing this signal the plugin will be painted new....
PlayerPlugin
Interface for PlayerPlugin classes. get_name() and language_changed() must be overwritten.
Definition: GUI_Player.h:43
PlayerPlugin::Base::isUiInitialized
virtual bool isUiInitialized() const
Check if ui already was initialized.