fix layout undo history
This commit is contained in:
parent
72eb8f873f
commit
f8c7ada585
6 changed files with 49 additions and 6 deletions
|
@ -109,6 +109,8 @@ public:
|
||||||
// QPixmap renderConnection(MapConnection, Layout *);
|
// QPixmap renderConnection(MapConnection, Layout *);
|
||||||
QPixmap renderBorder(bool ignoreCache = false);
|
QPixmap renderBorder(bool ignoreCache = false);
|
||||||
|
|
||||||
|
QPixmap getLayoutItemPixmap();
|
||||||
|
|
||||||
void setLayoutItem(LayoutPixmapItem *item) { layoutItem = item; }
|
void setLayoutItem(LayoutPixmapItem *item) { layoutItem = item; }
|
||||||
void setCollisionItem(CollisionPixmapItem *item) { collisionItem = item; }
|
void setCollisionItem(CollisionPixmapItem *item) { collisionItem = item; }
|
||||||
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
void setBorderItem(BorderMetatilesPixmapItem *item) { borderItem = item; }
|
||||||
|
|
|
@ -34,7 +34,7 @@ class Project : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
Project(QWidget *parent = nullptr);
|
Project(QObject *parent = nullptr);
|
||||||
~Project();
|
~Project();
|
||||||
|
|
||||||
Project(const Project &) = delete;
|
Project(const Project &) = delete;
|
||||||
|
|
|
@ -438,6 +438,10 @@ QPixmap Layout::renderBorder(bool ignoreCache) {
|
||||||
return this->border_pixmap;
|
return this->border_pixmap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QPixmap Layout::getLayoutItemPixmap() {
|
||||||
|
return this->layoutItem ? this->layoutItem->pixmap() : QPixmap();
|
||||||
|
}
|
||||||
|
|
||||||
bool Layout::hasUnsavedChanges() {
|
bool Layout::hasUnsavedChanges() {
|
||||||
return !this->editHistory.isClean();
|
return !this->editHistory.isClean();
|
||||||
}
|
}
|
||||||
|
|
|
@ -100,6 +100,10 @@ void Editor::setEditingMap() {
|
||||||
this->cursorMapTileRect->stopSingleTileMode();
|
this->cursorMapTileRect->stopSingleTileMode();
|
||||||
this->cursorMapTileRect->setActive(true);
|
this->cursorMapTileRect->setActive(true);
|
||||||
|
|
||||||
|
if (this->layout) {
|
||||||
|
this->editGroup.setActiveStack(&this->layout->editHistory);
|
||||||
|
}
|
||||||
|
|
||||||
setMapEditingButtonsEnabled(true);
|
setMapEditingButtonsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,6 +132,10 @@ void Editor::setEditingCollision() {
|
||||||
this->cursorMapTileRect->setSingleTileMode();
|
this->cursorMapTileRect->setSingleTileMode();
|
||||||
this->cursorMapTileRect->setActive(true);
|
this->cursorMapTileRect->setActive(true);
|
||||||
|
|
||||||
|
if (this->layout) {
|
||||||
|
this->editGroup.setActiveStack(&this->layout->editHistory);
|
||||||
|
}
|
||||||
|
|
||||||
setMapEditingButtonsEnabled(true);
|
setMapEditingButtonsEnabled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,6 +160,10 @@ void Editor::setEditingObjects() {
|
||||||
this->cursorMapTileRect->setSingleTileMode();
|
this->cursorMapTileRect->setSingleTileMode();
|
||||||
this->cursorMapTileRect->setActive(false);
|
this->cursorMapTileRect->setActive(false);
|
||||||
|
|
||||||
|
if (this->map) {
|
||||||
|
this->editGroup.setActiveStack(&this->map->editHistory);
|
||||||
|
}
|
||||||
|
|
||||||
setMapEditingButtonsEnabled(false);
|
setMapEditingButtonsEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,6 +196,10 @@ void Editor::setEditingConnections() {
|
||||||
setConnectionsEditable(true);
|
setConnectionsEditable(true);
|
||||||
this->cursorMapTileRect->setSingleTileMode();
|
this->cursorMapTileRect->setSingleTileMode();
|
||||||
this->cursorMapTileRect->setActive(false);
|
this->cursorMapTileRect->setActive(false);
|
||||||
|
|
||||||
|
if (this->map) {
|
||||||
|
this->editGroup.setActiveStack(&this->map->editHistory);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Editor::setEditingEncounters() {
|
void Editor::setEditingEncounters() {
|
||||||
|
@ -1153,6 +1169,8 @@ bool Editor::setLayout(QString layoutId) {
|
||||||
|
|
||||||
// !TODO: editGroup addStack
|
// !TODO: editGroup addStack
|
||||||
|
|
||||||
|
editGroup.addStack(&layout->editHistory);
|
||||||
|
|
||||||
map_ruler->setMapDimensions(QSize(this->layout->getWidth(), this->layout->getHeight()));
|
map_ruler->setMapDimensions(QSize(this->layout->getWidth(), this->layout->getHeight()));
|
||||||
connect(this->layout, &Layout::layoutDimensionsChanged, map_ruler, &MapRuler::setMapDimensions);
|
connect(this->layout, &Layout::layoutDimensionsChanged, map_ruler, &MapRuler::setMapDimensions);
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,14 @@ void MainWindow::initExtraSignals() {
|
||||||
connect(ui->mapList, &QTreeView::customContextMenuRequested,
|
connect(ui->mapList, &QTreeView::customContextMenuRequested,
|
||||||
this, &MainWindow::onOpenMapListContextMenu);
|
this, &MainWindow::onOpenMapListContextMenu);
|
||||||
|
|
||||||
|
ui->areaList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(ui->areaList, &QTreeView::customContextMenuRequested,
|
||||||
|
this, &MainWindow::onOpenMapListContextMenu);
|
||||||
|
|
||||||
|
ui->layoutList->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
|
connect(ui->layoutList, &QTreeView::customContextMenuRequested,
|
||||||
|
this, &MainWindow::onOpenMapListContextMenu);
|
||||||
|
|
||||||
// other signals
|
// other signals
|
||||||
connect(ui->newEventToolButton, &NewEventToolButton::newEventAdded, this, &MainWindow::addNewEvent);
|
connect(ui->newEventToolButton, &NewEventToolButton::newEventAdded, this, &MainWindow::addNewEvent);
|
||||||
connect(ui->tabWidget_EventType, &QTabWidget::currentChanged, this, &MainWindow::eventTabChanged);
|
connect(ui->tabWidget_EventType, &QTabWidget::currentChanged, this, &MainWindow::eventTabChanged);
|
||||||
|
@ -296,7 +304,7 @@ void MainWindow::initEditor() {
|
||||||
ui->menuEdit->addAction(showHistory);
|
ui->menuEdit->addAction(showHistory);
|
||||||
|
|
||||||
// Toggle an asterisk in the window title when the undo state is changed
|
// Toggle an asterisk in the window title when the undo state is changed
|
||||||
connect(&editor->editGroup, &QUndoGroup::cleanChanged, this, &MainWindow::showWindowTitle);
|
connect(&editor->editGroup, &QUndoGroup::indexChanged, this, &MainWindow::showWindowTitle);
|
||||||
|
|
||||||
// selecting objects from the spinners
|
// selecting objects from the spinners
|
||||||
connect(this->ui->spinner_ObjectID, QOverload<int>::of(&QSpinBox::valueChanged), [this](int value) {
|
connect(this->ui->spinner_ObjectID, QOverload<int>::of(&QSpinBox::valueChanged), [this](int value) {
|
||||||
|
@ -378,8 +386,8 @@ void MainWindow::showWindowTitle() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
if (editor && editor->layout) {
|
if (editor && editor->layout) {
|
||||||
// // QPixmap pixmap = editor->layout ? editor->layout->render(true) : QPixmap();
|
//QPixmap pixmap = editor->layout ? editor->layout->render(false) : QPixmap();
|
||||||
QPixmap pixmap = editor->layout ? editor->layout->render(false) : QPixmap();
|
QPixmap pixmap = editor->layout->pixmap;//getLayoutItemPixmap();
|
||||||
if (!pixmap.isNull()) {
|
if (!pixmap.isNull()) {
|
||||||
ui->mainTabBar->setTabIcon(0, QIcon(pixmap.scaled(16, 16)));
|
ui->mainTabBar->setTabIcon(0, QIcon(pixmap.scaled(16, 16)));
|
||||||
} else {
|
} else {
|
||||||
|
@ -549,7 +557,7 @@ bool MainWindow::openProject(QString dir) {
|
||||||
bool already_open = isProjectOpen() && (editor->project->root == dir);
|
bool already_open = isProjectOpen() && (editor->project->root == dir);
|
||||||
if (!already_open) {
|
if (!already_open) {
|
||||||
editor->closeProject();
|
editor->closeProject();
|
||||||
editor->project = new Project(this);
|
editor->project = new Project(editor);
|
||||||
QObject::connect(editor->project, &Project::reloadProject, this, &MainWindow::on_action_Reload_Project_triggered);
|
QObject::connect(editor->project, &Project::reloadProject, this, &MainWindow::on_action_Reload_Project_triggered);
|
||||||
QObject::connect(editor->project, &Project::disableWildEncountersUI, [this]() { this->setWildEncountersUIEnabled(false); });
|
QObject::connect(editor->project, &Project::disableWildEncountersUI, [this]() { this->setWildEncountersUIEnabled(false); });
|
||||||
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() {
|
QObject::connect(editor->project, &Project::uncheckMonitorFilesAction, [this]() {
|
||||||
|
@ -931,6 +939,7 @@ void MainWindow::on_comboBox_LayoutSelector_currentTextChanged(const QString &te
|
||||||
// !TODO: method to setMapLayout instead of having to do whole setMap thing,
|
// !TODO: method to setMapLayout instead of having to do whole setMap thing,
|
||||||
// also edit history and bug fixes
|
// also edit history and bug fixes
|
||||||
setMap(editor->map->name);
|
setMap(editor->map->name);
|
||||||
|
markMapEdited();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1150,6 +1159,16 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) {
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
switch (ui->mapListContainer->currentIndex()) {
|
||||||
|
//
|
||||||
|
case MapListTab::Groups:
|
||||||
|
break;
|
||||||
|
case MapListTab::Areas:
|
||||||
|
break;
|
||||||
|
case MapListTab::Layouts:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
// QStandardItem *selectedItem = mapListModel->itemFromIndex(index);
|
// QStandardItem *selectedItem = mapListModel->itemFromIndex(index);
|
||||||
// QVariant itemType = selectedItem->data(MapListUserRoles::TypeRole);
|
// QVariant itemType = selectedItem->data(MapListUserRoles::TypeRole);
|
||||||
// if (!itemType.isValid()) {
|
// if (!itemType.isValid()) {
|
||||||
|
|
|
@ -35,7 +35,7 @@ int Project::max_map_data_size = 10240; // 0x2800
|
||||||
int Project::default_map_size = 20;
|
int Project::default_map_size = 20;
|
||||||
int Project::max_object_events = 64;
|
int Project::max_object_events = 64;
|
||||||
|
|
||||||
Project::Project(QWidget *parent) :
|
Project::Project(QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
eventScriptLabelModel(this),
|
eventScriptLabelModel(this),
|
||||||
eventScriptLabelCompleter(this)
|
eventScriptLabelCompleter(this)
|
||||||
|
|
Loading…
Reference in a new issue