From 5bf7ef97e56841eb8d1de12722a66a859e5bfcde Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 15 Jan 2022 01:03:57 +0200 Subject: [PATCH 24/24] 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 | 36 ++++++++++++++++---------------- client/gui-qt/citydlg.h | 12 +++++------ client/gui-qt/fc_client.cpp | 8 +++---- client/gui-qt/gui_main.cpp | 6 +++--- client/gui-qt/hudwidget.cpp | 12 +++++------ client/gui-qt/hudwidget.h | 12 +++++------ client/gui-qt/messagewin.cpp | 6 +++--- client/gui-qt/messagewin.h | 6 +++--- client/gui-qt/pages.cpp | 6 +++--- client/gui-qt/repodlgs.cpp | 6 +++--- client/gui-qt/repodlgs.h | 6 +++--- client/gui-qt/sidebar.cpp | 6 +++--- client/gui-qt/sidebar.h | 8 +++---- configure.ac | 4 ++-- gen_headers/meson_fc_config.h.in | 3 +++ tools/fcmp/mpgui_qt.cpp | 6 +++--- tools/ruledit/ruledit_qt.cpp | 6 +++--- 17 files changed, 76 insertions(+), 73 deletions(-) diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp index 00bf778cf0..701554355c 100644 --- a/client/gui-qt/citydlg.cpp +++ b/client/gui-qt/citydlg.cpp @@ -403,11 +403,11 @@ void impr_item::init_pix() /************************************************************************//** Mouse enters widget ****************************************************************************/ -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void impr_item::enterEvent(QEnterEvent *event) -#else // FC_QT6_MODE +#else // FC_QT5_MODE void impr_item::enterEvent(QEvent *event) -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE { struct sprite *sprite; QPainter p; @@ -530,19 +530,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); } @@ -587,19 +587,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); } @@ -965,11 +965,11 @@ void unit_item::fortify_unit() /************************************************************************//** Mouse entered widget ****************************************************************************/ -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void unit_item::enterEvent(QEnterEvent *event) -#else // FC_QT6_MODE +#else // FC_QT5_MODE void unit_item::enterEvent(QEvent *event) -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE { QImage temp_img(unit_img.size(), QImage::Format_ARGB32_Premultiplied); QPainter p; @@ -1001,19 +1001,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); } @@ -1089,19 +1089,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/citydlg.h b/client/gui-qt/citydlg.h index 7f406794db..79b9c112cb 100644 --- a/client/gui-qt/citydlg.h +++ b/client/gui-qt/citydlg.h @@ -184,11 +184,11 @@ protected: void wheelEvent(QWheelEvent *event); void mousePressEvent(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 }; /**************************************************************************** @@ -237,11 +237,11 @@ protected: void wheelEvent(QWheelEvent *event); void mouseDoubleClickEvent(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 }; diff --git a/client/gui-qt/fc_client.cpp b/client/gui-qt/fc_client.cpp index dfd1a3492d..47f5f10ece 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 ed5b88b5c5..e60704de45 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_QT5_MODE 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 8bc03513f7..6efd61a6b5 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(); @@ -1911,11 +1911,11 @@ void hud_unit_combat::leaveEvent(QEvent *event) /************************************************************************//** Leave event for hud unit combat. Shows highlight. ****************************************************************************/ -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void hud_unit_combat::enterEvent(QEnterEvent *event) -#else // FC_QT6_MODE +#else // FC_QT5_MODE void hud_unit_combat::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 d90565103f..723461d936 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(); @@ -307,11 +307,11 @@ protected: void paintEvent(QPaintEvent *event); void mousePressEvent(QMouseEvent *e); 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: void init_images(bool redraw = false); int att_hp; diff --git a/client/gui-qt/messagewin.cpp b/client/gui-qt/messagewin.cpp index 5bbab6d4ed..f2ede73ab4 100644 --- a/client/gui-qt/messagewin.cpp +++ b/client/gui-qt/messagewin.cpp @@ -262,11 +262,11 @@ void messagewdg::item_selected(const QItemSelection &sl, /***********************************************************************//** Mouse entered messagewdg ***************************************************************************/ -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void messagewdg::enterEvent(QEnterEvent *event) -#else // FC_QT6x_MODE +#else // FC_QT5_MODE void messagewdg::enterEvent(QEvent *event) -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE { setCursor(Qt::ArrowCursor); } diff --git a/client/gui-qt/messagewin.h b/client/gui-qt/messagewin.h index e451d1b6d1..dc6a8d5d46 100644 --- a/client/gui-qt/messagewin.h +++ b/client/gui-qt/messagewin.h @@ -52,11 +52,11 @@ private: QGridLayout *layout; QPixmap *pix; protected: -#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 void leaveEvent(QEvent *event); void paint(QPainter *painter, QPaintEvent *event); void paintEvent(QPaintEvent *event); diff --git a/client/gui-qt/pages.cpp b/client/gui-qt/pages.cpp index ebd12553e6..40485932c4 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/repodlgs.cpp b/client/gui-qt/repodlgs.cpp index 9ab523cb28..d7c45e56ab 100644 --- a/client/gui-qt/repodlgs.cpp +++ b/client/gui-qt/repodlgs.cpp @@ -236,11 +236,11 @@ void unittype_item::upgrade_units() /************************************************************************//** Mouse entered widget ****************************************************************************/ -#ifdef FC_QT6_MODE +#ifndef FC_QT5_MODE void unittype_item::enterEvent(QEnterEvent *event) -#else // FC_QT6_MODE +#else // FC_QT5_MODE void unittype_item::enterEvent(QEvent *event) -#endif // FC_QT6_MODE +#endif // FC_QT5_MODE { entered = true; update(); diff --git a/client/gui-qt/repodlgs.h b/client/gui-qt/repodlgs.h index 4bdb4854c3..a25fb709fd 100644 --- a/client/gui-qt/repodlgs.h +++ b/client/gui-qt/repodlgs.h @@ -72,11 +72,11 @@ private slots: void upgrade_units(); protected: -#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 void leaveEvent(QEvent *event); void paintEvent(QPaintEvent *event); void wheelEvent(QWheelEvent *event); 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 71958bfc4f..a5a09ef123 100644 --- a/configure.ac +++ b/configure.ac @@ -671,8 +671,8 @@ AC_ARG_WITH([qtver], *) AC_MSG_ERROR([bad value ${enableval} for --with-qtver]) ;; esac], [qt_ver="$qt_default"]) -if test "x$qt_ver" = "xQt6" ; then - AC_DEFINE([FC_QT6_MODE], [1], [this is Qt6 based build]) +if test "x$qt_ver" = "xQt5" ; then + AC_DEFINE([FC_QT5_MODE], [1], [this is Qt5 based build]) fi FC_WORKING_CXX diff --git a/gen_headers/meson_fc_config.h.in b/gen_headers/meson_fc_config.h.in index e31fc9dec8..a135e1a57f 100644 --- a/gen_headers/meson_fc_config.h.in +++ b/gen_headers/meson_fc_config.h.in @@ -48,6 +48,9 @@ /* Have Sqlite3 database backend */ #define HAVE_FCDB_SQLITE3 1 +/* Build in Qt5 mode */ +#define FC_QT5_MODE + /* Release cycle information */ #mesondefine IS_DEVEL_VERSION 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.34.1