mirror of
https://github.com/huderlem/porymap.git
synced 2026-08-11 19:35:38 -05:00
Add unlockable icon
This commit is contained in:
@@ -334,6 +334,8 @@ void MainWindow::initCustomUI() {
|
||||
ui->mainTabBar->setTabIcon(i, mainTabIcons.value(i));
|
||||
}
|
||||
|
||||
this->unlockableMainTabIcon.load(":/images/unlockable_tab_icon.dat");
|
||||
|
||||
// Create map header data widget
|
||||
this->mapHeaderForm = new MapHeaderForm();
|
||||
ui->layout_HeaderData->addWidget(this->mapHeaderForm);
|
||||
@@ -343,6 +345,12 @@ void MainWindow::initCustomUI() {
|
||||
ui->graphicsView_Map->setResizeAnchor(QGraphicsView::ViewportAnchor::AnchorUnderMouse);
|
||||
}
|
||||
|
||||
void MainWindow::overrideMainTabIcons(const QIcon& icon) {
|
||||
for (int i = 1; i < ui->mainTabBar->count(); i++) {
|
||||
ui->mainTabBar->setTabIcon(i, icon);
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::initExtraSignals() {
|
||||
connect(ui->tabWidget_EventType, &QTabWidget::currentChanged, this, &MainWindow::eventTabChanged);
|
||||
|
||||
@@ -2285,6 +2293,8 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
|
||||
ui->stackedWidget_MapEvents->setCurrentIndex(1);
|
||||
} else if (index == MainTab::Connections) {
|
||||
ui->graphicsView_Connections->setFocus(); // Avoid opening tab with focus on something editable
|
||||
connect(this, &MainWindow::mapOpened, this, &MainWindow::tryUnlockMainTabIcon, Qt::UniqueConnection);
|
||||
connect(&this->unlockableMainTabIcon, &UnlockableIcon::unlocked, this, &MainWindow::overrideMainTabIcons, Qt::UniqueConnection);
|
||||
}
|
||||
|
||||
if (!editor->map) return;
|
||||
@@ -2294,6 +2304,18 @@ void MainWindow::on_mainTabBar_tabBarClicked(int index)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::tryUnlockMainTabIcon(const Map* map) {
|
||||
if (!map || this->unlockableMainTabIcon.isUnlocked()) return;
|
||||
const Layout* layout = map->layout();
|
||||
if (!layout) return;
|
||||
|
||||
QSet<QChar> chars;
|
||||
if (!layout->name.isEmpty()) chars.insert(layout->name.at(0));
|
||||
const QString tilesetName = Tileset::stripPrefix(layout->tileset_secondary_label);
|
||||
if (!tilesetName.isEmpty()) chars.insert(tilesetName.at(0));
|
||||
this->unlockableMainTabIcon.tryUnlock(chars);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionZoom_In_triggered() {
|
||||
editor->scaleMapView(1);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user