🔧 Added default values for config

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

@ -1,6 +1,5 @@
#include "mainwindow.h" #include "mainwindow.h"
#include <iostream>
#include <QApplication> #include <QApplication>
#include <QDir> #include <QDir>
#include <QSettings> #include <QSettings>
@ -14,10 +13,6 @@ std::unique_ptr<QSettings> settings;
// sogar auf Android, wenn man wahnsinnig sein sollte! // sogar auf Android, wenn man wahnsinnig sein sollte!
void initialise_settings() { void initialise_settings() {
QString config_string = QStandardPaths::locate( QStandardPaths::ConfigLocation, "ThinkPink.ini"); 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 ) ); settings.reset( new QSettings( config_string, QSettings::IniFormat ) );
} }

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

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

Loading…
Cancel
Save