From 9ba1ad6c935f83ec8dfee154b4658ff0ef52a6fa Mon Sep 17 00:00:00 2001 From: georgemoralis Date: Fri, 3 Mar 2023 18:48:09 +0200 Subject: [PATCH] added basic setting class ( startup code for #6) --- shadPS4/gui/gui_settings.cpp | 8 ++++++++ shadPS4/gui/gui_settings.h | 14 ++++++++++++++ shadPS4/gui/shadps4gui.cpp | 3 ++- shadPS4/gui/shadps4gui.h | 4 +++- shadPS4/main.cpp | 5 ++++- shadPS4/shadPS4.vcxproj | 2 ++ shadPS4/shadPS4.vcxproj.filters | 6 ++++++ 7 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 shadPS4/gui/gui_settings.cpp create mode 100644 shadPS4/gui/gui_settings.h diff --git a/shadPS4/gui/gui_settings.cpp b/shadPS4/gui/gui_settings.cpp new file mode 100644 index 00000000..4baf9373 --- /dev/null +++ b/shadPS4/gui/gui_settings.cpp @@ -0,0 +1,8 @@ +#include "gui_settings.h" + + +gui_settings::gui_settings(QObject* parent) +{ + m_settings.reset(new QSettings("shadps4.ini", QSettings::Format::IniFormat, parent)); +} + diff --git a/shadPS4/gui/gui_settings.h b/shadPS4/gui/gui_settings.h new file mode 100644 index 00000000..9671ce0e --- /dev/null +++ b/shadPS4/gui/gui_settings.h @@ -0,0 +1,14 @@ +#pragma once + +#include + +class gui_settings +{ + +public: + explicit gui_settings(QObject* parent = nullptr); + +private: + std::unique_ptr m_settings; +}; + diff --git a/shadPS4/gui/shadps4gui.cpp b/shadPS4/gui/shadps4gui.cpp index 546080c0..3b2b4214 100644 --- a/shadPS4/gui/shadps4gui.cpp +++ b/shadPS4/gui/shadps4gui.cpp @@ -7,8 +7,9 @@ #include #include -shadps4gui::shadps4gui(QWidget *parent) +shadps4gui::shadps4gui(std::shared_ptr gui_settings, QWidget* parent) : QMainWindow(parent) + , m_gui_settings(std::move(gui_settings)) { ui.setupUi(this); game_list = new GameListViewer(); diff --git a/shadPS4/gui/shadps4gui.h b/shadPS4/gui/shadps4gui.h index bd9d722e..9f65ae78 100644 --- a/shadPS4/gui/shadps4gui.h +++ b/shadPS4/gui/shadps4gui.h @@ -3,13 +3,14 @@ #include #include "ui_shadps4gui.h" #include "GameListViewer.h" +#include "gui_settings.h" class shadps4gui : public QMainWindow { Q_OBJECT public: - shadps4gui(QWidget *parent = nullptr); + shadps4gui(std::shared_ptr gui_settings, QWidget* parent = nullptr); ~shadps4gui(); public slots: @@ -18,4 +19,5 @@ public slots: private: Ui::shadps4guiClass ui; GameListViewer* game_list; + std::shared_ptr m_gui_settings; }; diff --git a/shadPS4/main.cpp b/shadPS4/main.cpp index feb4f413..baaf71a0 100644 --- a/shadPS4/main.cpp +++ b/shadPS4/main.cpp @@ -1,10 +1,13 @@ #include "gui/shadps4gui.h" #include +#include "gui/gui_settings.h" int main(int argc, char* argv[]) { QApplication a(argc, argv); - shadps4gui w; + std::shared_ptr m_gui_settings; + m_gui_settings.reset(new gui_settings()); + shadps4gui w(m_gui_settings,nullptr); w.show(); return a.exec(); } \ No newline at end of file diff --git a/shadPS4/shadPS4.vcxproj b/shadPS4/shadPS4.vcxproj index 199eae81..ccf22e67 100644 --- a/shadPS4/shadPS4.vcxproj +++ b/shadPS4/shadPS4.vcxproj @@ -16,6 +16,7 @@ + @@ -33,6 +34,7 @@ + diff --git a/shadPS4/shadPS4.vcxproj.filters b/shadPS4/shadPS4.vcxproj.filters index 9ca77d91..9b81844f 100644 --- a/shadPS4/shadPS4.vcxproj.filters +++ b/shadPS4/shadPS4.vcxproj.filters @@ -56,6 +56,9 @@ emulator\fileFormat + + gui + @@ -86,5 +89,8 @@ emulator\fileFormat + + gui + \ No newline at end of file