mirror of
https://github.com/redstrate/Astra.git
synced 2025-04-24 05:17:46 +00:00
Add button to create a new profile
This commit is contained in:
parent
6737a363fe
commit
26326d08a7
4 changed files with 46 additions and 3 deletions
|
@ -11,7 +11,6 @@
|
|||
#include <QProcess>
|
||||
#include <QComboBox>
|
||||
#include <QGridLayout>
|
||||
#include <QListWidget>
|
||||
#include <QLineEdit>
|
||||
|
||||
#include "xivlauncher.h"
|
||||
|
@ -23,10 +22,15 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window
|
|||
auto mainLayout = new QGridLayout(this);
|
||||
setLayout(mainLayout);
|
||||
|
||||
auto profileWidget = new QListWidget();
|
||||
profileWidget->addItem("Default");
|
||||
profileWidget = new QListWidget();
|
||||
mainLayout->addWidget(profileWidget, 0, 0);
|
||||
|
||||
auto addProfileButton = new QPushButton("Add Profile");
|
||||
connect(addProfileButton, &QPushButton::pressed, [=] {
|
||||
profileWidget->setCurrentRow(this->window.addProfile());
|
||||
});
|
||||
mainLayout->addWidget(addProfileButton, 1, 0);
|
||||
|
||||
auto gameBox = new QGroupBox("Game Options");
|
||||
auto gameBoxLayout = new QFormLayout();
|
||||
gameBox->setLayout(gameBoxLayout);
|
||||
|
@ -207,6 +211,16 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window
|
|||
this->window.settings.setValue("useGamemode", static_cast<bool>(state));
|
||||
});
|
||||
#endif
|
||||
|
||||
reloadControls();
|
||||
}
|
||||
|
||||
void SettingsWindow::reloadControls() {
|
||||
profileWidget->clear();
|
||||
|
||||
for(auto profile : window.profileList()) {
|
||||
profileWidget->addItem(profile);
|
||||
}
|
||||
}
|
||||
|
||||
void SettingsWindow::openPath(const QString path) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include <QWidget>
|
||||
#include <QListWidget>
|
||||
|
||||
class LauncherWindow;
|
||||
|
||||
|
@ -8,8 +9,13 @@ class SettingsWindow : public QWidget {
|
|||
public:
|
||||
SettingsWindow(LauncherWindow& window, QWidget* parent = nullptr);
|
||||
|
||||
public slots:
|
||||
void reloadControls();
|
||||
|
||||
private:
|
||||
void openPath(const QString path);
|
||||
|
||||
QListWidget* profileWidget;
|
||||
|
||||
LauncherWindow& window;
|
||||
};
|
|
@ -214,6 +214,7 @@ LauncherWindow::LauncherWindow(QWidget* parent) :
|
|||
QAction* settingsAction = fileMenu->addAction("Settings...");
|
||||
connect(settingsAction, &QAction::triggered, [=] {
|
||||
auto window = new SettingsWindow(*this);
|
||||
connect(this, &LauncherWindow::settingsChanged, window, &SettingsWindow::reloadControls);
|
||||
window->show();
|
||||
});
|
||||
|
||||
|
@ -352,6 +353,12 @@ ProfileSettings& LauncherWindow::currentProfile() {
|
|||
|
||||
void LauncherWindow::setProfile(QString name) {
|
||||
currentProfileIndex = getProfileIndex(name);
|
||||
settingsChanged();
|
||||
}
|
||||
|
||||
void LauncherWindow::setProfile(int index) {
|
||||
currentProfileIndex = index;
|
||||
settingsChanged();
|
||||
}
|
||||
|
||||
int LauncherWindow::getProfileIndex(QString name) {
|
||||
|
@ -371,3 +378,14 @@ QList<QString> LauncherWindow::profileList() const {
|
|||
|
||||
return list;
|
||||
}
|
||||
|
||||
int LauncherWindow::addProfile() {
|
||||
ProfileSettings newProfile;
|
||||
newProfile.name = "New Profile";
|
||||
|
||||
profileSettings.append(newProfile);
|
||||
|
||||
settingsChanged();
|
||||
|
||||
return profileSettings.size() - 1;
|
||||
}
|
|
@ -49,8 +49,10 @@ public:
|
|||
ProfileSettings currentProfile() const;
|
||||
ProfileSettings& currentProfile();
|
||||
void setProfile(QString name);
|
||||
void setProfile(int index);
|
||||
int getProfileIndex(QString name);
|
||||
QList<QString> profileList() const;
|
||||
int addProfile();
|
||||
|
||||
void launchGame(const LoginAuth auth);
|
||||
void launchExecutable(const QStringList args);
|
||||
|
@ -61,6 +63,9 @@ public:
|
|||
|
||||
QSettings settings;
|
||||
|
||||
signals:
|
||||
void settingsChanged();
|
||||
|
||||
private:
|
||||
SapphireLauncher* sapphireLauncher;
|
||||
SquareBoot* squareBoot;
|
||||
|
|
Loading…
Add table
Reference in a new issue