diff --git a/forms/mainwindow.ui b/forms/mainwindow.ui index 7f85664d..40cb2c3f 100644 --- a/forms/mainwindow.ui +++ b/forms/mainwindow.ui @@ -2373,7 +2373,7 @@ Tileset Editor - + true @@ -2382,7 +2382,7 @@ :/icons/sort_alphabet.ico:/icons/sort_alphabet.ico - Sort by &Name + Sort by &Area diff --git a/include/mainwindow.h b/include/mainwindow.h index 7e295e19..62582552 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -168,6 +168,7 @@ private: void displayMapProperties(); void checkToolButtons(); + void initCustomUI(); void initExtraShortcuts(); void initExtraSignals(); void initEditor(); diff --git a/include/core/filterchildrenproxymodel.h b/include/ui/filterchildrenproxymodel.h similarity index 100% rename from include/core/filterchildrenproxymodel.h rename to include/ui/filterchildrenproxymodel.h diff --git a/porymap.pro b/porymap.pro index e96e2f40..4fac7ee0 100644 --- a/porymap.pro +++ b/porymap.pro @@ -17,7 +17,6 @@ ICON = resources/icons/porymap-icon-1.ico SOURCES += src/core/block.cpp \ src/core/blockdata.cpp \ src/core/event.cpp \ - src/core/filterchildrenproxymodel.cpp \ src/core/heallocation.cpp \ src/core/historyitem.cpp \ src/core/map.cpp \ @@ -31,6 +30,7 @@ SOURCES += src/core/block.cpp \ src/ui/connectionpixmapitem.cpp \ src/ui/currentselectedmetatilespixmapitem.cpp \ src/ui/eventpropertiesframe.cpp \ + src/ui/filterchildrenproxymodel.cpp \ src/ui/graphicsview.cpp \ src/ui/imageproviders.cpp \ src/ui/mappixmapitem.cpp \ @@ -55,7 +55,6 @@ SOURCES += src/core/block.cpp \ HEADERS += include/core/block.h \ include/core/blockdata.h \ include/core/event.h \ - include/core/filterchildrenproxymodel.h \ include/core/heallocation.h \ include/core/history.h \ include/core/historyitem.h \ @@ -71,6 +70,7 @@ HEADERS += include/core/block.h \ include/ui/connectionpixmapitem.h \ include/ui/currentselectedmetatilespixmapitem.h \ include/ui/eventpropertiesframe.h \ + include/ui/filterchildrenproxymodel.h \ include/ui/graphicsview.h \ include/ui/imageproviders.h \ include/ui/mappixmapitem.h \ diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8ffbeb48..bd9899a9 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -36,6 +36,7 @@ MainWindow::MainWindow(QWidget *parent) : QApplication::setWindowIcon(QIcon(":/icons/porymap-icon-1.ico")); ui->setupUi(this); + this->initCustomUI(); this->initExtraSignals(); this->initExtraShortcuts(); this->initEditor(); @@ -57,6 +58,13 @@ void MainWindow::initExtraShortcuts() { ui->actionZoom_In->setShortcuts({QKeySequence("Ctrl++"), QKeySequence("Ctrl+=")}); } +void MainWindow::initCustomUI() { + // Right-clicking on items in the map list tree view brings up a context menu. + ui->mapList->setContextMenuPolicy(Qt::CustomContextMenu); + connect(ui->mapList, SIGNAL(customContextMenuRequested(const QPoint &)), + this, SLOT(onOpenMapListContextMenu(const QPoint &))); +} + void MainWindow::initExtraSignals() { connect(ui->newEventToolButton, SIGNAL(newEventAdded(QString)), this, SLOT(addNewEvent(QString))); } @@ -96,12 +104,12 @@ void MainWindow::initMapSortOrder() { QActionGroup *mapSortOrderActionGroup = new QActionGroup(ui->toolButton_MapSortOrder); mapSortOrderMenu->addAction(ui->actionSort_by_Group); - mapSortOrderMenu->addAction(ui->actionSort_by_Name); + mapSortOrderMenu->addAction(ui->actionSort_by_Area); mapSortOrderMenu->addAction(ui->actionSort_by_Layout); ui->toolButton_MapSortOrder->setMenu(mapSortOrderMenu); mapSortOrderActionGroup->addAction(ui->actionSort_by_Group); - mapSortOrderActionGroup->addAction(ui->actionSort_by_Name); + mapSortOrderActionGroup->addAction(ui->actionSort_by_Area); mapSortOrderActionGroup->addAction(ui->actionSort_by_Layout); connect(ui->toolButton_MapSortOrder, &QToolButton::triggered, this, &MainWindow::mapSortOrder_changed); @@ -119,7 +127,7 @@ void MainWindow::mapSortOrder_changed(QAction *action) int i = 0; for (; i < items.count(); i++) { - if(items[i] == action) + if (items[i] == action) { break; } @@ -602,11 +610,6 @@ void MainWindow::sortMapList() { } } - // Right-clicking on items in the map list tree view brings up a context menu. - ui->mapList->setContextMenuPolicy(Qt::CustomContextMenu); - connect(ui->mapList, SIGNAL(customContextMenuRequested(const QPoint &)), - this, SLOT(onOpenMapListContextMenu(const QPoint &))); - ui->mapList->setUpdatesEnabled(true); ui->mapList->expandToDepth(0); ui->mapList->repaint(); @@ -639,7 +642,7 @@ void MainWindow::onOpenMapListContextMenu(const QPoint &point) if (itemType == "map_group") { QString groupName = selectedItem->data(Qt::UserRole).toString(); int groupNum = selectedItem->data(MapListUserRoles::GroupRole).toInt(); - QMenu* menu = new QMenu(); + QMenu* menu = new QMenu(this); QActionGroup* actions = new QActionGroup(menu); actions->addAction(menu->addAction("Add New Map to Group"))->setData(groupNum); connect(actions, SIGNAL(triggered(QAction*)), this, SLOT(onAddNewMapToGroupClick(QAction*))); diff --git a/src/core/filterchildrenproxymodel.cpp b/src/ui/filterchildrenproxymodel.cpp similarity index 100% rename from src/core/filterchildrenproxymodel.cpp rename to src/ui/filterchildrenproxymodel.cpp