From e994adb5a73dc4201dcc313abad2376315b2dd12 Mon Sep 17 00:00:00 2001 From: redstrate Date: Mon, 1 Nov 2021 13:14:00 -0400 Subject: [PATCH] Add settings window --- CMakeLists.txt | 3 ++- src/settingswindow.cpp | 21 +++++++++++++++++++++ src/settingswindow.h | 13 +++++++++++++ src/xivlauncher.cpp | 13 +++++++++++++ 4 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 src/settingswindow.cpp create mode 100644 src/settingswindow.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 84dd193..7d84077 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,8 @@ add_executable(xivlauncher src/xivlauncher.cpp src/sapphirelauncher.cpp src/squareboot.cpp - src/squarelauncher.cpp) + src/squarelauncher.cpp + src/settingswindow.cpp) target_link_libraries(xivlauncher Qt6::Core Qt6::Widgets Qt6::Network qt6keychain) diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp new file mode 100644 index 0000000..33ecec0 --- /dev/null +++ b/src/settingswindow.cpp @@ -0,0 +1,21 @@ +#include "settingswindow.h" + +#include +#include +#include + +#include "xivlauncher.h" + +SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window(window), QWidget(parent) { + setWindowTitle("Settings"); + setWindowModality(Qt::WindowModality::ApplicationModal); + + auto layout = new QFormLayout(this); + setLayout(layout); + + auto gameDirectoryButton = new QPushButton("Open Game Directory"); + connect(gameDirectoryButton, &QPushButton::pressed, [this] { + QDesktopServices::openUrl("file://" + this->window.gamePath); + }); + layout->addRow(gameDirectoryButton); +} \ No newline at end of file diff --git a/src/settingswindow.h b/src/settingswindow.h new file mode 100644 index 0000000..75a41c4 --- /dev/null +++ b/src/settingswindow.h @@ -0,0 +1,13 @@ +#pragma once + +#include + +class LauncherWindow; + +class SettingsWindow : public QWidget { +public: + SettingsWindow(LauncherWindow& window, QWidget* parent = nullptr); + +private: + LauncherWindow& window; +}; \ No newline at end of file diff --git a/src/xivlauncher.cpp b/src/xivlauncher.cpp index 8bdefad..004cf9e 100755 --- a/src/xivlauncher.cpp +++ b/src/xivlauncher.cpp @@ -13,11 +13,13 @@ #include #include #include +#include #include "xivlauncher.h" #include "sapphirelauncher.h" #include "squarelauncher.h" #include "squareboot.h" +#include "settingswindow.h" void LauncherWindow::setSSL(QNetworkRequest& request) { QSslConfiguration config; @@ -90,6 +92,9 @@ void LauncherWindow::launch(const LoginAuth auth) { } if (isWine) { + QStringList env = QProcess::systemEnvironment(); + //env << "DXVK_FILTER_DEVICE_NAME=AMD"; + process->setEnvironment(env); process->start(winePath, arguments); } else { process->start(ffxivPath, arguments); @@ -128,6 +133,14 @@ LauncherWindow::LauncherWindow(QWidget* parent) : squareLauncher = new SquareLauncher(*this); squareBoot = new SquareBoot(*this, *squareLauncher); + QMenu* fileMenu = menuBar()->addMenu("File"); + + QAction* settingsAction = fileMenu->addAction("Settings..."); + connect(settingsAction, &QAction::triggered, [=] { + auto window = new SettingsWindow(*this); + window->show(); + }); + const auto savedServerType = settings.value("serverType", 0).toInt(); const auto savedLobbyURL = settings.value("lobbyURL", "127.0.0.1").toString(); const auto shouldRememberUsername = settings.value("rememberUsername", false).toBool();