36 lines
804 B
C
36 lines
804 B
C
|
#ifndef CONFIG_H
|
||
|
#define CONFIG_H
|
||
|
|
||
|
#include <QFile>
|
||
|
#include <QCoreApplication>
|
||
|
|
||
|
class Config{
|
||
|
public:
|
||
|
Config(){ file->exists() ? load() : setMode(0);}
|
||
|
~Config(){
|
||
|
file->close();
|
||
|
delete file;
|
||
|
}
|
||
|
void setMode(int m) { mode = m; save(); }
|
||
|
int getMode() {return mode;}
|
||
|
|
||
|
private:
|
||
|
int mode = 0;
|
||
|
QFile * file = new QFile(QCoreApplication::applicationDirPath() + "/src/config.ini");
|
||
|
|
||
|
void load(){
|
||
|
file->open(QIODevice::ReadOnly | QIODevice::Text);
|
||
|
mode = file->readAll().toInt();
|
||
|
file->close();
|
||
|
}
|
||
|
|
||
|
void save(){
|
||
|
file->open(QIODevice::WriteOnly | QIODevice::Text);
|
||
|
QString a;
|
||
|
a.setNum(mode);
|
||
|
file->write(a.toUtf8());
|
||
|
file->close();
|
||
|
}
|
||
|
};
|
||
|
#endif // CONFIG_H
|