drumstick 2.8.0
C++ MIDI libraries using Qt objects, idioms, and style.
settingsfactory.cpp
Go to the documentation of this file.
1/*
2 Drumstick Widgets
3 Copyright (C) 2018-2023 Pedro Lopez-Cabanillas <plcl@users.sf.net>
4
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17*/
18
19#include <QFileInfo>
21
27namespace drumstick { namespace widgets {
28
33QString SettingsFactory::s_fileName;
34
40void SettingsFactory::setFileName(const QString name)
41{
42 SettingsFactory::s_fileName = name;
43 QSettings::setDefaultFormat(QSettings::IniFormat);
44}
45
52{
53 if (m_settings.isNull()) {
54 if (s_fileName.isEmpty() || QSettings::defaultFormat() == QSettings::NativeFormat) {
55 m_settings.reset(new QSettings());
56 } else {
57 m_settings.reset(new QSettings(s_fileName, QSettings::IniFormat));
58 }
59 }
60 return m_settings.data();
61}
62
69{
70 return getQSettings();
71}
72
73} // namespace widgets
74} // namespace drumstick
The QSettings class provides persistent platform-independent application settings.
static void setFileName(const QString name)
SettingsFactory::setFileName sets the global file name for the persisting settings and sets the INI f...
QSettings * getQSettings()
SettingsFactory::getQSettings creates and/or returns a QSettings object pointer.
QSettings * operator->()
SettingsFactory::operator -> is equivalent to calling getQSettings()
Drumstick common.
SettingsFactory class declaration.