porymap/src/ui/newtilesetdialog.cpp

41 lines
1.5 KiB
C++
Raw Normal View History

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
2021-02-06 00:43:49 +00:00
QRegularExpression expression("[_A-Za-z0-9]+$");
QRegularExpressionValidator *validator = new QRegularExpressionValidator(expression);
2019-03-21 23:50:50 +00:00
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);
2022-10-07 19:29:51 +01:00
this->path = Tileset::getExpectedDir(this->fullSymbolName, this->isSecondary);
2019-03-21 23:50:50 +00:00
this->ui->pathLineEdit->setText(this->path);
}