Parent: [652cdc] (diff)

Child: [6835a4] (diff)

Download this file

CSettingsStorage.cpp    94 lines (79 with data), 3.0 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* CSettingsStorage.cpp */
/* Copyright (C) 2011 Lucio Carreras
*
* This file is part of sayonara player
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "HelperStructs/Helper.h"
#include "HelperStructs/PlaylistMode.h"
#include "HelperStructs/CSettingsStorage.h"
#include <QFile>
#include <QDir>
#include <QDebug>
CSettingsStorage* CSettingsStorage::getInstance() {
static CSettingsStorage* inst;
if (inst == 0) {
inst = new CSettingsStorage();
}
return inst;
}
CSettingsStorage::~CSettingsStorage ()
{
//is called
}
#define GENCODE_VARIABLE(NM, TP, CTP) \
static const QString NM##Key(#NM); \
void CSettingsStorage::set##NM(TP val) \
{ \
setValue(NM##Key, val); \
} \
TP CSettingsStorage::get##NM () \
{ \
return value(NM##Key).to##CTP (); \
}
GENCODE_VARIABLE(Version, QString, String)
GENCODE_VARIABLE(Volume, int, Int)
GENCODE_VARIABLE(PlayerSize, QSize, Size)
GENCODE_VARIABLE(PlayerPos, QPoint, Point)
GENCODE_VARIABLE(PlayerFullscreen, bool, Bool)
GENCODE_VARIABLE(PlayerStyle, int, Int)
GENCODE_VARIABLE(ShowNotifications, bool, Bool)
GENCODE_VARIABLE(Notification, QString, String)
GENCODE_VARIABLE(NotificationTimeout, int, Int)
GENCODE_VARIABLE(NotificationScale, int, Int)
GENCODE_VARIABLE(NoShowLibrary, bool, Bool)
GENCODE_VARIABLE(MinimizeToTray, bool, Bool)
GENCODE_VARIABLE(ShowSmallPlaylist, bool, Bool)
GENCODE_VARIABLE(PlaylistNumbers, bool, Bool)
GENCODE_VARIABLE(NotifyNewVersion, bool, Bool)
GENCODE_VARIABLE(PlayerUID, QString, String)
GENCODE_VARIABLE(FolderViewFNOrder, bool, Bool)
GENCODE_VARIABLE(LoadPlaylist, bool, Bool)
GENCODE_VARIABLE(SplitterState, QByteArray, ByteArray)
bool CSettingsStorage::isRunFirstTime ()
{
return value(VersionKey).isNull();
}
// Special cases
static const QString PlaylistModeKey("PlaylistMode");
void CSettingsStorage::setPlaylistMode(const Playlist_Mode& mode)
{
qDebug() << "setPlaylistMode: " << mode.toInt();
setValue(PlaylistModeKey, mode.toInt());
}
Playlist_Mode CSettingsStorage::getPlaylistMode()
{
qDebug() << "getPlaylistMode: " << value(PlaylistModeKey).toInt();
return Playlist_Mode(value(PlaylistModeKey).toInt());
}
// End special cases