Validate input lengths on mrpack export
Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
parent
3dccc38f42
commit
37b4f606c8
@ -26,6 +26,7 @@
|
|||||||
#include <QFileSystemModel>
|
#include <QFileSystemModel>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QPushButton>
|
||||||
#include "FastFileIconProvider.h"
|
#include "FastFileIconProvider.h"
|
||||||
#include "FileSystem.h"
|
#include "FileSystem.h"
|
||||||
#include "MMCZip.h"
|
#include "MMCZip.h"
|
||||||
@ -38,6 +39,13 @@ ExportMrPackDialog::ExportMrPackDialog(InstancePtr instance, QWidget* parent)
|
|||||||
ui->name->setText(instance->name());
|
ui->name->setText(instance->name());
|
||||||
ui->summary->setText(instance->notes().split(QRegularExpression("\\r?\\n"))[0]);
|
ui->summary->setText(instance->notes().split(QRegularExpression("\\r?\\n"))[0]);
|
||||||
|
|
||||||
|
// ensure a valid pack is generated
|
||||||
|
// the name and version fields mustn't be empty
|
||||||
|
connect(ui->name, &QLineEdit::textEdited, this, &ExportMrPackDialog::validate);
|
||||||
|
connect(ui->version, &QLineEdit::textEdited, this, &ExportMrPackDialog::validate);
|
||||||
|
// the instance name can technically be empty
|
||||||
|
validate();
|
||||||
|
|
||||||
QFileSystemModel* model = new QFileSystemModel(this);
|
QFileSystemModel* model = new QFileSystemModel(this);
|
||||||
model->setIconProvider(&icons);
|
model->setIconProvider(&icons);
|
||||||
|
|
||||||
@ -107,3 +115,9 @@ void ExportMrPackDialog::done(int result)
|
|||||||
|
|
||||||
QDialog::done(result);
|
QDialog::done(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExportMrPackDialog::validate()
|
||||||
|
{
|
||||||
|
const bool invalid = ui->name->text().isEmpty() || ui->version->text().isEmpty();
|
||||||
|
ui->buttonBox->button(QDialogButtonBox::Ok)->setDisabled(invalid);
|
||||||
|
}
|
||||||
|
@ -35,6 +35,7 @@ class ExportMrPackDialog : public QDialog {
|
|||||||
~ExportMrPackDialog();
|
~ExportMrPackDialog();
|
||||||
|
|
||||||
void done(int result) override;
|
void done(int result) override;
|
||||||
|
void validate();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const InstancePtr instance;
|
const InstancePtr instance;
|
||||||
|
@ -51,7 +51,11 @@
|
|||||||
<widget class="QLineEdit" name="name"/>
|
<widget class="QLineEdit" name="name"/>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
<item row="1" column="1">
|
||||||
<widget class="QLineEdit" name="version"/>
|
<widget class="QLineEdit" name="version">
|
||||||
|
<property name="text">
|
||||||
|
<string>1.0.0</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
Loading…
Reference in New Issue
Block a user