1
Fork 0
mirror of https://github.com/redstrate/Astra.git synced 2025-04-20 19:57:45 +00:00

Add setting for renaming the profile

This commit is contained in:
redstrate 2021-11-09 12:10:52 -05:00
parent 0961679427
commit 48c4bd10c4
2 changed files with 20 additions and 5 deletions

View file

@ -10,7 +10,6 @@
#include <QMessageBox>
#include <QProcess>
#include <QGridLayout>
#include <QLineEdit>
#include "xivlauncher.h"
@ -25,9 +24,7 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window
profileWidget->addItem("INVALID *DEBUG*");
profileWidget->setCurrentRow(0);
connect(profileWidget, &QListWidget::currentRowChanged, [=]() {
reloadControls();
});
connect(profileWidget, &QListWidget::currentRowChanged, this, &SettingsWindow::reloadControls);
mainLayout->addWidget(profileWidget, 0, 0);
@ -37,6 +34,14 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window
});
mainLayout->addWidget(addProfileButton, 1, 0);
nameEdit = new QLineEdit();
connect(nameEdit, &QLineEdit::editingFinished, [=] {
getCurrentProfile().name = nameEdit->text();
reloadControls();
});
mainLayout->addWidget(nameEdit, 2, 0);
auto gameBox = new QGroupBox("Game Options");
auto gameBoxLayout = new QFormLayout();
gameBox->setLayout(gameBoxLayout);
@ -49,7 +54,7 @@ SettingsWindow::SettingsWindow(LauncherWindow& window, QWidget* parent) : window
gameBoxLayout->addRow("DirectX Version", directXCombo);
connect(directXCombo, &QComboBox::currentIndexChanged, [=](int index) {
this->window.getProfile(profileWidget->currentRow()).useDX9 = directXCombo->currentIndex() == 1;
getCurrentProfile().useDX9 = directXCombo->currentIndex() == 1;
});
auto currentGameDirectory = new QLabel(window.currentProfile().gamePath);
@ -235,11 +240,16 @@ void SettingsWindow::reloadControls() {
profileWidget->setCurrentRow(oldRow);
ProfileSettings& profile = window.getProfile(profileWidget->currentRow());
nameEdit->setText(profile.name);
directXCombo->setCurrentIndex(profile.useDX9 ? 1 : 0);
currentlyReloadingControls = false;
}
ProfileSettings& SettingsWindow::getCurrentProfile() {
return this->window.getProfile(profileWidget->currentRow());
}
void SettingsWindow::openPath(const QString path) {
#if defined(Q_OS_WIN)
// for some reason, windows requires special treatment (what else is new?)

View file

@ -3,8 +3,10 @@
#include <QWidget>
#include <QListWidget>
#include <QComboBox>
#include <QLineEdit>
class LauncherWindow;
struct ProfileSettings;
class SettingsWindow : public QWidget {
public:
@ -15,8 +17,11 @@ public slots:
private:
void openPath(const QString path);
ProfileSettings& getCurrentProfile();
QListWidget* profileWidget = nullptr;
QLineEdit* nameEdit = nullptr;
QComboBox* directXCombo = nullptr;
bool currentlyReloadingControls = false;