drumstick  2.0.0
settingsfactory.cpp
Go to the documentation of this file.
1 /*
2  Drumstick Widgets
3  Copyright (C) 2018-2020 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 
27 namespace drumstick { namespace widgets {
28 
33 QString SettingsFactory::s_fileName;
34 
40 void SettingsFactory::setFileName(const QString name)
41 {
42  SettingsFactory::s_fileName = name;
43  QSettings::setDefaultFormat(QSettings::IniFormat);
44 }
45 
50 QSettings*
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.get();
61 }
62 
67 QSettings*
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.
Definition: alsaclient.cpp:68
SettingsFactory class declaration.