Sayonara Player
WidgetTemplate.h
1 /* WidgetTemplate.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 SAYONARAWIDGETTEMPLATE_H
22 #define SAYONARAWIDGETTEMPLATE_H
23 
24 #include "GUI/Utils/GuiClass.h"
25 #include "Utils/Settings/SayonaraClass.h"
26 #include <QShowEvent>
27 #include <QObject>
28 
29 class QWidget;
30 
31 #define combo_current_index_changed_int static_cast<void (QComboBox::*) (int)>(&QComboBox::currentIndexChanged)
32 #define combo_activated_int static_cast<void (QComboBox::*) (int)>(&QComboBox::activated)
33 #define spinbox_value_changed_int static_cast<void (QSpinBox::*) (int)>(&QSpinBox::valueChanged)
34 
35 namespace Gui
36 {
37  class WidgetTemplateParent;
39  public QObject,
40  public SayonaraClass
41  {
42  Q_OBJECT
43 
44  private:
46 
47  public:
48  AbstrWidgetTemplate(QObject* parent, WidgetTemplateParent* wtp);
49  virtual ~AbstrWidgetTemplate();
50 
51  protected:
52  virtual void language_changed();
53  virtual void skin_changed();
54  };
55 
56 
58  public SayonaraClass
59  {
60  friend class AbstrWidgetTemplate;
61 
62  public:
64  virtual ~WidgetTemplateParent();
65 
66  protected:
67  virtual void language_changed();
68  virtual void skin_changed();
69  };
70 
71  template<typename T>
79  public T,
80  protected WidgetTemplateParent
81  {
82  friend class AbstrWidgetTemplate;
83 
84  private:
85  AbstrWidgetTemplate* _awt;
86 
87  public:
88  template<typename... Args>
89  WidgetTemplate(Args&&... args) :
90  T(std::forward<Args>(args)...),
92  {
93  _awt = new AbstrWidgetTemplate(this, this);
94  }
95 
96  virtual ~WidgetTemplate() {}
97 
98  virtual void showEvent(QShowEvent* e) override
99  {
100  language_changed();
101  skin_changed();
102 
103  T::showEvent(e);
104  }
105  };
106 }
107 
108 #endif // SAYONARAWIDGETTEMPLATE_H
Definition: GUI_ControlsBase.h:43
The SayonaraClass class provides access to Settings and notifications.
Definition: SayonaraClass.h:29
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:78
Definition: WidgetTemplate.h:38
Definition: WidgetTemplate.h:57