diff --git a/assignments/06/ThinkPink/main.cpp b/assignments/06/ThinkPink/main.cpp index c724fe7..6d3bc64 100644 --- a/assignments/06/ThinkPink/main.cpp +++ b/assignments/06/ThinkPink/main.cpp @@ -6,20 +6,25 @@ #include #include +// dieser unique Pointer ist absolut genial, weil er mir erlaubt, die User-spezifischen Einstellungen zu Farben und Grid-Größe +// an das Mainwindow weiter zu reichen, noch *bevor* das Mainwindow überhaupt initialisiert ist! std::unique_ptr settings; -void find_config() { +// funktioniert komplett plattformunabhängig! +// 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::cout << "No config file found. Creating default config at " << config_string.toStdString() << std::endl; } - settings.reset( new QSettings( ) ); + settings.reset( new QSettings( config_string, QSettings::IniFormat ) ); } int main(int argc, char *argv[]) { + initialise_settings(); QApplication a(argc, argv); MainWindow w; w.show(); diff --git a/assignments/06/ThinkPink/mainwindow.cpp b/assignments/06/ThinkPink/mainwindow.cpp index 4b29d95..55eea55 100644 --- a/assignments/06/ThinkPink/mainwindow.cpp +++ b/assignments/06/ThinkPink/mainwindow.cpp @@ -1,8 +1,8 @@ -#include - #include "mainwindow.h" #include "ui_mainwindow.h" +extern std::unique_ptr settings; + MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) diff --git a/assignments/06/ThinkPink/mainwindow.h b/assignments/06/ThinkPink/mainwindow.h index 4643e32..0cfdaa4 100644 --- a/assignments/06/ThinkPink/mainwindow.h +++ b/assignments/06/ThinkPink/mainwindow.h @@ -2,6 +2,7 @@ #define MAINWINDOW_H #include +#include QT_BEGIN_NAMESPACE namespace Ui { class MainWindow; } diff --git a/assignments/06/ThinkPink/thinkpink.ini b/assignments/06/ThinkPink/thinkpink.ini index 4cd3a2a..2b0e150 100644 --- a/assignments/06/ThinkPink/thinkpink.ini +++ b/assignments/06/ThinkPink/thinkpink.ini @@ -3,5 +3,5 @@ columns = 9 rows = 9 [colors] -colors = 0xBD005E, 0xFFC0CB, 0xDB7093, 0xF7A8B8 +colors = 0xBD005E, 0xFFC0CB, 0xDB7093, 0xF7A8B8, 0x660033 ;, 0xDB7093