mirror of
https://github.com/AxioDL/metaforce.git
synced 2025-12-12 20:46:09 +00:00
Initial Options tab, CVar dialog
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
#include "ArgumentEditor.hpp"
|
||||
#include "ui_ArgumentEditor.h"
|
||||
#include "CVarDialog.hpp"
|
||||
#include <QSettings>
|
||||
#include <QInputDialog>
|
||||
#include <QDebug>
|
||||
|
||||
ArgumentEditor::ArgumentEditor(QWidget* parent)
|
||||
: QDialog(parent)
|
||||
, m_ui(std::make_unique<Ui::ArgumentEditor>()) {
|
||||
ArgumentEditor::ArgumentEditor(QWidget* parent) : QDialog(parent), m_ui(std::make_unique<Ui::ArgumentEditor>()) {
|
||||
m_ui->setupUi(this);
|
||||
m_model.setStringList(QSettings().value(QStringLiteral("urde_arguments")).toStringList());
|
||||
m_ui->argumentEditor->setModel(&m_model);
|
||||
@@ -24,10 +23,21 @@ void ArgumentEditor::on_addButton_clicked() {
|
||||
}
|
||||
}
|
||||
|
||||
void ArgumentEditor::on_addCvarButton_clicked() {
|
||||
CVarDialog input(this);
|
||||
int code = input.exec();
|
||||
if (code == DialogCode::Accepted) {
|
||||
QStringList list = m_model.stringList();
|
||||
list << input.textValue();
|
||||
m_model.setStringList(list);
|
||||
}
|
||||
}
|
||||
|
||||
void ArgumentEditor::on_editButton_clicked() {
|
||||
QModelIndex index = m_ui->argumentEditor->currentIndex();
|
||||
if (!index.isValid())
|
||||
if (!index.isValid()) {
|
||||
return;
|
||||
}
|
||||
|
||||
QInputDialog input(this);
|
||||
input.setTextValue(m_model.stringList().value(index.row()));
|
||||
@@ -41,16 +51,17 @@ void ArgumentEditor::on_editButton_clicked() {
|
||||
|
||||
void ArgumentEditor::on_deleteButton_clicked() {
|
||||
QModelIndex index = m_ui->argumentEditor->currentIndex();
|
||||
if (index.isValid())
|
||||
if (index.isValid()) {
|
||||
m_model.removeRows(index.row(), 1);
|
||||
}
|
||||
}
|
||||
|
||||
void ArgumentEditor::on_buttonBox_clicked(QAbstractButton* button) {
|
||||
QDialogButtonBox* buttonBox = qobject_cast<QDialogButtonBox*>(sender());
|
||||
auto* buttonBox = qobject_cast<QDialogButtonBox*>(sender());
|
||||
if (button == buttonBox->button(QDialogButtonBox::Ok)) {
|
||||
QSettings().setValue(QStringLiteral("urde_arguments"), m_model.stringList());
|
||||
accept();
|
||||
} else {
|
||||
reject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user