-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIniFile.cpp
35 lines (29 loc) · 1.36 KB
/
IniFile.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "IniFile.h"
void IniFile::writeToIniFile(const QString& filePath, const QString& styleName, const QString& gameVariant, const QString& pieceStyle, const QString& engineOutput) {
// Create a QSettings object for the INI file
QSettings settings(filePath, QSettings::IniFormat);
// Write values
settings.beginGroup("General");
settings.setValue("StyleName", styleName);
settings.setValue("GameVariant", gameVariant);
settings.setValue("PieceStyle", pieceStyle);
settings.setValue("EngineOutput", engineOutput);
settings.endGroup();
// Sync the changes explicitly (optional)
settings.sync();
}
QStringList IniFile::readFromIniFile(const QString& filePath) {
// Create a QSettings object for the INI file
QSettings settings(filePath, QSettings::IniFormat);
// Read values from the "General" group
settings.beginGroup("General");
const QString styleName = settings.value("StyleName", QApplication::style()->name()).toString();
const QString gameVariant = settings.value("GameVariant", "Chess").toString();
const QString pieceStyle = settings.value("PieceStyle", "European").toString();
const QString engineOutput = settings.value("EngineOutput", "Concise").toString();
settings.endGroup();
// Return values
QStringList result;
result << styleName << gameVariant << pieceStyle << engineOutput;
return result;
}