better unsaved changes code, only block whitespace in combos
This commit is contained in:
parent
0b63c438dd
commit
7bf07e72c2
5 changed files with 37 additions and 63 deletions
|
@ -210,7 +210,7 @@ signals:
|
||||||
void warpEventDoubleClicked(QString mapName, QString warpNum);
|
void warpEventDoubleClicked(QString mapName, QString warpNum);
|
||||||
void currentMetatilesSelectionChanged();
|
void currentMetatilesSelectionChanged();
|
||||||
void mapRulerStatusChanged(const QString &);
|
void mapRulerStatusChanged(const QString &);
|
||||||
void shouldUpdateWindow();
|
void editedMapData();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITOR_H
|
#endif // EDITOR_H
|
||||||
|
|
|
@ -307,6 +307,7 @@ private:
|
||||||
void checkToolButtons();
|
void checkToolButtons();
|
||||||
void clickToolButtonFromEditMode(QString editMode);
|
void clickToolButtonFromEditMode(QString editMode);
|
||||||
|
|
||||||
|
void markMapEdited();
|
||||||
void showWindowTitle();
|
void showWindowTitle();
|
||||||
|
|
||||||
void initWindow();
|
void initWindow();
|
||||||
|
|
|
@ -1930,8 +1930,7 @@ void Editor::updateCustomMapHeaderValues(QTableWidget *table)
|
||||||
fields[keyStr] = valueStr;
|
fields[keyStr] = valueStr;
|
||||||
}
|
}
|
||||||
map->customHeaders = fields;
|
map->customHeaders = fields;
|
||||||
map->hasUnsavedDataChanges = true;
|
emit editedMapData();
|
||||||
emit shouldUpdateWindow();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tileset* Editor::getCurrentMapPrimaryTileset()
|
Tileset* Editor::getCurrentMapPrimaryTileset()
|
||||||
|
|
|
@ -256,7 +256,7 @@ void MainWindow::initEditor() {
|
||||||
connect(this->editor, &Editor::currentMetatilesSelectionChanged, this, &MainWindow::currentMetatilesSelectionChanged);
|
connect(this->editor, &Editor::currentMetatilesSelectionChanged, this, &MainWindow::currentMetatilesSelectionChanged);
|
||||||
connect(this->editor, &Editor::wildMonDataChanged, this, &MainWindow::onWildMonDataChanged);
|
connect(this->editor, &Editor::wildMonDataChanged, this, &MainWindow::onWildMonDataChanged);
|
||||||
connect(this->editor, &Editor::mapRulerStatusChanged, this, &MainWindow::onMapRulerStatusChanged);
|
connect(this->editor, &Editor::mapRulerStatusChanged, this, &MainWindow::onMapRulerStatusChanged);
|
||||||
connect(this->editor, &Editor::shouldUpdateWindow, this, [=]() { showWindowTitle(); });
|
connect(this->editor, &Editor::editedMapData, this, &MainWindow::markMapEdited);
|
||||||
connect(ui->toolButton_Open_Scripts, &QToolButton::pressed, this->editor, &Editor::openMapScripts);
|
connect(ui->toolButton_Open_Scripts, &QToolButton::pressed, this->editor, &Editor::openMapScripts);
|
||||||
connect(ui->actionOpen_Project_in_Text_Editor, &QAction::triggered, this->editor, &Editor::openProjectInTextEditor);
|
connect(ui->actionOpen_Project_in_Text_Editor, &QAction::triggered, this->editor, &Editor::openProjectInTextEditor);
|
||||||
|
|
||||||
|
@ -340,6 +340,13 @@ void MainWindow::showWindowTitle() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MainWindow::markMapEdited() {
|
||||||
|
if (editor && editor->map) {
|
||||||
|
editor->map->hasUnsavedDataChanges = true;
|
||||||
|
showWindowTitle();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MainWindow::setProjectSpecificUIVisibility()
|
void MainWindow::setProjectSpecificUIVisibility()
|
||||||
{
|
{
|
||||||
ui->actionUse_Encounter_Json->setChecked(projectConfig.getEncounterJsonActive());
|
ui->actionUse_Encounter_Json->setChecked(projectConfig.getEncounterJsonActive());
|
||||||
|
@ -797,8 +804,7 @@ void MainWindow::on_comboBox_Song_currentTextChanged(const QString &song)
|
||||||
{
|
{
|
||||||
if (editor && editor->map) {
|
if (editor && editor->map) {
|
||||||
editor->map->song = song;
|
editor->map->song = song;
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -806,8 +812,7 @@ void MainWindow::on_comboBox_Location_currentTextChanged(const QString &location
|
||||||
{
|
{
|
||||||
if (editor && editor->map) {
|
if (editor && editor->map) {
|
||||||
editor->map->location = location;
|
editor->map->location = location;
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -815,8 +820,7 @@ void MainWindow::on_comboBox_Weather_currentTextChanged(const QString &weather)
|
||||||
{
|
{
|
||||||
if (editor && editor->map) {
|
if (editor && editor->map) {
|
||||||
editor->map->weather = weather;
|
editor->map->weather = weather;
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -824,8 +828,7 @@ void MainWindow::on_comboBox_Type_currentTextChanged(const QString &type)
|
||||||
{
|
{
|
||||||
if (editor && editor->map) {
|
if (editor && editor->map) {
|
||||||
editor->map->type = type;
|
editor->map->type = type;
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -833,8 +836,7 @@ void MainWindow::on_comboBox_BattleScene_currentTextChanged(const QString &battl
|
||||||
{
|
{
|
||||||
if (editor && editor->map) {
|
if (editor && editor->map) {
|
||||||
editor->map->battle_scene = battle_scene;
|
editor->map->battle_scene = battle_scene;
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -846,8 +848,7 @@ void MainWindow::on_checkBox_Visibility_clicked(bool checked)
|
||||||
} else {
|
} else {
|
||||||
editor->map->requiresFlash = "FALSE";
|
editor->map->requiresFlash = "FALSE";
|
||||||
}
|
}
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -859,8 +860,7 @@ void MainWindow::on_checkBox_ShowLocation_clicked(bool checked)
|
||||||
} else {
|
} else {
|
||||||
editor->map->show_location = "FALSE";
|
editor->map->show_location = "FALSE";
|
||||||
}
|
}
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -872,8 +872,7 @@ void MainWindow::on_checkBox_AllowRunning_clicked(bool checked)
|
||||||
} else {
|
} else {
|
||||||
editor->map->allowRunning = "0";
|
editor->map->allowRunning = "0";
|
||||||
}
|
}
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,8 +884,7 @@ void MainWindow::on_checkBox_AllowBiking_clicked(bool checked)
|
||||||
} else {
|
} else {
|
||||||
editor->map->allowBiking = "0";
|
editor->map->allowBiking = "0";
|
||||||
}
|
}
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -898,8 +896,7 @@ void MainWindow::on_checkBox_AllowEscapeRope_clicked(bool checked)
|
||||||
} else {
|
} else {
|
||||||
editor->map->allowEscapeRope = "0";
|
editor->map->allowEscapeRope = "0";
|
||||||
}
|
}
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -907,8 +904,7 @@ void MainWindow::on_spinBox_FloorNumber_valueChanged(int offset)
|
||||||
{
|
{
|
||||||
if (editor && editor->map) {
|
if (editor && editor->map) {
|
||||||
editor->map->floorNumber = offset;
|
editor->map->floorNumber = offset;
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2012,10 +2008,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
frame->ui->comboBox_sprite->addItems(event_obj_gfx_constants.keys());
|
frame->ui->comboBox_sprite->addItems(event_obj_gfx_constants.keys());
|
||||||
frame->ui->comboBox_sprite->setCurrentIndex(frame->ui->comboBox_sprite->findText(item->event->get("sprite")));
|
frame->ui->comboBox_sprite->setCurrentIndex(frame->ui->comboBox_sprite->findText(item->event->get("sprite")));
|
||||||
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, item, &DraggablePixmapItem::set_sprite);
|
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, item, &DraggablePixmapItem::set_sprite);
|
||||||
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, this, [=]() {
|
connect(frame->ui->comboBox_sprite, &QComboBox::currentTextChanged, this, &MainWindow::markMapEdited);
|
||||||
this->editor->map->hasUnsavedDataChanges = true;
|
|
||||||
showWindowTitle();
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
frame->ui->script->setVisible(true);
|
frame->ui->script->setVisible(true);
|
||||||
|
@ -2226,10 +2219,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
item->event->put(key, value);
|
item->event->put(key, value);
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(spin, QOverload<int>::of(&NoScrollSpinBox::valueChanged), this, [=]() {
|
connect(spin, QOverload<int>::of(&NoScrollSpinBox::valueChanged), this, &MainWindow::markMapEdited);
|
||||||
this->editor->map->hasUnsavedDataChanges = true;
|
|
||||||
showWindowTitle();
|
|
||||||
});
|
|
||||||
// Keys using check boxes
|
// Keys using check boxes
|
||||||
} else if (checkKeys.contains(key)) {
|
} else if (checkKeys.contains(key)) {
|
||||||
check->setChecked(value.toInt());
|
check->setChecked(value.toInt());
|
||||||
|
@ -2250,10 +2240,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
connect(check, &QCheckBox::stateChanged, this, [=]() {
|
connect(check, &QCheckBox::stateChanged, this, &MainWindow::markMapEdited);
|
||||||
this->editor->map->hasUnsavedDataChanges = true;
|
|
||||||
showWindowTitle();
|
|
||||||
});
|
|
||||||
// Keys using combo boxes
|
// Keys using combo boxes
|
||||||
} else {
|
} else {
|
||||||
combo->setCurrentText(value);
|
combo->setCurrentText(value);
|
||||||
|
@ -2283,10 +2270,7 @@ void MainWindow::updateSelectedObjects() {
|
||||||
|
|
||||||
item->bind(combo, key);
|
item->bind(combo, key);
|
||||||
|
|
||||||
connect(combo, &QComboBox::currentTextChanged, this, [=]() {
|
connect(combo, &QComboBox::currentTextChanged, this, &MainWindow::markMapEdited);
|
||||||
this->editor->map->hasUnsavedDataChanges = true;
|
|
||||||
showWindowTitle();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
frames.append(frame);
|
frames.append(frame);
|
||||||
|
@ -2710,8 +2694,7 @@ void MainWindow::onTilesetsSaved(QString primaryTilesetLabel, QString secondaryT
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onWildMonDataChanged() {
|
void MainWindow::onWildMonDataChanged() {
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::onMapRulerStatusChanged(const QString &status) {
|
void MainWindow::onMapRulerStatusChanged(const QString &status) {
|
||||||
|
@ -2764,38 +2747,33 @@ void MainWindow::showExportMapImageWindow(ImageExporterMode mode) {
|
||||||
void MainWindow::on_comboBox_ConnectionDirection_currentTextChanged(const QString &direction)
|
void MainWindow::on_comboBox_ConnectionDirection_currentTextChanged(const QString &direction)
|
||||||
{
|
{
|
||||||
editor->updateCurrentConnectionDirection(direction);
|
editor->updateCurrentConnectionDirection(direction);
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_spinBox_ConnectionOffset_valueChanged(int offset)
|
void MainWindow::on_spinBox_ConnectionOffset_valueChanged(int offset)
|
||||||
{
|
{
|
||||||
editor->updateConnectionOffset(offset);
|
editor->updateConnectionOffset(offset);
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_comboBox_ConnectedMap_currentTextChanged(const QString &mapName)
|
void MainWindow::on_comboBox_ConnectedMap_currentTextChanged(const QString &mapName)
|
||||||
{
|
{
|
||||||
if (editor->project->mapNames.contains(mapName)) {
|
if (editor->project->mapNames.contains(mapName)) {
|
||||||
editor->setConnectionMap(mapName);
|
editor->setConnectionMap(mapName);
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_pushButton_AddConnection_clicked()
|
void MainWindow::on_pushButton_AddConnection_clicked()
|
||||||
{
|
{
|
||||||
editor->addNewConnection();
|
editor->addNewConnection();
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_pushButton_RemoveConnection_clicked()
|
void MainWindow::on_pushButton_RemoveConnection_clicked()
|
||||||
{
|
{
|
||||||
editor->removeCurrentConnection();
|
editor->removeCurrentConnection();
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainWindow::on_pushButton_NewWildMonGroup_clicked() {
|
void MainWindow::on_pushButton_NewWildMonGroup_clicked() {
|
||||||
|
@ -2814,8 +2792,7 @@ void MainWindow::on_comboBox_DiveMap_currentTextChanged(const QString &mapName)
|
||||||
{
|
{
|
||||||
if (editor->project->mapNames.contains(mapName)) {
|
if (editor->project->mapNames.contains(mapName)) {
|
||||||
editor->updateDiveMap(mapName);
|
editor->updateDiveMap(mapName);
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2823,8 +2800,7 @@ void MainWindow::on_comboBox_EmergeMap_currentTextChanged(const QString &mapName
|
||||||
{
|
{
|
||||||
if (editor->project->mapNames.contains(mapName)) {
|
if (editor->project->mapNames.contains(mapName)) {
|
||||||
editor->updateEmergeMap(mapName);
|
editor->updateEmergeMap(mapName);
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2835,8 +2811,7 @@ void MainWindow::on_comboBox_PrimaryTileset_currentTextChanged(const QString &ti
|
||||||
redrawMapScene();
|
redrawMapScene();
|
||||||
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
||||||
updateTilesetEditor();
|
updateTilesetEditor();
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2847,8 +2822,7 @@ void MainWindow::on_comboBox_SecondaryTileset_currentTextChanged(const QString &
|
||||||
redrawMapScene();
|
redrawMapScene();
|
||||||
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
on_horizontalSlider_MetatileZoom_valueChanged(ui->horizontalSlider_MetatileZoom->value());
|
||||||
updateTilesetEditor();
|
updateTilesetEditor();
|
||||||
editor->map->hasUnsavedDataChanges = true;
|
markMapEdited();
|
||||||
showWindowTitle();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ NoScrollComboBox::NoScrollComboBox(QWidget *parent)
|
||||||
this->completer()->setCompletionMode(QCompleter::PopupCompletion);
|
this->completer()->setCompletionMode(QCompleter::PopupCompletion);
|
||||||
this->completer()->setFilterMode(Qt::MatchContains);
|
this->completer()->setFilterMode(Qt::MatchContains);
|
||||||
|
|
||||||
QRegularExpression re("[A-Za-z_0-9]+");
|
QRegularExpression re("[^\\s]*");
|
||||||
QValidator *validator = new QRegularExpressionValidator(re);
|
QValidator *validator = new QRegularExpressionValidator(re);
|
||||||
this->setValidator(validator);
|
this->setValidator(validator);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue