🔧 Added default values for config

main
Isabell Pflug 2 years ago
parent 8515d609c1
commit 48776cbe93

@ -1,6 +1,5 @@
#include "mainwindow.h"
#include <iostream>
#include <QApplication>
#include <QDir>
#include <QSettings>
@ -14,10 +13,6 @@ std::unique_ptr<QSettings> settings;
// sogar auf Android, wenn man wahnsinnig sein sollte!
void initialise_settings() {
QString config_string = QStandardPaths::locate( QStandardPaths::ConfigLocation, "ThinkPink.ini");
if (config_string == "") {
config_string = QDir(QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)).filePath("ThinkPink.ini");
std::cout << "No config file found. Creating default config at " << config_string.toStdString() << std::endl;
}
settings.reset( new QSettings( config_string, QSettings::IniFormat ) );
}

@ -3,17 +3,14 @@
extern std::unique_ptr<QSettings> settings;
void MainWindow::initialiseAbout() {
QCoreApplication::setOrganizationName("Isabell Elise");
QCoreApplication::setOrganizationDomain("https://liberapay.com/isabell-elise/");
QCoreApplication::setApplicationName("ThinkPink");
}
// initialisation functions
void MainWindow::initialiseGameGrid() {
int n_rows = settings->value("size/rows", 9).toInt();
int n_columns = settings->value("size/columns", 9).toInt();
std::cout << "Number of rows: " << n_rows << std::endl;
std::cout << "Number of columns: " << n_columns << std::endl;
qDebug() << "Number of rows: " << n_rows;
qDebug() << "Number of columns: " << n_columns;
qDebug() << "Colors: ";
for (long long i = 0; i < colors.size(); i++) {
qDebug() << colors.value(i);
}
}
void MainWindow::initialiseWindow() {
@ -30,9 +27,12 @@ void MainWindow::initialiseMenuBar() {
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
, n_rows(settings->value("size/rows", 9).toInt())
, n_columns(settings->value("size/columns", 9).toInt())
, colors(settings->value("colors/colors", QStringList() << "0xBD005E" << "0xFFC0CB" << "0xDB7093" << "0xF7A8B8" << "0x660033").toStringList())
{
ui->setupUi(this);
initialiseAbout();
initialiseGameGrid();
initialiseWindow();
initialiseMenuBar();

@ -2,6 +2,9 @@
#define MAINWINDOW_H
#include <iostream>
#include <vector>
#include <QDebug>
#include <QMainWindow>
#include <QSettings>
@ -16,12 +19,15 @@ class MainWindow : public QMainWindow
public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();
void initialiseAbout();
// initialisation functions
void initialiseGameGrid();
void initialiseWindow();
void initialiseMenuBar();
private:
Ui::MainWindow *ui;
const int n_rows;
const int n_columns;
const QStringList colors;
};
#endif // MAINWINDOW_H

Loading…
Cancel
Save