numlockmanager/config.h

36 lines
804 B
C
Raw Normal View History

2023-09-01 14:13:41 +00:00
#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