Sayonara Player
WidgetTemplate.h
1 /* WidgetTemplate.h */
2 
3 /* Copyright (C) 2011-2019 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 
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  {
41  Q_OBJECT
42 
43  private:
45 
46  public:
47  AbstrWidgetTemplate(QObject* parent, WidgetTemplateParent* wtp);
48  virtual ~AbstrWidgetTemplate();
49 
50  protected:
51  virtual void language_changed();
52  virtual void skin_changed();
53  };
54 
55 
57  {
58  friend class AbstrWidgetTemplate;
59 
60  public:
62  virtual ~WidgetTemplateParent();
63 
64  protected:
65  virtual void language_changed();
66  virtual void skin_changed();
67  };
68 
69  template<typename T>
77  public T,
78  protected WidgetTemplateParent
79  {
80  friend class AbstrWidgetTemplate;
81 
82  private:
83  AbstrWidgetTemplate* _awt;
84 
85  public:
86  template<typename... Args>
87  WidgetTemplate(Args&&... args) :
88  T(std::forward<Args>(args)...),
90  {
91  _awt = new AbstrWidgetTemplate(this, this);
92  }
93 
94  virtual ~WidgetTemplate() {}
95 
96  virtual void showEvent(QShowEvent* e) override
97  {
98  language_changed();
99  skin_changed();
100 
101  T::showEvent(e);
102  }
103  };
104 }
105 
106 #endif // SAYONARAWIDGETTEMPLATE_H
Definition: GUI_ControlsBase.h:43
Template for Sayonara Widgets. This template is responsible for holding a reference to the settings...
Definition: WidgetTemplate.h:76
Definition: WidgetTemplate.h:38
Definition: WidgetTemplate.h:56