Qt: Initial wave of Qt6 compat fixes

This commit is contained in:
Vicki Pfau 2022-03-15 15:34:56 -07:00
parent 50e0fe9972
commit c8302da954
8 changed files with 26 additions and 22 deletions

View File

@ -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()) {

View File

@ -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;
}

View File

@ -255,7 +255,11 @@ private:
uint64_t m_frameCounter;
QList<std::function<void()>> m_resetActions;
QList<std::function<void()>> 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;

View File

@ -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<CoreController> controller) {
void QGBA::Display::attach(std::shared_ptr<CoreController> 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<CoreController> 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();

View File

@ -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 {

View File

@ -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;
}

View File

@ -29,7 +29,7 @@ TileView::TileView(std::shared_ptr<CoreController> controller, QWidget* parent)
connect(m_ui.tiles, &TilePainter::needsRedraw, this, [this]() {
updateTiles(true);
});
connect(m_ui.tilesSelector, qOverload<int>(&QButtonGroup::buttonClicked), this, [this]() {
connect(m_ui.tilesSelector, qOverload<QAbstractButton*>(&QButtonGroup::buttonClicked), this, [this]() {
updateTiles(true);
});
connect(m_ui.paletteId, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), this, &TileView::updatePalette);

View File

@ -189,7 +189,7 @@ private:
std::shared_ptr<CoreController> m_controller;
std::unique_ptr<AudioProcessor> m_audioProcessor;
std::unique_ptr<Display> m_display;
std::unique_ptr<QGBA::Display> m_display;
int m_savedScale;
// TODO: Move these to a new class