From 41d0b4261fd8d1fe878314cc3701a520c3896029 Mon Sep 17 00:00:00 2001 From: GriffinR Date: Thu, 10 Apr 2025 12:33:56 -0400 Subject: [PATCH] Fix deprecated code as of Qt 6.9 --- include/core/utility.h | 7 ++++ include/mainwindow.h | 7 ++-- include/ui/mapheaderform.h | 10 ++--- include/ui/mapimageexporter.h | 37 ++++++++--------- include/ui/regionmapeditor.h | 5 ++- include/ui/shortcut.h | 3 -- include/ui/tileseteditor.h | 6 +-- src/core/utility.cpp | 7 ++++ src/editor.cpp | 4 ++ src/mainwindow.cpp | 30 ++++++++------ src/scriptapi/apioverlay.cpp | 5 +++ src/ui/customscriptseditor.cpp | 4 ++ src/ui/eventframes.cpp | 4 ++ src/ui/imageproviders.cpp | 7 +++- src/ui/mapheaderform.cpp | 18 ++++++--- src/ui/mapimageexporter.cpp | 68 ++++++++++++++++++++++++-------- src/ui/metatilelayersitem.cpp | 5 +++ src/ui/projectsettingseditor.cpp | 10 ++++- src/ui/regionmapeditor.cpp | 22 ++++++++--- src/ui/shortcut.cpp | 13 +----- src/ui/tilemaptileselector.cpp | 4 ++ src/ui/tileseteditor.cpp | 25 +++++++++--- src/ui/updatepromoter.cpp | 4 ++ 23 files changed, 210 insertions(+), 95 deletions(-) diff --git a/include/core/utility.h b/include/core/utility.h index 1b9277ab..d5b7900b 100644 --- a/include/core/utility.h +++ b/include/core/utility.h @@ -9,6 +9,13 @@ namespace Util { int roundUp(int numToRound, int multiple); QString toDefineCase(QString input); QString toHexString(uint32_t value, int minLength = 0); + Qt::Orientations getOrientation(bool xflip, bool yflip); } +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + typedef Qt::CheckState CheckState; +#else + typedef int CheckState; +#endif + #endif // UTILITY_H diff --git a/include/mainwindow.h b/include/mainwindow.h index cdc641c2..9b1be78a 100644 --- a/include/mainwindow.h +++ b/include/mainwindow.h @@ -248,8 +248,6 @@ private slots: void on_comboBox_PrimaryTileset_currentTextChanged(const QString &arg1); void on_comboBox_SecondaryTileset_currentTextChanged(const QString &arg1); void on_pushButton_ChangeDimensions_clicked(); - void on_checkBox_smartPaths_stateChanged(int selected); - void on_checkBox_ToggleBorder_stateChanged(int selected); void resetMapViewScale(); @@ -260,7 +258,6 @@ private slots: void eventTabChanged(int index); - void on_checkBox_MirrorConnections_stateChanged(int selected); void on_actionDive_Emerge_Map_triggered(); void on_actionShow_Events_In_Map_View_triggered(); void on_groupBox_DiveMapOpacity_toggled(bool on); @@ -437,6 +434,10 @@ private: void checkForUpdates(bool requestedByUser); void setDivingMapsVisible(bool visible); + + void setSmartPathsEnabled(CheckState state); + void setBorderVisibility(CheckState state); + void setMirrorConnectionsEnabled(CheckState state); }; // These are namespaced in a struct to avoid colliding with e.g. class Map. diff --git a/include/ui/mapheaderform.h b/include/ui/mapheaderform.h index 79f4f6c8..1b7bd66a 100644 --- a/include/ui/mapheaderform.h +++ b/include/ui/mapheaderform.h @@ -73,11 +73,11 @@ private: void onWeatherChanged(const QString &weather); void onTypeChanged(const QString &type); void onBattleSceneChanged(const QString &battleScene); - void onRequiresFlashChanged(int selected); - void onShowLocationNameChanged(int selected); - void onAllowRunningChanged(int selected); - void onAllowBikingChanged(int selected); - void onAllowEscapingChanged(int selected); + void onRequiresFlashChanged(CheckState selected); + void onShowLocationNameChanged(CheckState selected); + void onAllowRunningChanged(CheckState selected); + void onAllowBikingChanged(CheckState selected); + void onAllowEscapingChanged(CheckState selected); void onFloorNumberChanged(int offset); }; diff --git a/include/ui/mapimageexporter.h b/include/ui/mapimageexporter.h index ffc4d272..7b85beb9 100644 --- a/include/ui/mapimageexporter.h +++ b/include/ui/mapimageexporter.h @@ -91,30 +91,27 @@ protected: virtual void showEvent(QShowEvent *) override; virtual void resizeEvent(QResizeEvent *) override; -private slots: - void on_checkBox_Objects_stateChanged(int state); - void on_checkBox_Warps_stateChanged(int state); - void on_checkBox_BGs_stateChanged(int state); - void on_checkBox_Triggers_stateChanged(int state); - void on_checkBox_HealLocations_stateChanged(int state); - void on_checkBox_AllEvents_stateChanged(int state); - - void on_checkBox_ConnectionUp_stateChanged(int state); - void on_checkBox_ConnectionDown_stateChanged(int state); - void on_checkBox_ConnectionLeft_stateChanged(int state); - void on_checkBox_ConnectionRight_stateChanged(int state); - void on_checkBox_AllConnections_stateChanged(int state); - - void on_checkBox_Collision_stateChanged(int state); - void on_checkBox_Grid_stateChanged(int state); - void on_checkBox_Border_stateChanged(int state); +private: + void setShowGrid(CheckState state); + void setShowBorder(CheckState state); + void setShowObjects(CheckState state); + void setShowWarps(CheckState state); + void setShowBgs(CheckState state); + void setShowTriggers(CheckState state); + void setShowHealLocations(CheckState state); + void setShowAllEvents(CheckState state); + void setShowConnectionUp(CheckState state); + void setShowConnectionDown(CheckState state); + void setShowConnectionLeft(CheckState state); + void setShowConnectionRight(CheckState state); + void setShowAllConnections(CheckState state); + void setShowCollision(CheckState state); + void setDisablePreviewScaling(CheckState state); + void setDisablePreviewUpdates(CheckState state); void on_pushButton_Reset_pressed(); void on_spinBox_TimelapseDelay_editingFinished(); void on_spinBox_FrameSkip_editingFinished(); - - void on_checkBox_DisablePreviewScaling_stateChanged(int state); - void on_checkBox_DisablePreviewUpdates_stateChanged(int state); }; #endif // MAPIMAGEEXPORTER_H diff --git a/include/ui/regionmapeditor.h b/include/ui/regionmapeditor.h index 9a838827..969b6e3a 100644 --- a/include/ui/regionmapeditor.h +++ b/include/ui/regionmapeditor.h @@ -121,6 +121,9 @@ private: void restoreWindowState(); void closeEvent(QCloseEvent* event); + void setTileHFlip(CheckState); + void setTileVFlip(CheckState); + private slots: void on_action_RegionMap_Save_triggered(); void on_actionSave_All_triggered(); @@ -145,8 +148,6 @@ private slots: void on_spinBox_RM_LayoutWidth_valueChanged(int); void on_spinBox_RM_LayoutHeight_valueChanged(int); void on_spinBox_tilePalette_valueChanged(int); - void on_checkBox_tileHFlip_stateChanged(int); - void on_checkBox_tileVFlip_stateChanged(int); void on_verticalSlider_Zoom_Map_Image_valueChanged(int); void on_verticalSlider_Zoom_Image_Tiles_valueChanged(int); void onHoveredRegionMapTileChanged(int x, int y); diff --git a/include/ui/shortcut.h b/include/ui/shortcut.h index 8989401d..5fdbfaee 100644 --- a/include/ui/shortcut.h +++ b/include/ui/shortcut.h @@ -49,9 +49,6 @@ public: void setAutoRepeat(bool on); bool autoRepeat() const; - int id() const; - QList ids() const; - inline QWidget *parentWidget() const { return static_cast(QObject::parent()); } diff --git a/include/ui/tileseteditor.h b/include/ui/tileseteditor.h index d659390a..ff2999ff 100644 --- a/include/ui/tileseteditor.h +++ b/include/ui/tileseteditor.h @@ -71,10 +71,6 @@ private slots: void on_spinBox_paletteSelector_valueChanged(int arg1); - void on_checkBox_xFlip_stateChanged(int arg1); - - void on_checkBox_yFlip_stateChanged(int arg1); - void on_actionSave_Tileset_triggered(); void on_actionImport_Primary_Tiles_triggered(); @@ -149,6 +145,8 @@ private: void commitTerrainType(); void commitLayerType(); void setRawAttributesVisible(bool visible); + void setXFlip(CheckState state); + void setYFlip(CheckState state); Ui::TilesetEditor *ui; History metatileHistory; diff --git a/src/core/utility.cpp b/src/core/utility.cpp index 1053f879..55830b8a 100644 --- a/src/core/utility.cpp +++ b/src/core/utility.cpp @@ -42,3 +42,10 @@ QString Util::toDefineCase(QString input) { QString Util::toHexString(uint32_t value, int minLength) { return "0x" + QString("%1").arg(value, minLength, 16, QChar('0')).toUpper(); } + +Qt::Orientations Util::getOrientation(bool xflip, bool yflip) { + Qt::Orientations flags; + if (xflip) flags |= Qt::Orientation::Horizontal; + if (yflip) flags |= Qt::Orientation::Vertical; + return flags; +} diff --git a/src/editor.cpp b/src/editor.cpp index 29b6cb5d..a50e5622 100644 --- a/src/editor.cpp +++ b/src/editor.cpp @@ -296,7 +296,11 @@ void Editor::addNewWildMonGroup(QWidget *window) { form.addRow(new QLabel(monField.name), fieldCheckbox); } // Reading from ui here so not saving to disk before user. +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(copyCheckbox, &QCheckBox::checkStateChanged, [=](Qt::CheckState state){ +#else connect(copyCheckbox, &QCheckBox::stateChanged, [=](int state){ +#endif if (state == Qt::Checked) { int fieldIndex = 0; MonTabWidget *monWidget = static_cast(stack->widget(stack->currentIndex())); diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 650acdaf..42c070f8 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -299,6 +299,16 @@ void MainWindow::initExtraSignals() { connect(ui->action_NewLayout, &QAction::triggered, this, &MainWindow::openNewLayoutDialog); connect(ui->actionDuplicate_Current_Map_Layout, &QAction::triggered, this, &MainWindow::openDuplicateMapOrLayoutDialog); connect(ui->comboBox_LayoutSelector->lineEdit(), &QLineEdit::editingFinished, this, &MainWindow::onLayoutSelectorEditingFinished); + +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(ui->checkBox_smartPaths, &QCheckBox::checkStateChanged, this, &MainWindow::setSmartPathsEnabled); + connect(ui->checkBox_ToggleBorder, &QCheckBox::checkStateChanged, this, &MainWindow::setBorderVisibility); + connect(ui->checkBox_MirrorConnections, &QCheckBox::checkStateChanged, this, &MainWindow::setMirrorConnectionsEnabled); +#else + connect(ui->checkBox_smartPaths, &QCheckBox::stateChanged, this, &MainWindow::setSmartPathsEnabled); + connect(ui->checkBox_ToggleBorder, &QCheckBox::stateChanged, this, &MainWindow::setBorderVisibility); + connect(ui->checkBox_MirrorConnections, &QCheckBox::stateChanged, this, &MainWindow::setMirrorConnectionsEnabled); +#endif } void MainWindow::on_actionCheck_for_Updates_triggered() { @@ -2711,25 +2721,21 @@ void MainWindow::on_pushButton_ChangeDimensions_clicked() { } } -void MainWindow::on_checkBox_smartPaths_stateChanged(int selected) +void MainWindow::setSmartPathsEnabled(CheckState state) { - bool enabled = selected == Qt::Checked; - editor->settings->smartPathsEnabled = enabled; - if (enabled) { - editor->cursorMapTileRect->setSmartPathMode(true); - } else { - editor->cursorMapTileRect->setSmartPathMode(false); - } + bool enabled = (state == Qt::Checked); + this->editor->settings->smartPathsEnabled = enabled; + this->editor->cursorMapTileRect->setSmartPathMode(enabled); } -void MainWindow::on_checkBox_ToggleBorder_stateChanged(int selected) +void MainWindow::setBorderVisibility(CheckState state) { - editor->toggleBorderVisibility(selected != 0); + editor->toggleBorderVisibility(state == Qt::Checked); } -void MainWindow::on_checkBox_MirrorConnections_stateChanged(int selected) +void MainWindow::setMirrorConnectionsEnabled(CheckState state) { - porymapConfig.mirrorConnectingMaps = (selected == Qt::Checked); + porymapConfig.mirrorConnectingMaps = (state == Qt::Checked); } void MainWindow::on_actionTileset_Editor_triggered() diff --git a/src/scriptapi/apioverlay.cpp b/src/scriptapi/apioverlay.cpp index 4b1f75b8..00a34495 100644 --- a/src/scriptapi/apioverlay.cpp +++ b/src/scriptapi/apioverlay.cpp @@ -276,7 +276,12 @@ void MapView::addTileImage(int x, int y, int tileId, bool xflip, bool yflip, int this->editor->layout->tileset_primary, this->editor->layout->tileset_secondary, paletteId) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + .flipped(Util::getOrientation(xflip, yflip)); +#else .mirrored(xflip, yflip); +#endif + if (setTransparency) image.setColor(0, qRgba(0, 0, 0, 0)); if (this->getOverlay(layer)->addImage(x, y, image)) diff --git a/src/ui/customscriptseditor.cpp b/src/ui/customscriptseditor.cpp index eddbc7ae..9c166d43 100644 --- a/src/ui/customscriptseditor.cpp +++ b/src/ui/customscriptseditor.cpp @@ -105,7 +105,11 @@ void CustomScriptsEditor::displayScript(const QString &filepath, bool enabled) { connect(widget->ui->b_Choose, &QAbstractButton::clicked, [this, item](bool) { this->replaceScript(item); }); connect(widget->ui->b_Edit, &QAbstractButton::clicked, [this, item](bool) { this->openScript(item); }); connect(widget->ui->b_Delete, &QAbstractButton::clicked, [this, item](bool) { this->removeScript(item); }); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(widget->ui->checkBox_Enable, &QCheckBox::checkStateChanged, this, &CustomScriptsEditor::markEdited); +#else connect(widget->ui->checkBox_Enable, &QCheckBox::stateChanged, this, &CustomScriptsEditor::markEdited); +#endif connect(widget->ui->lineEdit_filepath, &QLineEdit::textEdited, this, &CustomScriptsEditor::markEdited); // Per the Qt manual, for performance reasons QListWidget::setItemWidget shouldn't be used with non-static items. diff --git a/src/ui/eventframes.cpp b/src/ui/eventframes.cpp index 065dbf19..e9c108d3 100644 --- a/src/ui/eventframes.cpp +++ b/src/ui/eventframes.cpp @@ -853,7 +853,11 @@ void HiddenItemFrame::connectSignals(MainWindow *window) { // underfoot this->check_itemfinder->disconnect(); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(this->check_itemfinder, &QCheckBox::checkStateChanged, [=](Qt::CheckState state) { +#else connect(this->check_itemfinder, &QCheckBox::stateChanged, [=](int state) { +#endif this->hiddenItem->setUnderfoot(state == Qt::Checked); this->hiddenItem->modify(); }); diff --git a/src/ui/imageproviders.cpp b/src/ui/imageproviders.cpp index 33ec3596..b1510195 100644 --- a/src/ui/imageproviders.cpp +++ b/src/ui/imageproviders.cpp @@ -127,7 +127,12 @@ QImage getMetatileImage( color.setAlpha(0); tile_image.setColor(0, color.rgba()); - metatile_painter.drawImage(origin, tile_image.mirrored(tile.xflip, tile.yflip)); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + tile_image.flip(Util::getOrientation(tile.xflip, tile.yflip)); +#else + tile_image = tile_image.mirrored(tile.xflip, tile.yflip); +#endif + metatile_painter.drawImage(origin, tile_image); } metatile_painter.end(); diff --git a/src/ui/mapheaderform.cpp b/src/ui/mapheaderform.cpp index 09cb22c7..92fa8c7f 100644 --- a/src/ui/mapheaderform.cpp +++ b/src/ui/mapheaderform.cpp @@ -21,11 +21,19 @@ MapHeaderForm::MapHeaderForm(QWidget *parent) connect(ui->comboBox_Type, &QComboBox::currentTextChanged, this, &MapHeaderForm::onTypeChanged); connect(ui->comboBox_BattleScene, &QComboBox::currentTextChanged, this, &MapHeaderForm::onBattleSceneChanged); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(ui->checkBox_RequiresFlash, &QCheckBox::checkStateChanged, this, &MapHeaderForm::onRequiresFlashChanged); + connect(ui->checkBox_ShowLocationName, &QCheckBox::checkStateChanged, this, &MapHeaderForm::onShowLocationNameChanged); + connect(ui->checkBox_AllowRunning, &QCheckBox::checkStateChanged, this, &MapHeaderForm::onAllowRunningChanged); + connect(ui->checkBox_AllowBiking, &QCheckBox::checkStateChanged, this, &MapHeaderForm::onAllowBikingChanged); + connect(ui->checkBox_AllowEscaping, &QCheckBox::checkStateChanged, this, &MapHeaderForm::onAllowEscapingChanged); +#else connect(ui->checkBox_RequiresFlash, &QCheckBox::stateChanged, this, &MapHeaderForm::onRequiresFlashChanged); connect(ui->checkBox_ShowLocationName, &QCheckBox::stateChanged, this, &MapHeaderForm::onShowLocationNameChanged); connect(ui->checkBox_AllowRunning, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowRunningChanged); connect(ui->checkBox_AllowBiking, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowBikingChanged); connect(ui->checkBox_AllowEscaping, &QCheckBox::stateChanged, this, &MapHeaderForm::onAllowEscapingChanged); +#endif connect(ui->spinBox_FloorNumber, QOverload::of(&QSpinBox::valueChanged), this, &MapHeaderForm::onFloorNumberChanged); @@ -207,11 +215,11 @@ void MapHeaderForm::onSongUpdated(const QString &song) { if (m_hea void MapHeaderForm::onWeatherChanged(const QString &weather) { if (m_header) m_header->setWeather(weather); } void MapHeaderForm::onTypeChanged(const QString &type) { if (m_header) m_header->setType(type); } void MapHeaderForm::onBattleSceneChanged(const QString &battleScene) { if (m_header) m_header->setBattleScene(battleScene); } -void MapHeaderForm::onRequiresFlashChanged(int selected) { if (m_header) m_header->setRequiresFlash(selected == Qt::Checked); } -void MapHeaderForm::onShowLocationNameChanged(int selected) { if (m_header) m_header->setShowsLocationName(selected == Qt::Checked); } -void MapHeaderForm::onAllowRunningChanged(int selected) { if (m_header) m_header->setAllowsRunning(selected == Qt::Checked); } -void MapHeaderForm::onAllowBikingChanged(int selected) { if (m_header) m_header->setAllowsBiking(selected == Qt::Checked); } -void MapHeaderForm::onAllowEscapingChanged(int selected) { if (m_header) m_header->setAllowsEscaping(selected == Qt::Checked); } +void MapHeaderForm::onRequiresFlashChanged(CheckState selected) { if (m_header) m_header->setRequiresFlash(selected == Qt::Checked); } +void MapHeaderForm::onShowLocationNameChanged(CheckState selected) { if (m_header) m_header->setShowsLocationName(selected == Qt::Checked); } +void MapHeaderForm::onAllowRunningChanged(CheckState selected) { if (m_header) m_header->setAllowsRunning(selected == Qt::Checked); } +void MapHeaderForm::onAllowBikingChanged(CheckState selected) { if (m_header) m_header->setAllowsBiking(selected == Qt::Checked); } +void MapHeaderForm::onAllowEscapingChanged(CheckState selected) { if (m_header) m_header->setAllowsEscaping(selected == Qt::Checked); } void MapHeaderForm::onFloorNumberChanged(int offset) { if (m_header) m_header->setFloorNumber(offset); } void MapHeaderForm::onLocationChanged(const QString &location) { if (m_header) m_header->setLocation(location); diff --git a/src/ui/mapimageexporter.cpp b/src/ui/mapimageexporter.cpp index 39607bca..cf1339c5 100644 --- a/src/ui/mapimageexporter.cpp +++ b/src/ui/mapimageexporter.cpp @@ -60,6 +60,42 @@ MapImageExporter::MapImageExporter(QWidget *parent, Project *project, Map *map, connect(ui->comboBox_MapSelection, QOverload::of(&QComboBox::currentIndexChanged), this, &MapImageExporter::updateMapSelection); connect(ui->comboBox_MapSelection->lineEdit(), &QLineEdit::editingFinished, this, &MapImageExporter::updateMapSelection); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(ui->checkBox_Objects, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowObjects); + connect(ui->checkBox_Warps, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowWarps); + connect(ui->checkBox_BGs, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowBgs); + connect(ui->checkBox_Triggers, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowTriggers); + connect(ui->checkBox_HealLocations, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowHealLocations); + connect(ui->checkBox_AllEvents, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowAllEvents); + connect(ui->checkBox_ConnectionUp, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowConnectionUp); + connect(ui->checkBox_ConnectionDown, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowConnectionDown); + connect(ui->checkBox_ConnectionLeft, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowConnectionLeft); + connect(ui->checkBox_ConnectionRight, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowConnectionRight); + connect(ui->checkBox_AllConnections, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowAllConnections); + connect(ui->checkBox_Collision, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowCollision); + connect(ui->checkBox_Grid, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowGrid); + connect(ui->checkBox_Border, &QCheckBox::checkStateChanged, this, &MapImageExporter::setShowBorder); + connect(ui->checkBox_DisablePreviewScaling, &QCheckBox::checkStateChanged, this, &MapImageExporter::setDisablePreviewScaling); + connect(ui->checkBox_DisablePreviewUpdates, &QCheckBox::checkStateChanged, this, &MapImageExporter::setDisablePreviewUpdates); +#else + connect(ui->checkBox_Objects, &QCheckBox::stateChanged, this, &MapImageExporter::setShowObjects); + connect(ui->checkBox_Warps, &QCheckBox::stateChanged, this, &MapImageExporter::setShowWarps); + connect(ui->checkBox_BGs, &QCheckBox::stateChanged, this, &MapImageExporter::setShowBgs); + connect(ui->checkBox_Triggers, &QCheckBox::stateChanged, this, &MapImageExporter::setShowTriggers); + connect(ui->checkBox_HealLocations, &QCheckBox::stateChanged, this, &MapImageExporter::setShowHealLocations); + connect(ui->checkBox_AllEvents, &QCheckBox::stateChanged, this, &MapImageExporter::setShowAllEvents); + connect(ui->checkBox_ConnectionUp, &QCheckBox::stateChanged, this, &MapImageExporter::setShowConnectionUp); + connect(ui->checkBox_ConnectionDown, &QCheckBox::stateChanged, this, &MapImageExporter::setShowConnectionDown); + connect(ui->checkBox_ConnectionLeft, &QCheckBox::stateChanged, this, &MapImageExporter::setShowConnectionLeft); + connect(ui->checkBox_ConnectionRight, &QCheckBox::stateChanged, this, &MapImageExporter::setShowConnectionRight); + connect(ui->checkBox_AllConnections, &QCheckBox::stateChanged, this, &MapImageExporter::setShowAllConnections); + connect(ui->checkBox_Collision, &QCheckBox::stateChanged, this, &MapImageExporter::setShowCollision); + connect(ui->checkBox_Grid, &QCheckBox::stateChanged, this, &MapImageExporter::setShowGrid); + connect(ui->checkBox_Border, &QCheckBox::stateChanged, this, &MapImageExporter::setShowBorder); + connect(ui->checkBox_DisablePreviewScaling, &QCheckBox::stateChanged, this, &MapImageExporter::setDisablePreviewScaling); + connect(ui->checkBox_DisablePreviewUpdates, &QCheckBox::stateChanged, this, &MapImageExporter::setDisablePreviewUpdates); +#endif + ui->graphicsView_Preview->setFocus(); } @@ -719,48 +755,48 @@ void MapImageExporter::setConnectionDirectionEnabled(const QString &dir, bool en } } -void MapImageExporter::on_checkBox_Collision_stateChanged(int state) { +void MapImageExporter::setShowCollision(CheckState state) { m_settings.showCollision = (state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_Grid_stateChanged(int state) { +void MapImageExporter::setShowGrid(CheckState state) { m_settings.showGrid = (state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_Border_stateChanged(int state) { +void MapImageExporter::setShowBorder(CheckState state) { m_settings.showBorder = (state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_Objects_stateChanged(int state) { +void MapImageExporter::setShowObjects(CheckState state) { setEventGroupEnabled(Event::Group::Object, state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_Warps_stateChanged(int state) { +void MapImageExporter::setShowWarps(CheckState state) { setEventGroupEnabled(Event::Group::Warp, state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_BGs_stateChanged(int state) { +void MapImageExporter::setShowBgs(CheckState state) { setEventGroupEnabled(Event::Group::Bg, state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_Triggers_stateChanged(int state) { +void MapImageExporter::setShowTriggers(CheckState state) { setEventGroupEnabled(Event::Group::Coord, state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_HealLocations_stateChanged(int state) { +void MapImageExporter::setShowHealLocations(CheckState state) { setEventGroupEnabled(Event::Group::Heal, state == Qt::Checked); updatePreview(); } // Shortcut setting for enabling all events -void MapImageExporter::on_checkBox_AllEvents_stateChanged(int state) { +void MapImageExporter::setShowAllEvents(CheckState state) { bool on = (state == Qt::Checked); const QSignalBlocker b_Objects(ui->checkBox_Objects); @@ -791,28 +827,28 @@ void MapImageExporter::on_checkBox_AllEvents_stateChanged(int state) { updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionUp_stateChanged(int state) { +void MapImageExporter::setShowConnectionUp(CheckState state) { setConnectionDirectionEnabled("up", state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionDown_stateChanged(int state) { +void MapImageExporter::setShowConnectionDown(CheckState state) { setConnectionDirectionEnabled("down", state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionLeft_stateChanged(int state) { +void MapImageExporter::setShowConnectionLeft(CheckState state) { setConnectionDirectionEnabled("left", state == Qt::Checked); updatePreview(); } -void MapImageExporter::on_checkBox_ConnectionRight_stateChanged(int state) { +void MapImageExporter::setShowConnectionRight(CheckState state) { setConnectionDirectionEnabled("right", state == Qt::Checked); updatePreview(); } // Shortcut setting for enabling all connection directions -void MapImageExporter::on_checkBox_AllConnections_stateChanged(int state) { +void MapImageExporter::setShowAllConnections(CheckState state) { bool on = (state == Qt::Checked); const QSignalBlocker b_Up(ui->checkBox_ConnectionUp); @@ -838,7 +874,7 @@ void MapImageExporter::on_checkBox_AllConnections_stateChanged(int state) { updatePreview(); } -void MapImageExporter::on_checkBox_DisablePreviewScaling_stateChanged(int state) { +void MapImageExporter::setDisablePreviewScaling(CheckState state) { m_settings.disablePreviewScaling = (state == Qt::Checked); if (m_settings.disablePreviewScaling) { ui->graphicsView_Preview->resetTransform(); @@ -847,7 +883,7 @@ void MapImageExporter::on_checkBox_DisablePreviewScaling_stateChanged(int state) } } -void MapImageExporter::on_checkBox_DisablePreviewUpdates_stateChanged(int state) { +void MapImageExporter::setDisablePreviewUpdates(CheckState state) { m_settings.disablePreviewUpdates = (state == Qt::Checked); if (m_settings.disablePreviewUpdates) { if (m_timelapseMovie) { diff --git a/src/ui/metatilelayersitem.cpp b/src/ui/metatilelayersitem.cpp index 3050e761..87218f52 100644 --- a/src/ui/metatilelayersitem.cpp +++ b/src/ui/metatilelayersitem.cpp @@ -1,6 +1,7 @@ #include "config.h" #include "metatilelayersitem.h" #include "imageproviders.h" +#include "utility.h" #include static const QList tilePositions = { @@ -28,7 +29,11 @@ void MetatileLayersItem::draw() { for (int i = 0; i < numTiles; i++) { Tile tile = this->metatile->tiles.at(i); QImage tileImage = getPalettedTileImage(tile.tileId, this->primaryTileset, this->secondaryTileset, tile.palette, true) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + .flipped(Util::getOrientation(tile.xflip, tile.yflip)) +#else .mirrored(tile.xflip, tile.yflip) +#endif .scaled(16, 16); painter.drawImage(tilePositions.at(i) * 16, tileImage); } diff --git a/src/ui/projectsettingseditor.cpp b/src/ui/projectsettingseditor.cpp index 1c869dce..b1c61151 100644 --- a/src/ui/projectsettingseditor.cpp +++ b/src/ui/projectsettingseditor.cpp @@ -45,7 +45,11 @@ void ProjectSettingsEditor::connectSignals() { connect(ui->comboBox_BaseGameVersion, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::promptRestoreDefaults); connect(ui->comboBox_AttributesSize, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::updateAttributeLimits); connect(ui->comboBox_IconSpecies, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::updatePokemonIconPath); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(ui->checkBox_EnableCustomBorderSize, &QCheckBox::checkStateChanged, [this](Qt::CheckState state) { +#else connect(ui->checkBox_EnableCustomBorderSize, &QCheckBox::stateChanged, [this](int state) { +#endif bool customSize = (state == Qt::Checked); // When switching between the spin boxes or line edit for border metatiles we set // the newly-shown UI using the values from the hidden UI. @@ -82,8 +86,12 @@ void ProjectSettingsEditor::connectSignals() { connect(combo, &QComboBox::currentTextChanged, this, &ProjectSettingsEditor::markEdited); } for (auto checkBox : ui->centralwidget->findChildren()) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(checkBox, &QCheckBox::checkStateChanged, this, &ProjectSettingsEditor::markEdited); +#else connect(checkBox, &QCheckBox::stateChanged, this, &ProjectSettingsEditor::markEdited); - for (auto radioButton : ui->centralwidget->findChildren()) +#endif + for (auto radioButton : ui->centralwidget->findChildren()) connect(radioButton, &QRadioButton::toggled, this, &ProjectSettingsEditor::markEdited); for (auto lineEdit : ui->centralwidget->findChildren()) connect(lineEdit, &QLineEdit::textEdited, this, &ProjectSettingsEditor::markEdited); diff --git a/src/ui/regionmapeditor.cpp b/src/ui/regionmapeditor.cpp index 2febccd8..9495395f 100644 --- a/src/ui/regionmapeditor.cpp +++ b/src/ui/regionmapeditor.cpp @@ -27,6 +27,15 @@ RegionMapEditor::RegionMapEditor(QWidget *parent, Project *project) : this->ui->setupUi(this); this->project = project; connect(this->project, &Project::mapSectionIdNamesChanged, this, &RegionMapEditor::setLocations); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(ui->checkBox_tileHFlip, &QCheckBox::checkStateChanged, this, &RegionMapEditor::setTileHFlip); + connect(ui->checkBox_tileVFlip, &QCheckBox::checkStateChanged, this, &RegionMapEditor::setTileVFlip); +#else + connect(ui->checkBox_tileHFlip, &QCheckBox::stateChanged, this, &RegionMapEditor::setTileHFlip); + connect(ui->checkBox_tileVFlip, &QCheckBox::stateChanged, this, &RegionMapEditor::setTileVFlip); +#endif + + this->configFilepath = QString("%1/%2").arg(this->project->root).arg(projectConfig.getFilePath(ProjectFilePath::json_region_porymap_cfg)); this->initShortcuts(); this->restoreWindowState(); @@ -1030,15 +1039,18 @@ void RegionMapEditor::on_pushButton_RM_Options_delete_clicked() { } void RegionMapEditor::on_spinBox_tilePalette_valueChanged(int value) { - this->mapsquare_selector_item->selectPalette(value); + if (this->mapsquare_selector_item) + this->mapsquare_selector_item->selectPalette(value); } -void RegionMapEditor::on_checkBox_tileHFlip_stateChanged(int state) { - this->mapsquare_selector_item->selectHFlip(state == Qt::Checked); +void RegionMapEditor::setTileHFlip(CheckState state) { + if (this->mapsquare_selector_item) + this->mapsquare_selector_item->selectHFlip(state == Qt::Checked); } -void RegionMapEditor::on_checkBox_tileVFlip_stateChanged(int state) { - this->mapsquare_selector_item->selectVFlip(state == Qt::Checked); +void RegionMapEditor::setTileVFlip(CheckState state) { + if (this->mapsquare_selector_item) + this->mapsquare_selector_item->selectVFlip(state == Qt::Checked); } void RegionMapEditor::on_action_RegionMap_Resize_triggered() { diff --git a/src/ui/shortcut.cpp b/src/ui/shortcut.cpp index e94b4095..6b72da09 100644 --- a/src/ui/shortcut.cpp +++ b/src/ui/shortcut.cpp @@ -123,21 +123,10 @@ bool Shortcut::autoRepeat() const { return sc_vec.first()->autoRepeat(); } -int Shortcut::id() const { - return sc_vec.first()->id(); -} - -QList Shortcut::ids() const { - QList id_list; - for (auto *sc : sc_vec) - id_list.append(sc->id()); - return id_list; -} - bool Shortcut::event(QEvent *e) { if (isEnabled() && e->type() == QEvent::Shortcut) { auto se = static_cast(e); - if (ids().contains(se->shortcutId()) && keys().contains(se->key())) { + if (keys().contains(se->key())) { if (QWhatsThis::inWhatsThisMode()) { QWhatsThis::showText(QCursor::pos(), whatsThis()); } else { diff --git a/src/ui/tilemaptileselector.cpp b/src/ui/tilemaptileselector.cpp index a4ef5719..9093b694 100644 --- a/src/ui/tilemaptileselector.cpp +++ b/src/ui/tilemaptileselector.cpp @@ -93,7 +93,11 @@ QImage TilemapTileSelector::tileImg(shared_ptr tile) { // take a tile from the tileset QImage img = tilesetImage.copy(pos.x() * 8, pos.y() * 8, 8, 8); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + img.flip(Util::getOrientation(tile->hFlip(), tile->vFlip())); +#else img = img.mirrored(tile->hFlip(), tile->vFlip()); +#endif return img; } diff --git a/src/ui/tileseteditor.cpp b/src/ui/tileseteditor.cpp index 351771df..9281bd28 100644 --- a/src/ui/tileseteditor.cpp +++ b/src/ui/tileseteditor.cpp @@ -27,6 +27,14 @@ TilesetEditor::TilesetEditor(Project *project, Layout *layout, QWidget *parent) setTilesets(this->layout->tileset_primary_label, this->layout->tileset_secondary_label); ui->setupUi(this); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(ui->checkBox_xFlip, &QCheckBox::checkStateChanged, this, &TilesetEditor::setXFlip); + connect(ui->checkBox_yFlip, &QCheckBox::checkStateChanged, this, &TilesetEditor::setYFlip); +#else + connect(ui->checkBox_xFlip, &QCheckBox::stateChanged, this, &TilesetEditor::setXFlip); + connect(ui->checkBox_yFlip, &QCheckBox::stateChanged, this, &TilesetEditor::setYFlip); +#endif + this->tileXFlip = ui->checkBox_xFlip->isChecked(); this->tileYFlip = ui->checkBox_yFlip->isChecked(); this->paletteId = ui->spinBox_paletteSelector->value(); @@ -388,8 +396,13 @@ void TilesetEditor::drawSelectedTiles() { int tileIndex = 0; for (int j = 0; j < dimensions.y(); j++) { for (int i = 0; i < dimensions.x(); i++) { - QImage tileImage = getPalettedTileImage(tiles.at(tileIndex).tileId, this->primaryTileset, this->secondaryTileset, tiles.at(tileIndex).palette, true) - .mirrored(tiles.at(tileIndex).xflip, tiles.at(tileIndex).yflip) + auto tile = tiles.at(tileIndex); + QImage tileImage = getPalettedTileImage(tile.tileId, this->primaryTileset, this->secondaryTileset, tile.palette, true) +#if (QT_VERSION >= QT_VERSION_CHECK(6, 9, 0)) + .flipped(Util::getOrientation(tile.xflip, tile.yflip)) +#else + .mirrored(tile.xflip, tile.yflip) +#endif .scaled(16, 16); tileIndex++; painter.drawImage(i * 16, j * 16, tileImage); @@ -540,17 +553,17 @@ void TilesetEditor::on_spinBox_paletteSelector_valueChanged(int paletteId) this->metatileLayersItem->clearLastModifiedCoords(); } -void TilesetEditor::on_checkBox_xFlip_stateChanged(int checked) +void TilesetEditor::setXFlip(CheckState state) { - this->tileXFlip = checked; + this->tileXFlip = (state == Qt::Checked); this->tileSelector->setTileFlips(this->tileXFlip, this->tileYFlip); this->drawSelectedTiles(); this->metatileLayersItem->clearLastModifiedCoords(); } -void TilesetEditor::on_checkBox_yFlip_stateChanged(int checked) +void TilesetEditor::setYFlip(CheckState state) { - this->tileYFlip = checked; + this->tileYFlip = (state == Qt::Checked); this->tileSelector->setTileFlips(this->tileXFlip, this->tileYFlip); this->drawSelectedTiles(); this->metatileLayersItem->clearLastModifiedCoords(); diff --git a/src/ui/updatepromoter.cpp b/src/ui/updatepromoter.cpp index f9331a16..27c37b0a 100644 --- a/src/ui/updatepromoter.cpp +++ b/src/ui/updatepromoter.cpp @@ -19,7 +19,11 @@ UpdatePromoter::UpdatePromoter(QWidget *parent, NetworkAccessManager *manager) // Set up "Do not alert me" check box this->updatePreferences(); ui->checkBox_StopAlerts->setVisible(false); +#if (QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)) + connect(ui->checkBox_StopAlerts, &QCheckBox::checkStateChanged, [this](Qt::CheckState state) { +#else connect(ui->checkBox_StopAlerts, &QCheckBox::stateChanged, [this](int state) { +#endif porymapConfig.checkForUpdates = (state != Qt::Checked); emit this->changedPreferences(); });