diff --git a/src/settingswindow.cpp b/src/settingswindow.cpp index 6483fa9..91d895a 100644 --- a/src/settingswindow.cpp +++ b/src/settingswindow.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #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?) diff --git a/src/settingswindow.h b/src/settingswindow.h index c30fd10..da5067f 100644 --- a/src/settingswindow.h +++ b/src/settingswindow.h @@ -3,8 +3,10 @@ #include #include #include +#include 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;