cleanup: shortcuts, setLayout

This commit is contained in:
garak 2024-04-18 14:38:15 -04:00
parent 5bb0983c33
commit f46ac36a94
3 changed files with 19 additions and 65 deletions

View file

@ -185,6 +185,7 @@ private slots:
void onLoadMapRequested(QString, QString);
void onMapChanged(Map *map);
void onLayoutChanged(Layout *layout);
void onMapNeedsRedrawing();
void onLayoutNeedsRedrawing();
void onTilesetsSaved(QString, QString);
@ -280,9 +281,9 @@ private slots:
void on_horizontalSlider_CollisionTransparency_valueChanged(int value);
void on_toolButton_HideShow_clicked();
void on_toolButton_ExpandAll_clicked();
void on_toolButton_CollapseAll_clicked();
void do_HideShow();
void do_ExpandAll();
void do_CollapseAll();
void on_toolButton_HideShow_Groups_clicked();
void on_toolButton_ExpandAll_Groups_clicked();
void on_toolButton_CollapseAll_Groups_clicked();

View file

@ -5,51 +5,8 @@
#include "scripting.h"
#include "imageproviders.h"
// QString id;
// QString name;
// int width;
// int height;
// int border_width;
// int border_height;
// QString border_path;
// QString blockdata_path;
// QString tileset_primary_label;
// QString tileset_secondary_label;
// Tileset *tileset_primary = nullptr;
// Tileset *tileset_secondary = nullptr;
// Blockdata blockdata;
// QImage image;
// QPixmap pixmap;
// QImage border_image;
// QPixmap border_pixmap;
// QImage collision_image;
// QPixmap collision_pixmap;
// Blockdata border;
// Blockdata cached_blockdata;
// Blockdata cached_collision;
// Blockdata cached_border;
// struct {
// Blockdata blocks;
// QSize mapDimensions;
// Blockdata border;
// QSize borderDimensions;
// } lastCommitBlocks; // to track map changes
// QList<int> metatileLayerOrder;
// QList<float> metatileLayerOpacity;
// LayoutPixmapItem *layoutItem = nullptr;
// CollisionPixmapItem *collisionItem = nullptr;
// BorderMetatilesPixmapItem *borderItem = nullptr;
// QUndoStack editHistory;
Layout *Layout::copy() {
Layout *layout = new Layout;
layout->copyFrom(this);

View file

@ -162,15 +162,15 @@ void MainWindow::initExtraShortcuts() {
shortcutToggle_Smart_Paths->setObjectName("shortcutToggle_Smart_Paths");
shortcutToggle_Smart_Paths->setWhatsThis("Toggle Smart Paths");
auto *shortcutHide_Show = new Shortcut(QKeySequence(), this, SLOT(on_toolButton_HideShow_clicked()));
auto *shortcutHide_Show = new Shortcut(QKeySequence(), this, SLOT(do_HideShow()));
shortcutHide_Show->setObjectName("shortcutHide_Show");
shortcutHide_Show->setWhatsThis("Map List: Hide/Show Empty Folders");
auto *shortcutExpand_All = new Shortcut(QKeySequence(), this, SLOT(on_toolButton_ExpandAll_clicked()));
auto *shortcutExpand_All = new Shortcut(QKeySequence(), this, SLOT(do_ExpandAll()));
shortcutExpand_All->setObjectName("shortcutExpand_All");
shortcutExpand_All->setWhatsThis("Map List: Expand all folders");
auto *shortcutCollapse_All = new Shortcut(QKeySequence(), this, SLOT(on_toolButton_CollapseAll_clicked()));
auto *shortcutCollapse_All = new Shortcut(QKeySequence(), this, SLOT(do_CollapseAll()));
shortcutCollapse_All->setObjectName("shortcutCollapse_All");
shortcutCollapse_All->setWhatsThis("Map List: Collapse all folders");
@ -847,7 +847,6 @@ bool MainWindow::setMap(QString map_name, bool scroll) {
}
if (editor->map && !editor->map->name.isNull()) {
// !TODO: function to act on current view? or that does all the views
ui->mapList->setExpanded(groupListProxyModel->mapFromSource(mapGroupModel->indexOfMap(map_name)), false);
}
@ -869,12 +868,12 @@ bool MainWindow::setMap(QString map_name, bool scroll) {
showWindowTitle();
connect(editor->map, &Map::mapChanged, this, &MainWindow::onMapChanged);
connect(editor->map, &Map::mapNeedsRedrawing, this, &MainWindow::onMapNeedsRedrawing);
connect(editor->map, &Map::modified, [this](){ this->markMapEdited(); });
connect(editor->map, &Map::mapChanged, this, &MainWindow::onMapChanged, Qt::UniqueConnection);
connect(editor->map, &Map::mapNeedsRedrawing, this, &MainWindow::onMapNeedsRedrawing, Qt::UniqueConnection);
connect(editor->map, &Map::modified, this, &MainWindow::markMapEdited, Qt::UniqueConnection);
connect(editor->layout, &Layout::layoutChanged, [this]() { onMapChanged(nullptr); });
connect(editor->layout, &Layout::needsRedrawing, this, &MainWindow::onLayoutNeedsRedrawing);
connect(editor->layout, &Layout::layoutChanged, this, &MainWindow::onLayoutChanged, Qt::UniqueConnection);
connect(editor->layout, &Layout::needsRedrawing, this, &MainWindow::onLayoutNeedsRedrawing, Qt::UniqueConnection);
setRecentMapConfig(map_name);
updateMapList();
@ -903,9 +902,7 @@ bool MainWindow::setLayout(QString layoutId) {
showWindowTitle();
updateMapList();
// !TODO: make sure these connections are not duplicated / cleared later
connect(editor->layout, &Layout::needsRedrawing, this, &MainWindow::onLayoutNeedsRedrawing, Qt::UniqueConnection);
// connect(editor->map, &Map::modified, [this](){ this->markMapEdited(); });
updateTilesetEditor();
@ -1064,12 +1061,9 @@ void MainWindow::displayMapProperties() {
}
void MainWindow::on_comboBox_LayoutSelector_currentTextChanged(const QString &text) {
//
if (editor && editor->project && editor->map) {
if (editor->project->mapLayouts.contains(text)) {
editor->map->setLayout(editor->project->loadLayout(text));
// !TODO: method to setMapLayout instead of having to do whole setMap thing,
// also edit history and bug fixes
setMap(editor->map->name);
markMapEdited();
}
@ -1834,7 +1828,6 @@ void MainWindow::currentMetatilesSelectionChanged() {
scrollMetatileSelectorToSelection();
}
// !TODO
void MainWindow::on_mapListContainer_currentChanged(int index) {
switch (index) {
case MapListTab::Groups:
@ -1853,7 +1846,6 @@ void MainWindow::on_mapListContainer_currentChanged(int index) {
porymapConfig.setMapSortOrder(this->mapSortOrder);
}
/// !TODO
void MainWindow::on_mapList_activated(const QModelIndex &index) {
QVariant data = index.data(Qt::UserRole);
if (index.data(MapListRoles::TypeRole) == "map_name" && !data.isNull()) {
@ -2844,6 +2836,10 @@ void MainWindow::onMapChanged(Map *) {
updateMapList();
}
void MainWindow::onLayoutChanged(Layout *) {
updateMapList();
}
void MainWindow::onMapNeedsRedrawing() {
redrawMapScene();
}
@ -3172,7 +3168,7 @@ void MainWindow::initTilesetEditor() {
connect(this->tilesetEditor, &TilesetEditor::tilesetsSaved, this, &MainWindow::onTilesetsSaved);
}
void MainWindow::on_toolButton_ExpandAll_clicked() {
void MainWindow::do_ExpandAll() {
switch (ui->mapListContainer->currentIndex()) {
case MapListTab::Groups:
this->on_toolButton_ExpandAll_Groups_clicked();
@ -3186,7 +3182,7 @@ void MainWindow::on_toolButton_ExpandAll_clicked() {
}
}
void MainWindow::on_toolButton_CollapseAll_clicked() {
void MainWindow::do_CollapseAll() {
switch (ui->mapListContainer->currentIndex()) {
case MapListTab::Groups:
this->on_toolButton_CollapseAll_Groups_clicked();
@ -3200,7 +3196,7 @@ void MainWindow::on_toolButton_CollapseAll_clicked() {
}
}
void MainWindow::on_toolButton_HideShow_clicked() {
void MainWindow::do_HideShow() {
switch (ui->mapListContainer->currentIndex()) {
case MapListTab::Groups:
this->on_toolButton_HideShow_Groups_clicked();