2019-03-21 23:50:50 +00:00
|
|
|
#include "newtilesetdialog.h"
|
|
|
|
#include "ui_newtilesetdialog.h"
|
|
|
|
#include <QFileDialog>
|
|
|
|
#include "project.h"
|
|
|
|
|
|
|
|
NewTilesetDialog::NewTilesetDialog(Project* project, QWidget *parent) :
|
|
|
|
QDialog(parent),
|
|
|
|
ui(new Ui::NewTilesetDialog)
|
|
|
|
{
|
|
|
|
ui->setupUi(this);
|
|
|
|
this->setFixedSize(this->width(), this->height());
|
|
|
|
this->project = project;
|
|
|
|
//only allow characters valid for a symbol
|
2020-04-20 21:48:19 +01:00
|
|
|
QRegExp expression("[_A-Za-z0-9]+$");
|
2019-03-21 23:50:50 +00:00
|
|
|
QRegExpValidator *validator = new QRegExpValidator(expression);
|
|
|
|
this->ui->nameLineEdit->setValidator(validator);
|
|
|
|
|
|
|
|
connect(this->ui->nameLineEdit, &QLineEdit::textChanged, this, &NewTilesetDialog::NameOrSecondaryChanged);
|
|
|
|
connect(this->ui->typeComboBox, &QComboBox::currentTextChanged, this, &NewTilesetDialog::SecondaryChanged);
|
|
|
|
//connect(this->ui->toolButton, &QToolButton::clicked, this, &NewTilesetDialog::ChangeFilePath);
|
|
|
|
this->SecondaryChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
NewTilesetDialog::~NewTilesetDialog()
|
|
|
|
{
|
|
|
|
delete ui;
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewTilesetDialog::SecondaryChanged(){
|
|
|
|
this->isSecondary = (this->ui->typeComboBox->currentIndex() == 1);
|
|
|
|
NameOrSecondaryChanged();
|
|
|
|
}
|
|
|
|
|
|
|
|
void NewTilesetDialog::NameOrSecondaryChanged() {
|
|
|
|
this->friendlyName = this->ui->nameLineEdit->text();
|
|
|
|
this->fullSymbolName = "gTileset_" + this->friendlyName;
|
|
|
|
this->ui->symbolNameLineEdit->setText(this->fullSymbolName);
|
|
|
|
this->path = QString("/data/tilesets/") + (this->isSecondary ? "secondary/" : "primary/") + this->friendlyName.toLower();
|
|
|
|
this->ui->pathLineEdit->setText(this->path);
|
|
|
|
}
|