Skip to content

Commit

Permalink
Portable settings
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro-Beirao committed Dec 15, 2023
1 parent 8d01e38 commit 6d9786a
Show file tree
Hide file tree
Showing 6 changed files with 200 additions and 188 deletions.
8 changes: 4 additions & 4 deletions dsda-launcher/demodialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ demodialog::demodialog(QStringList iwad_list, QWidget *parent)
mainLayout->addWidget(files_label, 2, 0, 1, 3);

files_listWidget = new QTableWidget();
int size = settings.beginReadArray("pwadfolders");
int size = settings->beginReadArray("pwadfolders");
if(size!=0)
{
for (int i = 0; i < size; i++)
{
settings.setArrayIndex(i);
QString folder = settings.value("folder").toString();
settings->setArrayIndex(i);
QString folder = settings->value("folder").toString();
if(folder!="")
{
QDir path(folder);
Expand All @@ -52,7 +52,7 @@ demodialog::demodialog(QStringList iwad_list, QWidget *parent)
}
}
}
settings.endArray();
settings->endArray();

QString folder;
#ifdef _WIN32
Expand Down
16 changes: 8 additions & 8 deletions dsda-launcher/historylist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ void historyList::getHistory()
return;
}

QString box1 = settings.value("toggle1t").toString();
QString box2 = settings.value("toggle2t").toString();
QString box3 = settings.value("toggle3t").toString();
QString box4 = settings.value("toggle4t").toString();
QString box1 = settings->value("toggle1t").toString();
QString box2 = settings->value("toggle2t").toString();
QString box3 = settings->value("toggle3t").toString();
QString box4 = settings->value("toggle4t").toString();

std::string buffer;
while (buffer.substr(0,1) != "-" && !file.eof())
Expand Down Expand Up @@ -328,25 +328,25 @@ void historyList::on_launch_pushButton_clicked()
if(buffer.substr(0,5)=="box1=") // box1
{
if(buffer.substr(5)=="true")
argList.append(settings.value("toggle1a").toString());
argList.append(settings->value("toggle1a").toString());
std::getline(file, buffer);
}
if(buffer.substr(0,5)=="box2=") // box2
{
if(buffer.substr(5)=="true")
argList.append(settings.value("toggle2a").toString());
argList.append(settings->value("toggle2a").toString());
std::getline(file, buffer);
}
if(buffer.substr(0,5)=="box3=") // box3
{
if(buffer.substr(5)=="true")
argList.append(settings.value("toggle3a").toString());
argList.append(settings->value("toggle3a").toString());
std::getline(file, buffer);
}
if(buffer.substr(0,5)=="box4=") //box4
{
if(buffer.substr(5)=="true")
argList.append(settings.value("toggle4a").toString());
argList.append(settings->value("toggle4a").toString());
std::getline(file, buffer);
}
std::string fullscreen = "w";
Expand Down
18 changes: 15 additions & 3 deletions dsda-launcher/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,30 @@
#include <QMessageBox>
#include <QDebug>

extern QSettings *settings;

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

// Settings to be stored
QSettings settings("pedrobeirao","dsda-launcher");
settings = new QSettings(QCoreApplication::applicationDirPath() + "/dsda-launcher.ini", QSettings::IniFormat);

QApplication a(argc, argv);
// Check for previous registry settings and copy it to the new one if needed
if (settings->value("version").toString()=="")
{
QSettings prev_reg_settings("pedrobeirao", "dsda-launcher");
Q_FOREACH(QString key, prev_reg_settings.allKeys())
{
settings->setValue(key, prev_reg_settings.value(key));
}
}

MainWindow w;
w.ensurePolished();
w.show();

if(settings.value("version").toString()!=version)
if(settings->value("version").toString()!=version)
{
QMessageBox msgBox;
msgBox.setWindowTitle("dsda-launcher " + version);
Expand Down
Loading

0 comments on commit 6d9786a

Please sign in to comment.