2019-01-26 23:22:16 +00:00
|
|
|
#include "ArgumentEditor.hpp"
|
|
|
|
#include "ui_ArgumentEditor.h"
|
2021-03-10 20:13:03 +00:00
|
|
|
//#include "CVarDialog.hpp"
|
2019-01-26 23:22:16 +00:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QInputDialog>
|
|
|
|
#include <QDebug>
|
|
|
|
|
2020-04-15 06:13:11 +00:00
|
|
|
ArgumentEditor::ArgumentEditor(QWidget* parent) : QDialog(parent), m_ui(std::make_unique<Ui::ArgumentEditor>()) {
|
2019-01-26 23:22:16 +00:00
|
|
|
m_ui->setupUi(this);
|
2019-08-28 01:35:51 +00:00
|
|
|
m_model.setStringList(QSettings().value(QStringLiteral("urde_arguments")).toStringList());
|
2019-01-26 23:22:16 +00:00
|
|
|
m_ui->argumentEditor->setModel(&m_model);
|
|
|
|
}
|
|
|
|
|
2019-08-26 00:50:17 +00:00
|
|
|
ArgumentEditor::~ArgumentEditor() = default;
|
2019-01-26 23:22:16 +00:00
|
|
|
|
|
|
|
void ArgumentEditor::on_addButton_clicked() {
|
|
|
|
QInputDialog input(this);
|
|
|
|
int code = input.exec();
|
|
|
|
if (code == DialogCode::Accepted) {
|
|
|
|
QStringList list = m_model.stringList();
|
|
|
|
list << input.textValue();
|
|
|
|
m_model.setStringList(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-15 06:13:11 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-01-26 23:22:16 +00:00
|
|
|
void ArgumentEditor::on_editButton_clicked() {
|
|
|
|
QModelIndex index = m_ui->argumentEditor->currentIndex();
|
2020-04-15 06:13:11 +00:00
|
|
|
if (!index.isValid()) {
|
2019-01-26 23:22:16 +00:00
|
|
|
return;
|
2020-04-15 06:13:11 +00:00
|
|
|
}
|
2019-01-26 23:22:16 +00:00
|
|
|
|
|
|
|
QInputDialog input(this);
|
|
|
|
input.setTextValue(m_model.stringList().value(index.row()));
|
|
|
|
int code = input.exec();
|
|
|
|
if (code == DialogCode::Accepted) {
|
|
|
|
QStringList list = m_model.stringList();
|
|
|
|
list[index.row()] = input.textValue();
|
|
|
|
m_model.setStringList(list);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void ArgumentEditor::on_deleteButton_clicked() {
|
|
|
|
QModelIndex index = m_ui->argumentEditor->currentIndex();
|
2020-04-15 06:13:11 +00:00
|
|
|
if (index.isValid()) {
|
2019-01-26 23:22:16 +00:00
|
|
|
m_model.removeRows(index.row(), 1);
|
2020-04-15 06:13:11 +00:00
|
|
|
}
|
2019-01-26 23:22:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void ArgumentEditor::on_buttonBox_clicked(QAbstractButton* button) {
|
2020-04-15 06:13:11 +00:00
|
|
|
auto* buttonBox = qobject_cast<QDialogButtonBox*>(sender());
|
2019-01-26 23:22:16 +00:00
|
|
|
if (button == buttonBox->button(QDialogButtonBox::Ok)) {
|
2019-08-28 01:35:51 +00:00
|
|
|
QSettings().setValue(QStringLiteral("urde_arguments"), m_model.stringList());
|
2019-01-26 23:22:16 +00:00
|
|
|
accept();
|
|
|
|
} else {
|
|
|
|
reject();
|
|
|
|
}
|
2020-04-15 06:13:11 +00:00
|
|
|
}
|