Sayonara Player
src
Helper
Settings
SettingNotifier.h
1
/* SettingNotifier.h */
2
3
/* Copyright (C) 2011-2016 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
22
23
#ifndef SETTINGNOTIFIER_H
24
#define SETTINGNOTIFIER_H
25
26
#include <QObject>
27
#include "Helper/Settings/AbstrSettingNotifier.h"
28
29
/* Connect a Setting to a private slot in a class that want to be notified
30
whenever the setting changed:
31
32
call: REGISTER_LISTENER(Set::LFM_Active, lfm_active_changed);
33
where lfm_active_changed() is a private Slot in that class;
34
*/
35
36
#define __REGISTER_LISTENER(setting_key, fn) \
37
SettingNotifier<setting_key##_t>* v_##fn = SettingNotifier<setting_key##_t>::getInstance();\
38
connect(v_##fn, SIGNAL(sig_value_changed()), this, SLOT( fn() ))
39
40
#define REGISTER_LISTENER(setting_key, fn) \
41
do { \
42
__REGISTER_LISTENER(setting_key, fn); \
43
fn(); \
44
} while(0)
45
46
#define REGISTER_LISTENER_NO_CALL(setting_key, fn) \
47
do { \
48
__REGISTER_LISTENER(setting_key, fn); \
49
} while(0)
50
51
52
53
54
/* A Setting notifier has to be a singleton */
55
template
<
typename
T >
56
class
SettingNotifier
:
public
AbstrSettingNotifier
{
57
58
private
:
59
SettingNotifier
( QObject* parent=0 ) :
AbstrSettingNotifier
(parent) {}
60
SettingNotifier
(
const
SettingNotifier
& ){}
61
62
public
:
63
virtual
~
SettingNotifier
(){}
64
65
static
SettingNotifier< T >
* getInstance(){
66
static
SettingNotifier< T >
inst;
67
return
&inst;
68
}
69
70
void
val_changed(){
71
emit sig_value_changed();
72
}
73
};
74
75
76
#endif // SETTINGNOTIFIER_H
AbstrSettingNotifier
The AbstrSettingNotifier class The setting notifier emits a sig_value_changed whenever the value of t...
Definition:
AbstrSettingNotifier.h:39
SettingNotifier
Definition:
SettingNotifier.h:56
Generated on Sun Feb 12 2017 00:05:17 for Sayonara Player by
1.8.13