From 521cee69b50a52cad656bb7007d863cc30757c39 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 9 Oct 2021 20:17:27 +0300 Subject: [PATCH 53/53] Replace FC_QT6_MODE with FC_QT5_MODE Turn the Qt6-as-special-case logic to Qt5-as-special-case by retiring FC_QT6_MODE macro and introducing FC_QT5_MODE. See osdn #43010 Signed-off-by: Marko Lindqvist --- client/gui-qt/citydlg.cpp | 24 ++++++++++++------------ client/gui-qt/fc_client.cpp | 8 ++++---- client/gui-qt/gui_main.cpp | 6 +++--- client/gui-qt/hudwidget.cpp | 6 +++--- client/gui-qt/hudwidget.h | 6 +++--- client/gui-qt/pages.cpp | 6 +++--- client/gui-qt/sidebar.cpp | 6 +++--- client/gui-qt/sidebar.h | 8 ++++---- configure.ac | 7 +++++-- tools/fcmp/mpgui_qt.cpp | 6 +++--- tools/ruledit/ruledit_qt.cpp | 6 +++--- 11 files changed, 46 insertions(+), 43 deletions(-) diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index b692476372..8fdc5a10f9 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -526,19 +526,19 @@ void impr_info::wheelEvent(QWheelEvent *event) p = parentWidget()->parentWidget()->pos(); p = mapToGlobal(p); -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->buttons(), event->modifiers(), event->phase(), false, event->source()); -#else /* FC_QT6_MODE */ +#else /* FC_QT5_MODE */ QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->angleDelta().y(), Qt::Horizontal, event->buttons(), event->modifiers(), event->phase(), event->source()); -#endif /* FC_QT6_MODE */ +#endif /* FC_QT5_MODE */ QApplication::sendEvent(parentWidget(), &new_event); } @@ -583,19 +583,19 @@ void impr_item::wheelEvent(QWheelEvent *event) p = parentWidget()->parentWidget()->pos(); p = mapToGlobal(p); -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->buttons(), event->modifiers(), event->phase(), false, event->source()); -#else /* FC_QT6_MODE */ +#else /* FC_QT5_MODE */ QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->angleDelta().y(), Qt::Horizontal, event->buttons(), event->modifiers(), event->phase(), event->source()); -#endif /* FC_QT6_MODE */ +#endif /* FC_QT5_MODE */ QApplication::sendEvent(parentWidget()->parentWidget(), &new_event); } @@ -993,19 +993,19 @@ void unit_item::wheelEvent(QWheelEvent *event) p = parentWidget()->parentWidget()->pos(); p = mapToGlobal(p); -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->buttons(), event->modifiers(), event->phase(), false, event->source()); -#else /* FC_QT6_MODE */ +#else /* FC_QT5_MODE */ QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->angleDelta().y(), Qt::Horizontal, event->buttons(), event->modifiers(), event->phase(), event->source()); -#endif /* FC_QT6_MODE */ +#endif /* FC_QT5_MODE */ QApplication::sendEvent(parentWidget()->parentWidget(), &new_event); } @@ -1081,19 +1081,19 @@ void unit_info::wheelEvent(QWheelEvent *event) p = parentWidget()->parentWidget()->pos(); p = mapToGlobal(p); -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->buttons(), event->modifiers(), event->phase(), false, event->source()); -#else /* FC_QT6_MODE */ +#else /* FC_QT5_MODE */ QWheelEvent new_event(QPoint(5, 5), p + QPoint(5,5), event->pixelDelta(), event->angleDelta(), event->angleDelta().y(), Qt::Horizontal, event->buttons(), event->modifiers(), event->phase(), event->source()); -#endif /* FC_QT6_MODE */ +#endif /* FC_QT5_MODE */ QApplication::sendEvent(parentWidget(), &new_event); } diff --git a/client/gui-qt/fc_client.cpp b/client/gui-qt/fc_client.cpp index 8fc89bd0e5..d81da4b910 100644 --- a/client/gui-qt/fc_client.cpp +++ b/client/gui-qt/fc_client.cpp @@ -34,9 +34,9 @@ #include #include -#ifndef FC_QT6_MODE +#ifdef FC_QT5_MODE #include -#endif /* FC_QT6_MODE */ +#endif /* FC_QT5_MODE */ #include @@ -69,9 +69,9 @@ QString current_theme; ****************************************************************************/ fc_client::fc_client() : QMainWindow() { -#ifndef FC_QT6_MODE +#ifdef FC_QT5_MODE QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8")); -#endif /* FC_QT6_MODE */ +#endif /* FC_QT5_MODE */ /** * Somehow freeciv-client-common asks to switch to page when all widgets * haven't been created yet by Qt, even constructor finished job, diff --git a/client/gui-qt/gui_main.cpp b/client/gui-qt/gui_main.cpp index 7c0db16d6c..2a672d494d 100644 --- a/client/gui-qt/gui_main.cpp +++ b/client/gui-qt/gui_main.cpp @@ -546,9 +546,9 @@ void qtg_insert_client_build_info(char *outbuf, size_t outlen) cat_snprintf(outbuf, outlen, _("\nBuilt against Qt %s, using %s"), QT_VERSION_STR, qVersion()); -#ifdef FC_QT6_MODE +#ifndef FC_QT65MODE cat_snprintf(outbuf, outlen, _("\nBuilt in Qt6 mode.")); -#else // FC_QT6_MODE +#else // FC_QT5_MODE cat_snprintf(outbuf, outlen, _("\nBuilt in Qt5 mode.")); -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE } diff --git a/client/gui-qt/hudwidget.cpp b/client/gui-qt/hudwidget.cpp index 6cae46de27..315e9ed658 100644 --- a/client/gui-qt/hudwidget.cpp +++ b/client/gui-qt/hudwidget.cpp @@ -897,11 +897,11 @@ void hud_action::leaveEvent(QEvent *event) /************************************************************************//** Enter event for hud_action, used to get status of pixmap higlight ****************************************************************************/ -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void hud_action::enterEvent(QEnterEvent *event) -#else // FC_QT6_MODE +#else // FC_QT5_MODE void hud_action::enterEvent(QEvent *event) -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE { focus = true; update(); diff --git a/client/gui-qt/hudwidget.h b/client/gui-qt/hudwidget.h index 0f9c518af8..d7c6cead7b 100644 --- a/client/gui-qt/hudwidget.h +++ b/client/gui-qt/hudwidget.h @@ -171,11 +171,11 @@ protected: void mousePressEvent(QMouseEvent *e); void mouseMoveEvent(QMouseEvent *event); void leaveEvent(QEvent *event); -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void enterEvent(QEnterEvent *event); -#else // FC_QT6_MODE +#else // FC_QT5_MODE void enterEvent(QEvent *event); -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE private slots: void on_clicked(); void on_right_clicked(); diff --git a/client/gui-qt/pages.cpp b/client/gui-qt/pages.cpp index 682a06cf4b..f46dcbf49e 100644 --- a/client/gui-qt/pages.cpp +++ b/client/gui-qt/pages.cpp @@ -1348,15 +1348,15 @@ void fc_client::slot_selection_changed(const QItemSelection &selected, load_pix->setPixmap(*(new QPixmap)); } -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE QPixmap pm = load_pix->pixmap(Qt::ReturnByValue); load_pix->setFixedSize(pm.width(), pm.height()); -#else /* FC_QT6_MODE */ +#else /* FC_QT5_MODE */ load_pix->setFixedSize(load_pix->pixmap()->width(), load_pix->pixmap()->height()); -#endif /* FC_QT6_MODE */ +#endif /* FC_QT5_MODE */ if ((sf = secfile_load_section(fn_bytes.data(), "research", TRUE))) { diff --git a/client/gui-qt/sidebar.cpp b/client/gui-qt/sidebar.cpp index ae761a9a13..0148d4ed27 100644 --- a/client/gui-qt/sidebar.cpp +++ b/client/gui-qt/sidebar.cpp @@ -203,11 +203,11 @@ void fc_sidewidget::paint(QPainter *painter, QPaintEvent *event) /***********************************************************************//** Mouse entered on widget area ***************************************************************************/ -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void fc_sidewidget::enterEvent(QEnterEvent *event) -#else // FC_QT6_MODE +#else // FC_QT5_MODE void fc_sidewidget::enterEvent(QEvent *event) -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE { if (!hover) { hover = true; diff --git a/client/gui-qt/sidebar.h b/client/gui-qt/sidebar.h index ba0b6a06a1..acb275bc3f 100644 --- a/client/gui-qt/sidebar.h +++ b/client/gui-qt/sidebar.h @@ -74,12 +74,12 @@ public slots: void sblink(); void some_slot(); protected: - void contextMenuEvent(QContextMenuEvent *event); -#ifdef FC_QT6_MODE + void contextMenuEvent(QContextMenuEvent *event); +#ifndef FC_QT5_MODE void enterEvent(QEnterEvent *event); -#else // FC_QT6_MODE +#else // FC_QT5_MODE void enterEvent(QEvent *event); -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE void leaveEvent(QEvent *event); void mousePressEvent(QMouseEvent *event); void paintEvent(QPaintEvent *event); diff --git a/configure.ac b/configure.ac index 13c587e472..15ec5e718d 100644 --- a/configure.ac +++ b/configure.ac @@ -661,11 +661,14 @@ dnl when setting compiler flags. AC_ARG_WITH([qt6], AS_HELP_STRING([--with-qt6], [build Qt6 versions of Qt programs]), [case "${withval}" in - yes) qt_ver="Qt6" - AC_DEFINE([FC_QT6_MODE], [1], [this is Qt6 based build]) ;; + yes) qt_ver="Qt6" ;; *) qt_ver="Qt5" ;; esac], [qt_ver="Qt5"]) +if test "x$qt_ver" = "xQt5" ; then + AC_DEFINE([FC_QT5_MODE], [1], [this is Qt5 based build]) +fi + FC_WORKING_CXX dnl Set debug flags supported by compiler diff --git a/tools/fcmp/mpgui_qt.cpp b/tools/fcmp/mpgui_qt.cpp index 2be9b4f82c..ca735ab4f2 100644 --- a/tools/fcmp/mpgui_qt.cpp +++ b/tools/fcmp/mpgui_qt.cpp @@ -196,11 +196,11 @@ void mpgui::setup(QWidget *central, struct fcmp_params *params) rev_ver = fc_git_revision(); -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE mode = R__("built in Qt6 mode."); -#else // FC_QT6_MODE +#else // FC_QT5_MODE mode = R__("built in Qt5 mode."); -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE if (rev_ver == nullptr) { fc_snprintf(verbuf, sizeof(verbuf), "%s%s\n%s", word_version(), diff --git a/tools/ruledit/ruledit_qt.cpp b/tools/ruledit/ruledit_qt.cpp index 3b7dc22350..47b4d6643c 100644 --- a/tools/ruledit/ruledit_qt.cpp +++ b/tools/ruledit/ruledit_qt.cpp @@ -123,11 +123,11 @@ void ruledit_gui::setup(QWidget *central_in) rev_ver = fc_git_revision(); -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE mode = R__("built in Qt6 mode."); -#else // FC_QT6_MODE +#else // FC_QT5_MODE mode = R__("built in Qt5 mode."); -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE if (rev_ver == NULL) { fc_snprintf(verbuf, sizeof(verbuf), "%s%s\n%s", word_version(), -- 2.33.0