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 
26 #include "Utils/Settings/SayonaraClass.h"
27 #include "Utils/Settings/SettingNotifier.h"
28 #include "Utils/Settings/SettingKey.h"
29 
30 #include <QShowEvent>
31 
32 class QWidget;
33 
34 #define combo_current_index_changed_int static_cast<void (QComboBox::*) (int)>(&QComboBox::currentIndexChanged)
35 #define combo_activated_int static_cast<void (QComboBox::*) (int)>(&QComboBox::activated)
36 #define spinbox_value_changed_int static_cast<void (QSpinBox::*) (int)>(&QSpinBox::valueChanged)
37 
38 namespace Gui
39 {
40  template<typename T>
48  public T,
49  public SayonaraClass
50  {
51  public:
52 
53  template<typename... Args>
54  WidgetTemplate(Args&&... args) :
55  T(std::forward<Args>(args)...),
57  {
58  Set::listen<Set::Player_Language>(this, &WidgetTemplate<T>::language_changed);
59  Set::listen<Set::Player_Style>(this, &WidgetTemplate<T>::skin_changed);
60  Set::listen<Set::Player_FontName>(this, &WidgetTemplate<T>::skin_changed, false);
61  Set::listen<Set::Player_FontSize>(this, &WidgetTemplate<T>::skin_changed, false);
62  Set::listen<Set::PL_FontSize>(this, &WidgetTemplate<T>::skin_changed, false);
63  Set::listen<Set::Lib_FontSize>(this, &WidgetTemplate<T>::skin_changed, false);
64  Set::listen<Set::Lib_FontBold>(this, &WidgetTemplate<T>::skin_changed, false);
65  Set::listen<Set::Icon_Theme>(this, &WidgetTemplate<T>::skin_changed, false);
66  Set::listen<Set::Icon_ForceInDarkTheme>(this, &WidgetTemplate<T>::skin_changed, false);
67  }
68 
69  virtual ~WidgetTemplate() {}
70 
71  virtual void language_changed() {}
72  virtual void skin_changed() {}
73 
74  virtual void showEvent(QShowEvent* e) override
75  {
76  language_changed();
77  skin_changed();
78 
79  T::showEvent(e);
80  }
81  };
82 }
83 
84 #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:47