From c8302da954a46869cf1222d4f153c1f3923b899b Mon Sep 17 00:00:00 2001 From: Vicki Pfau Date: Tue, 15 Mar 2022 15:34:56 -0700 Subject: [PATCH] Qt: Initial wave of Qt6 compat fixes --- src/platform/qt/CheatsModel.cpp | 2 +- src/platform/qt/ConfigController.cpp | 4 ++-- src/platform/qt/CoreController.h | 4 ++++ src/platform/qt/Display.cpp | 30 ++++++++++++++-------------- src/platform/qt/LoadSaveState.cpp | 2 +- src/platform/qt/LogConfigModel.cpp | 2 +- src/platform/qt/TileView.cpp | 2 +- src/platform/qt/Window.h | 2 +- 8 files changed, 26 insertions(+), 22 deletions(-) diff --git a/src/platform/qt/CheatsModel.cpp b/src/platform/qt/CheatsModel.cpp index 3694424d8..85528c1b6 100644 --- a/src/platform/qt/CheatsModel.cpp +++ b/src/platform/qt/CheatsModel.cpp @@ -107,7 +107,7 @@ QModelIndex CheatsModel::parent(const QModelIndex& index) const { Qt::ItemFlags CheatsModel::flags(const QModelIndex& index) const { if (!index.isValid()) { - return 0; + return Qt::NoItemFlags; } if (index.parent().isValid()) { diff --git a/src/platform/qt/ConfigController.cpp b/src/platform/qt/ConfigController.cpp index 74861027d..e6162237b 100644 --- a/src/platform/qt/ConfigController.cpp +++ b/src/platform/qt/ConfigController.cpp @@ -63,9 +63,9 @@ Action* ConfigOption::addBoolean(const QString& text, ActionMapper* actions, con } QObject::connect(action, &QObject::destroyed, this, [this, action]() { - m_actions.removeAll(std::make_pair(action, 1)); + m_actions.removeAll(std::make_pair(action, QVariant(1))); }); - m_actions.append(std::make_pair(action, 1)); + m_actions.append(std::make_pair(action, QVariant(1))); return action; } diff --git a/src/platform/qt/CoreController.h b/src/platform/qt/CoreController.h index be96f15f9..ead578003 100644 --- a/src/platform/qt/CoreController.h +++ b/src/platform/qt/CoreController.h @@ -255,7 +255,11 @@ private: uint64_t m_frameCounter; QList> m_resetActions; QList> m_frameActions; +#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) + QRecursiveMutex m_actionMutex; +#else QMutex m_actionMutex{QMutex::Recursive}; +#endif int m_moreFrames = -1; QMutex m_bufferMutex; diff --git a/src/platform/qt/Display.cpp b/src/platform/qt/Display.cpp index 0914a65f4..7548e674c 100644 --- a/src/platform/qt/Display.cpp +++ b/src/platform/qt/Display.cpp @@ -16,12 +16,12 @@ using namespace QGBA; #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY) -Display::Driver Display::s_driver = Display::Driver::OPENGL; +QGBA::Display::Driver Display::s_driver = QGBA::Display::Driver::OPENGL; #else -Display::Driver Display::s_driver = Display::Driver::QT; +QGBA::Display::Driver Display::s_driver = QGBA::Display::Driver::QT; #endif -Display* Display::create(QWidget* parent) { +QGBA::Display* QGBA::Display::create(QWidget* parent) { #if defined(BUILD_GL) || defined(BUILD_GLES2) || defined(BUILD_GLES3) || defined(USE_EPOXY) QSurfaceFormat format; format.setSwapInterval(1); @@ -76,7 +76,7 @@ Display* Display::create(QWidget* parent) { } } -Display::Display(QWidget* parent) +QGBA::Display::Display(QWidget* parent) : QWidget(parent) { setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding); @@ -86,7 +86,7 @@ Display::Display(QWidget* parent) setMouseTracking(true); } -void Display::attach(std::shared_ptr controller) { +void QGBA::Display::attach(std::shared_ptr controller) { CoreController* controllerP = controller.get(); connect(controllerP, &CoreController::stateLoaded, this, &Display::resizeContext); connect(controllerP, &CoreController::stateLoaded, this, &Display::forceDraw); @@ -103,7 +103,7 @@ void Display::attach(std::shared_ptr controller) { connect(controllerP, &CoreController::didReset, this, &Display::resizeContext); } -void Display::configure(ConfigController* config) { +void QGBA::Display::configure(ConfigController* config) { const mCoreOptions* opts = config->options(); lockAspectRatio(opts->lockAspectRatio); lockIntegerScaling(opts->lockIntegerScaling); @@ -122,7 +122,7 @@ void Display::configure(ConfigController* config) { #endif } -void Display::resizeEvent(QResizeEvent*) { +void QGBA::Display::resizeEvent(QResizeEvent*) { #if (QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)) m_messagePainter.resize(size(), devicePixelRatioF()); #else @@ -130,41 +130,41 @@ void Display::resizeEvent(QResizeEvent*) { #endif } -void Display::lockAspectRatio(bool lock) { +void QGBA::Display::lockAspectRatio(bool lock) { m_lockAspectRatio = lock; } -void Display::lockIntegerScaling(bool lock) { +void QGBA::Display::lockIntegerScaling(bool lock) { m_lockIntegerScaling = lock; } -void Display::interframeBlending(bool lock) { +void QGBA::Display::interframeBlending(bool lock) { m_interframeBlending = lock; } -void Display::showOSDMessages(bool enable) { +void QGBA::Display::showOSDMessages(bool enable) { m_showOSD = enable; } -void Display::showFrameCounter(bool enable) { +void QGBA::Display::showFrameCounter(bool enable) { m_showFrameCounter = enable; if (!enable) { m_messagePainter.clearFrameCounter(); } } -void Display::filter(bool filter) { +void QGBA::Display::filter(bool filter) { m_filter = filter; } -void Display::showMessage(const QString& message) { +void QGBA::Display::showMessage(const QString& message) { m_messagePainter.showMessage(message); if (!isDrawing()) { forceDraw(); } } -void Display::mouseMoveEvent(QMouseEvent*) { +void QGBA::Display::mouseMoveEvent(QMouseEvent*) { emit showCursor(); m_mouseTimer.stop(); m_mouseTimer.start(); diff --git a/src/platform/qt/LoadSaveState.cpp b/src/platform/qt/LoadSaveState.cpp index 4bcae6175..aa76ed523 100644 --- a/src/platform/qt/LoadSaveState.cpp +++ b/src/platform/qt/LoadSaveState.cpp @@ -216,7 +216,7 @@ void LoadSaveState::loadState(int slot) { m_slots[slot - 1]->setIcon(statePixmap); } if (creation.toMSecsSinceEpoch()) { - m_slots[slot - 1]->setText(creation.toString(Qt::DefaultLocaleShortDate)); + m_slots[slot - 1]->setText(QLocale().toString(creation, QLocale::ShortFormat)); } else if (stateImage.isNull()) { m_slots[slot - 1]->setText(tr("Slot %1").arg(slot)); } else { diff --git a/src/platform/qt/LogConfigModel.cpp b/src/platform/qt/LogConfigModel.cpp index dd3d48b6a..2748aaf7c 100644 --- a/src/platform/qt/LogConfigModel.cpp +++ b/src/platform/qt/LogConfigModel.cpp @@ -139,7 +139,7 @@ int LogConfigModel::rowCount(const QModelIndex& parent) const { Qt::ItemFlags LogConfigModel::flags(const QModelIndex& index) const { if (!index.isValid() || (index.row() == 0 && index.column() == 0)) { - return 0; + return Qt::NoItemFlags; } return Qt::ItemIsUserCheckable | Qt::ItemIsEnabled; } diff --git a/src/platform/qt/TileView.cpp b/src/platform/qt/TileView.cpp index 3e8e58155..23cba18fd 100644 --- a/src/platform/qt/TileView.cpp +++ b/src/platform/qt/TileView.cpp @@ -29,7 +29,7 @@ TileView::TileView(std::shared_ptr controller, QWidget* parent) connect(m_ui.tiles, &TilePainter::needsRedraw, this, [this]() { updateTiles(true); }); - connect(m_ui.tilesSelector, qOverload(&QButtonGroup::buttonClicked), this, [this]() { + connect(m_ui.tilesSelector, qOverload(&QButtonGroup::buttonClicked), this, [this]() { updateTiles(true); }); connect(m_ui.paletteId, static_cast(&QSpinBox::valueChanged), this, &TileView::updatePalette); diff --git a/src/platform/qt/Window.h b/src/platform/qt/Window.h index 4a76a5d2e..db319080c 100644 --- a/src/platform/qt/Window.h +++ b/src/platform/qt/Window.h @@ -189,7 +189,7 @@ private: std::shared_ptr m_controller; std::unique_ptr m_audioProcessor; - std::unique_ptr m_display; + std::unique_ptr m_display; int m_savedScale; // TODO: Move these to a new class