Add basic prefences window with text editor command field

This commit is contained in:
BigBahss
2020-11-16 07:39:42 -05:00
parent 0a15dfbf4c
commit ea9cfa47e5
7 changed files with 177 additions and 1 deletions

View File

@@ -0,0 +1,42 @@
#include "preferenceeditor.h"
#include "ui_preferenceeditor.h"
#include "config.h"
#include <QAbstractButton>
PreferenceEditor::PreferenceEditor(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::PreferenceEditor)
{
ui->setupUi(this);
setAttribute(Qt::WA_DeleteOnClose);
connect(ui->buttonBox, &QDialogButtonBox::clicked,
this, &PreferenceEditor::dialogButtonClicked);
populateFields();
}
PreferenceEditor::~PreferenceEditor()
{
delete ui;
}
void PreferenceEditor::populateFields() {
ui->lineEdit_TextEditor->setText(porymapConfig.getTextEditorCommand());
}
void PreferenceEditor::saveFields() {
porymapConfig.setTextEditorCommand(ui->lineEdit_TextEditor->text());
}
void PreferenceEditor::dialogButtonClicked(QAbstractButton *button) {
auto buttonRole = ui->buttonBox->buttonRole(button);
if (buttonRole == QDialogButtonBox::AcceptRole) {
saveFields();
close();
} else if (buttonRole == QDialogButtonBox::ApplyRole) {
saveFields();
} else if (buttonRole == QDialogButtonBox::RejectRole) {
close();
}
}