fix Qt deprecation warnings

This commit is contained in:
oltolm 2024-05-25 14:11:53 +02:00 committed by Vicki Pfau
parent 3a3ebb5dc7
commit c7b5d10546
9 changed files with 52 additions and 1 deletions

View File

@ -318,7 +318,11 @@ void ConfigController::setOption(const char* key, const char* value) {
}
void ConfigController::setOption(const char* key, const QVariant& value) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (value.type() == QVariant::Bool) {
#else
if (value.typeId() == QMetaType::Type::Bool) {
#endif
setOption(key, value.toBool());
return;
}

View File

@ -505,12 +505,20 @@ bool FrameView::eventFilter(QObject*, QEvent* event) {
QPointF pos;
switch (event->type()) {
case QEvent::MouseButtonPress:
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
pos = static_cast<QMouseEvent*>(event)->localPos();
#else
pos = static_cast<QMouseEvent*>(event)->position();
#endif
pos /= m_ui.magnification->value();
selectLayer(pos);
return true;
case QEvent::MouseButtonDblClick:
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
pos = static_cast<QMouseEvent*>(event)->localPos();
#else
pos = static_cast<QMouseEvent*>(event)->position();
#endif
pos /= m_ui.magnification->value();
disableLayer(pos);
return true;

View File

@ -161,8 +161,13 @@ bool MapView::eventFilter(QObject*, QEvent* event) {
if (event->type() != QEvent::MouseButtonPress) {
return false;
}
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
int x = static_cast<QMouseEvent*>(event)->x();
int y = static_cast<QMouseEvent*>(event)->y();
#else
int x = static_cast<QMouseEvent*>(event)->position().x();
int y = static_cast<QMouseEvent*>(event)->position().y();
#endif
x /= 8 * m_ui.magnification->value();
y /= 8 * m_ui.magnification->value();
selectTile(x, y);

View File

@ -511,8 +511,13 @@ void MemoryModel::wheelEvent(QWheelEvent* event) {
}
void MemoryModel::mousePressEvent(QMouseEvent* event) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (event->x() < m_margins.left() || event->y() < m_margins.top() ||
event->x() > size().width() - m_margins.right()) {
#else
if (event->position().x() < m_margins.left() || event->position().y() < m_margins.top() ||
event->position().x() > size().width() - m_margins.right()) {
#endif
m_selection = qMakePair(0, 0);
return;
}
@ -540,8 +545,13 @@ void MemoryModel::mousePressEvent(QMouseEvent* event) {
}
void MemoryModel::mouseMoveEvent(QMouseEvent* event) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (event->x() < m_margins.left() || event->y() < m_margins.top() ||
event->x() > size().width() - m_margins.right()) {
#else
if (event->position().x() < m_margins.left() || event->position().y() < m_margins.top() ||
event->position().x() > size().width() - m_margins.right()) {
#endif
return;
}

View File

@ -281,7 +281,7 @@ void SaveConverter::detectFromHeaders(std::shared_ptr<VFileDevice> vf) {
}
free(data);
}
} else if (buffer.left(gsv.count()) == gsv) {
} else if (buffer.left(gsv.size()) == gsv) {
size_t size;
void* data = GBASavedataGSVGetPayload(*vf, &size, nullptr, false);
if (data) {

View File

@ -56,8 +56,13 @@ void Swatch::paintEvent(QPaintEvent*) {
}
void Swatch::mousePressEvent(QMouseEvent* event) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
int x = event->x() / (m_size + 1);
int y = event->y() / (m_size + 1);
#else
int x = event->position().x() / (m_size + 1);
int y = event->position().y() / (m_size + 1);
#endif
emit indexPressed(y * m_dims.width() + x);
}

View File

@ -39,8 +39,13 @@ void TilePainter::resizeEvent(QResizeEvent*) {
}
void TilePainter::mousePressEvent(QMouseEvent* event) {
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
int x = event->x() / m_size;
int y = event->y() / m_size;
#else
int x = event->position().x() / m_size;
int y = event->position().y() / m_size;
#endif
int index = y * (width() / m_size) + x;
if (index < m_tileCount) {
emit indexPressed(index);

View File

@ -918,7 +918,11 @@ void Window::gameStarted() {
#ifdef M_CORE_GBA
if (m_controller->platform() == mPLATFORM_GBA) {
QVariant eCardList = m_config->takeArgvOption(QString("ecard"));
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (eCardList.canConvert(QMetaType::QStringList)) {
#else
if (QMetaType::canConvert(eCardList.metaType(), QMetaType(QMetaType::QStringList))) {
#endif
m_controller->scanCards(eCardList.toStringList());
}
}
@ -2149,7 +2153,11 @@ void Window::setController(CoreController* controller, const QString& fname) {
#ifdef M_CORE_GBA
if (m_controller->platform() == mPLATFORM_GBA) {
QVariant mb = m_config->takeArgvOption(QString("mb"));
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (mb.canConvert(QMetaType::QString)) {
#else
if (QMetaType::canConvert(mb.metaType(), QMetaType(QMetaType::QString))) {
#endif
m_controller->replaceGame(mb.toString());
}
}

View File

@ -90,7 +90,9 @@ int main(int argc, char* argv[]) {
QApplication::setApplicationName(projectName);
QApplication::setApplicationVersion(projectVersion);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
#endif
#ifdef BUILD_GLES2
QSurfaceFormat format;
@ -109,7 +111,11 @@ int main(int argc, char* argv[]) {
#endif
QTranslator qtTranslator;
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
if (qtTranslator.load(locale, "qt", "_", QLibraryInfo::location(QLibraryInfo::TranslationsPath))) {
#else
if (qtTranslator.load(locale, "qt", "_", QLibraryInfo::path(QLibraryInfo::TranslationsPath))) {
#endif
application.installTranslator(&qtTranslator);
}