From 1a357be9d09b3ba1d41576b3a3d049c2554e0906 Mon Sep 17 00:00:00 2001 From: Hugues Delorme Date: Thu, 5 Dec 2024 17:04:40 +0100 Subject: [PATCH] Code cosmetics about usages of "#if QT_VERSION" --- src/app/command_system_information.cpp | 2 +- src/app/qtgui_utils.cpp | 2 +- src/app/widget_main_control.cpp | 2 +- src/qtbackend/qt_signal_thread_helper.cpp | 7 ++++++- src/qtcommon/qtcore_hfuncs.h | 2 +- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/app/command_system_information.cpp b/src/app/command_system_information.cpp index 47388f25..15ef44db 100644 --- a/src/app/command_system_information.cpp +++ b/src/app/command_system_information.cpp @@ -352,7 +352,7 @@ QString CommandSystemInformation::data() << indentx2 << "useHoverEffects: " << sh->useHoverEffects() << '\n' << indentx2 << "wheelScrollLines: " << sh->wheelScrollLines() << '\n' << indentx2 << "mouseQuickSelectionThreshold: " << sh->mouseQuickSelectionThreshold() << '\n' -#if (QT_VERSION >= QT_VERSION_CHECK(5, 14, 0)) +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) << indentx2 << "mouseDoubleClickDistance: " << sh->mouseDoubleClickDistance() << '\n' << indentx2 << "touchDoubleTapDistance: " << sh->touchDoubleTapDistance() << '\n' #endif diff --git a/src/app/qtgui_utils.cpp b/src/app/qtgui_utils.cpp index 7a3adcca..3893288f 100644 --- a/src/app/qtgui_utils.cpp +++ b/src/app/qtgui_utils.cpp @@ -203,7 +203,7 @@ QPixmap toQPixmap(const Image_PixMap& pixmap) auto fnToQImageFormat = [](Image_Format occFormat) { switch (occFormat) { case Image_Format_RGB: return QImage::Format_RGB888; -#if (QT_VERSION>=QT_VERSION_CHECK(5,14,0)) +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) case Image_Format_BGR: return QImage::Format_BGR888; #endif case Image_Format_RGBA: return QImage::Format_ARGB32; diff --git a/src/app/widget_main_control.cpp b/src/app/widget_main_control.cpp index d6a0415c..a78d5484 100644 --- a/src/app/widget_main_control.cpp +++ b/src/app/widget_main_control.cpp @@ -374,7 +374,7 @@ void WidgetMainControl::reloadDocumentAfterChange(const DocumentPtr& doc) ; const auto msgBtns = QMessageBox::Yes | QMessageBox::No; auto msgBox = new QMessageBox(QMessageBox::Question, tr("Question"), strQuestion, msgBtns, this); -#if (QT_VERSION>=QT_VERSION_CHECK(5,14,0)) +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) msgBox->setTextFormat(Qt::MarkdownText); #else msgBox->setTextFormat(Qt::AutoText); diff --git a/src/qtbackend/qt_signal_thread_helper.cpp b/src/qtbackend/qt_signal_thread_helper.cpp index ae4ec8c5..fb605353 100644 --- a/src/qtbackend/qt_signal_thread_helper.cpp +++ b/src/qtbackend/qt_signal_thread_helper.cpp @@ -20,7 +20,12 @@ std::any QtSignalThreadHelper::getCurrentThreadContext() void QtSignalThreadHelper::execInThread(const std::any& context, const std::function& fn) { - QMetaObject::invokeMethod(std::any_cast(context), fn, Qt::ConnectionType::QueuedConnection); + auto qobject = std::any_cast(context); +#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) + QTimer::singleShot(0, qobject, fn); +#else + QMetaObject::invokeMethod(qobject, fn, Qt::ConnectionType::QueuedConnection); +#endif } } // namespace Mayo diff --git a/src/qtcommon/qtcore_hfuncs.h b/src/qtcommon/qtcore_hfuncs.h index 91b8e943..91637c0d 100644 --- a/src/qtcommon/qtcore_hfuncs.h +++ b/src/qtcommon/qtcore_hfuncs.h @@ -24,7 +24,7 @@ inline std::size_t hash_value(const QString& key) { } // namespace boost -#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0)) +#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) namespace std { // Specialization of C++11 std::hash<> functor for QByteArray