1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-24 13:27:45 +00:00

Add settings window

This commit is contained in:
redstrate 2021-11-01 13:14:00 -04:00
parent 272a26330b
commit e994adb5a7
4 changed files with 49 additions and 1 deletions

View file

@ -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)

21
src/settingswindow.cpp Normal file
View file

@ -0,0 +1,21 @@
#include "settingswindow.h"
#include <QFormLayout>
#include <QPushButton>
#include <QDesktopServices>
#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);
}

13
src/settingswindow.h Normal file
View file

@ -0,0 +1,13 @@
#pragma once
#include <QWidget>
class LauncherWindow;
class SettingsWindow : public QWidget {
public:
SettingsWindow(LauncherWindow& window, QWidget* parent = nullptr);
private:
LauncherWindow& window;
};

View file

@ -13,11 +13,13 @@
#include <QCheckBox>
#include <keychain.h>
#include <QMessageBox>
#include <QMenuBar>
#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();