4 #ifndef CM_PREFERENCES_H
5 #define CM_PREFERENCES_H
15 #include <QStandardPaths>
17 #define PREF_QSTRING(x) tilde::Preferences::inst().getQString(x)
20 #define TILDE_APP_VERSION "0.1"
21 #define TILDE_PREF_INIT tilde::Preferences::inst().init()
35 std::map<std::string, QString> _data;
42 Preferences(Preferences
const&) =
delete;
43 void operator=(Preferences
const&) =
delete;
49 return get(key)->asQString();
72 set(
"Paths", (QString)
"");
74 QStringList
paths =
get(
"Paths")->asQStringList();
78 paths.append(newPath);
88 ret =
get(
"Paths")->asQStringList();
94 QFile textFile(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).at(0) +
"/tilde~/Settings/Preferences.txt");
96 if (!textFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
97 qDebug() << textFile.errorString();
100 QStringList prefList;
102 QTextStream textStream(&textFile);
104 QString line = textStream.readLine();
108 prefList.append(line);
111 if (prefList.size() > 0)
119 QFile textFile(QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation).at(0) +
"/tilde~/Settings/Preferences.txt");
121 if (!textFile.open(QIODevice::WriteOnly)) {
123 qDebug() << textFile.errorString();
126 QStringList prefList;
130 textFile.open(QIODevice::WriteOnly | QIODevice::Text);
131 QTextStream logStream(&textFile);
132 for (
int i = 0; i < prefList.size(); i++) {
133 logStream << prefList.at(i) <<
"\n";
141 #endif // CM_PREFERENCES_H
app Preferences singleton
Definition: Preferences.h:26
void create(string pName, string pGroup, QString pVersion, T defaultData)
Definition: PropertyList.h:48
void readFromTextFile()
Definition: Preferences.h:92
#define TILDE_APP_VERSION
Definition: Preferences.h:20
QString extractFromPdFileString(QString input)
extract properties from string in pd file
Definition: PropertyList.cpp:99
string asPdFileString()
returns string for saving in file
Definition: PropertyList.cpp:43
void init()
Definition: Preferences.h:56
QString getQString(QString key)
Definition: Preferences.h:46
static Preferences & inst()
Definition: Preferences.h:28
Property handling class for ui object - property list.
Definition: PropertyList.h:34
OOPD * instance
Definition: OOPD.cpp:20
void operator=(Preferences const &)=delete
QStringList paths()
Definition: Preferences.h:82
void saveToTextFile()
Definition: Preferences.h:117
void addPath(QString newPath)
Definition: Preferences.h:69
void set(string pName, U value)
Definition: PropertyList.h:70