Project

General

Profile

Feature #1219 ยป 0028-Clean-out-qt5-support-code.patch

Marko Lindqvist, 01/21/2025 11:00 PM

View differences:

client/gui-qt/citydlg.cpp
/************************************************************************//**
Mouse enters widget
****************************************************************************/
#ifndef FC_QT5_MODE
void impr_item::enterEvent(QEnterEvent *event)
#else // FC_QT5_MODE
void impr_item::enterEvent(QEvent *event)
#endif // FC_QT5_MODE
{
struct sprite *sprite;
QPainter p;
......
/************************************************************************//**
Mouse entered widget
****************************************************************************/
#ifndef FC_QT5_MODE
void unit_item::enterEvent(QEnterEvent *event)
#else // FC_QT5_MODE
void unit_item::enterEvent(QEvent *event)
#endif // FC_QT5_MODE
{
QImage temp_img(unit_img.size(), QImage::Format_ARGB32_Premultiplied);
QPainter p;
......
return;
}
#ifndef FC_QT5_MODE
fc_assert_ret(id.typeId() == QMetaType::Int);
#else // FC_QT5_MODE
fc_assert_ret(id.type() == QVariant::Int);
#endif // FC_QT5_MODE
worklist = global_worklist_get(global_worklist_by_id(id.toInt()));
city_set_queue(pcity, worklist);
......
return;
}
#ifndef FC_QT5_MODE
fc_assert_ret(id.typeId() == QMetaType::Int);
#else // FC_QT5_MODE
fc_assert_ret(id.type() == QVariant::Int);
#endif // FC_QT5_MODE
worklist = global_worklist_get(global_worklist_by_id(id.toInt()));
city_queue_insert_worklist(pcity, selected_row_p + 1, worklist);
client/gui-qt/citydlg.h
void wheelEvent(QWheelEvent *event);
void mousePressEvent(QMouseEvent *event);
void leaveEvent(QEvent *event);
#ifndef FC_QT5_MODE
void enterEvent(QEnterEvent *event);
#else // FC_QT5_MODE
void enterEvent(QEvent *event);
#endif // FC_QT5_MODE
};
/****************************************************************************
......
void wheelEvent(QWheelEvent *event);
void mouseDoubleClickEvent(QMouseEvent *event);
void leaveEvent(QEvent *event);
#ifndef FC_QT5_MODE
void enterEvent(QEnterEvent *event);
#else // FC_QT5_MODE
void enterEvent(QEvent *event);
#endif // FC_QT5_MODE
};
/****************************************************************************
Shows list of improvements
****************************************************************************/
client/gui-qt/dialogs.cpp
void qfc_dialog::mouseMoveEvent(QMouseEvent *event)
{
if (moving_now) {
move(mevent_gpos(event) - point);
move(event->globalPosition().toPoint() - point);
}
}
......
if (y <= titlebar_height
&& x <= width() - close_pix.width()) {
point = mevent_gpos(event) - geometry().topLeft();
point = event->globalPosition().toPoint() - geometry().topLeft();
moving_now = true;
setCursor(Qt::SizeAllCursor);
} else if (y <= titlebar_height
......
***************************************************************************/
void notify_dialog::mousePressEvent(QMouseEvent *event)
{
cursor = mevent_gpos(event) - geometry().topLeft();
cursor = event->globalPosition().toPoint() - geometry().topLeft();
if (event->button() == Qt::RightButton) {
was_destroyed = true;
......
***************************************************************************/
void notify_dialog::mouseMoveEvent(QMouseEvent *event)
{
move(mevent_gpos(event) - cursor);
move(event->globalPosition().toPoint() - cursor);
setCursor(Qt::SizeAllCursor);
}
client/gui-qt/fc_client.cpp
#include <QStyleFactory>
#include <QTabBar>
#include <QTextBlock>
#ifdef FC_QT5_MODE
#include <QTextCodec>
#endif // FC_QT5_MODE
#include <QTextEdit>
// common
......
{
QString wtitle;
#ifdef FC_QT5_MODE
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));
#endif // FC_QT5_MODE
/**
* Somehow client-common asks to switch to page when all widgets
* haven't been created yet by Qt, even constructor finished job,
......
wtitle = wtitle.arg(
#ifdef FC_QT6X_MODE
"Qt6x"
#elif FC_QT5_MODE
"Qt5"
#else // FC_QT6X_MODE
"Qt6"
#endif // FC_QT6X_MODE
client/gui-qt/fonts.cpp
QString configure_font(QString font_name, QStringList sl, int size,
bool bold)
{
#ifdef FC_QT5_MODE
QFontDatabase database;
#endif
QString str;
QFont *f;
QString style;
......
}
foreach (str, sl) {
#ifndef FC_QT5_MODE
QList<int> sizes = QFontDatabase::smoothSizes(str, style);
#else // FC_QT5_MODE
QList<int> sizes = database.smoothSizes(str, style);
#endif // FC_QT5_MODE
if (!sizes.isEmpty()) {
QListIterator<int> i(sizes);
client/gui-qt/gui_main.cpp
cat_snprintf(outbuf, outlen, _("\nBuilt against Qt %s, using %s"),
QT_VERSION_STR, ver.data());
#ifdef FC_QT5_MODE
cat_snprintf(outbuf, outlen, _("\nBuilt in Qt5 mode."));
#elif defined(FC_QT6X_MODE)
#if defined(FC_QT6X_MODE)
cat_snprintf(outbuf, outlen, _("\nBuilt in Qt6x mode."));
#else // FC_QT5_MODE
#else // FC_QT6X_MODE
cat_snprintf(outbuf, outlen, _("\nBuilt in Qt6 mode."));
#endif // FC_QT5_MODE
#endif // FC_QT6X_MODE
}
/**********************************************************************//**
client/gui-qt/gui_main.h
void popup_quit_dialog();
QApplication *current_app();
// Compatibility layer between Qt5 and Qt6 while we support
// also the former.
#ifndef FC_QT5_MODE
#define mevent_gpos(__ev__) (__ev__)->globalPosition().toPoint()
#else // FC_QT5_MODE
#define mevent_gpos(__ev__) (__ev__)->globalPos()
#endif // FC_QT5_MODE
#ifdef FREECIV_HAVE_CXX20_CAPTURE_THIS
#define CAPTURE_DEFAULT_THIS [=, this]
#else // FREECIV_HAVE_CXX20_CAPTURE_THIS
client/gui-qt/hudwidget.cpp
/************************************************************************//**
Enter event for hud_action, used to get status of pixmap highlight
****************************************************************************/
#ifndef FC_QT5_MODE
void hud_action::enterEvent(QEnterEvent *event)
#else // FC_QT5_MODE
void hud_action::enterEvent(QEvent *event)
#endif // FC_QT5_MODE
{
focus = true;
update();
......
/************************************************************************//**
Leave event for hud unit combat. Shows highlight.
****************************************************************************/
#ifndef FC_QT5_MODE
void hud_unit_combat::enterEvent(QEnterEvent *event)
#else // FC_QT5_MODE
void hud_unit_combat::enterEvent(QEvent *event)
#endif // FC_QT5_MODE
{
focus = true;
update();
......
void scale_widget::mousePressEvent(QMouseEvent *event)
{
if (event->button() == Qt::LeftButton) {
#ifndef FC_QT5_MODE
if (event->position().x() <= size) {
#else // FC_QT5_MODE
if (event->localPos().x() <= size) {
#endif // FC_QT5_MODE
scale = scale / 1.2;
} else {
scale = scale * 1.2;
client/gui-qt/hudwidget.h
void mousePressEvent(QMouseEvent *e);
void mouseMoveEvent(QMouseEvent *event);
void leaveEvent(QEvent *event);
#ifndef FC_QT5_MODE
void enterEvent(QEnterEvent *event);
#else // FC_QT5_MODE
void enterEvent(QEvent *event);
#endif // FC_QT5_MODE
private slots:
void on_clicked();
void on_right_clicked();
......
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent *e);
void leaveEvent(QEvent *event);
#ifndef FC_QT5_MODE
void enterEvent(QEnterEvent *event);
#else // FC_QT5_MODE
void enterEvent(QEvent *event);
#endif // FC_QT5_MODE
private:
void init_images(bool redraw = false);
int att_hp;
client/gui-qt/mapview.cpp
void move_widget::mouseMoveEvent(QMouseEvent *event)
{
if (!gui()->interface_locked) {
parentWidget()->move(mevent_gpos(event) - point);
parentWidget()->move(event->globalPosition().toPoint() - point);
}
}
......
void move_widget::mousePressEvent(QMouseEvent *event)
{
if (!gui()->interface_locked) {
point = mevent_gpos(event) - parentWidget()->geometry().topLeft();
point = event->globalPosition().toPoint()
- parentWidget()->geometry().topLeft();
}
update();
......
return;
}
qp = mevent_gpos(event);
qp = event->globalPosition().toPoint();
np.setX(qp.x() - point.x());
np.setY(qp.y() - point.y());
np.setX(qMax(np.x(), 32));
......
return;
}
qp = mevent_gpos(event);
qp = event->globalPosition().toPoint();
point.setX(qp.x() - parentWidget()->width());
point.setY(qp.y() - parentWidget()->height());
update();
......
if (gui()->interface_locked) {
return;
}
cursor = mevent_gpos(event) - geometry().topLeft();
cursor = event->globalPosition().toPoint() - geometry().topLeft();
}
if (event->button() == Qt::RightButton) {
......
p = event->pos();
r = mapTo(gui()->mapview_wdg, p);
p = r - p;
move(mevent_gpos(event) - cursor);
move(event->globalPosition().toPoint() - cursor);
setCursor(Qt::SizeAllCursor);
gui()->qt_settings.minimap_x = static_cast<float>(p.x()) / mapview.width;
gui()->qt_settings.minimap_y = static_cast<float>(p.y())
client/gui-qt/messagewin.cpp
int x = pos.x();
int y = pos.y();
cursor = mevent_gpos(event) - geometry().topLeft();
cursor = event->globalPosition().toPoint() - geometry().topLeft();
if (y > 0 && y < 25 && x > width() - 25 && x < width()) {
resize_mode = true;
resxy = true;
......
if ((event->buttons() & Qt::LeftButton) && resize_mode && resy) {
QPoint to_move;
#ifndef FC_QT5_MODE
int newheight = event->globalPosition().y() - cursor.y() - geometry().y();
#else // FC_QT5_MODE
int newheight = event->globalY() - cursor.y() - geometry().y();
#endif // FC_QT5_MODE
resize(width(), this->geometry().height()-newheight);
to_move = mevent_gpos(event) - cursor;
to_move = event->globalPosition().toPoint() - cursor;
move(this->x(), to_move.y());
setCursor(Qt::SizeVerCursor);
restore_chat();
......
setCursor(Qt::SizeVerCursor);
} else if (resxy && (event->buttons() & Qt::LeftButton)) {
QPoint to_move;
#ifndef FC_QT5_MODE
int newheight = event->globalPosition().y() - cursor.y() - geometry().y();
#else // FC_QT5_MODE
int newheight = event->globalY() - cursor.y() - geometry().y();
#endif // FC_QT5_MODE
resize(ex, this->geometry().height()- newheight);
to_move = mevent_gpos(event) - cursor;
to_move = event->globalPosition().toPoint() - cursor;
move(this->x(), to_move.y());
setCursor(Qt::SizeBDiagCursor);
restore_chat();
......
/***********************************************************************//**
Mouse entered messagewdg
***************************************************************************/
#ifndef FC_QT5_MODE
void messagewdg::enterEvent(QEnterEvent *event)
#else // FC_QT5_MODE
void messagewdg::enterEvent(QEvent *event)
#endif // FC_QT5_MODE
{
setCursor(Qt::ArrowCursor);
}
client/gui-qt/messagewin.h
QGridLayout *layout;
QPixmap *pix;
protected:
#ifndef FC_QT5_MODE
void enterEvent(QEnterEvent *event);
#else // FC_QT5_MODE
void enterEvent(QEvent *event);
#endif // FC_QT5_MODE
void leaveEvent(QEvent *event);
void paint(QPainter *painter, QPaintEvent *event);
void paintEvent(QPaintEvent *event);
client/gui-qt/pages.cpp
rev_ver = fc_git_revision();
if (rev_ver == nullptr) {
// TRANS: "version 3.1.0, Qt5 client"
#ifdef FC_QT5_MODE
fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt5 client"),
word_version(), VERSION_STRING);
#elif defined(FC_QT6X_MODE)
// TRANS: "version 3.4.0, Qt6 client"
#if defined(FC_QT6X_MODE)
fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt6x client"),
word_version(), VERSION_STRING);
#else // FC_QT5_MODE
#else // FC_QT6X_MODE
fc_snprintf(msgbuf, sizeof(msgbuf), _("%s%s, Qt6 client"),
word_version(), VERSION_STRING);
#endif // FC_QT5_MODE
#endif // FC_QT6X_MODE
} else {
fc_snprintf(msgbuf, sizeof(msgbuf), "%s%s",
word_version(), VERSION_STRING);
......
main_graphics.height() - fm.descent() - fm.height(),
msgbuf);
#ifdef FC_QT5_MODE
strncpy(msgbuf, _("Qt5 client"), sizeof(msgbuf) - 1);
#elif defined(FC_QT6X_MODE)
#if defined(FC_QT6X_MODE)
strncpy(msgbuf, _("Qt6x client"), sizeof(msgbuf) - 1);
#else // FC_QT5_MODE
#else // FC_QT6X_MODE
strncpy(msgbuf, _("Qt6 client"), sizeof(msgbuf) - 1);
#endif // FC_QT5_MODE
#endif // FC_QT6X_MODE
}
painter.drawText(main_graphics.width() - fm.horizontalAdvance (msgbuf)
......
load_pix->setPixmap(*(new QPixmap));
}
#ifdef FC_QT5_MODE
QPixmap pm = load_pix->pixmap(Qt::ReturnByValue);
#else // FC_QT5_MODE
QPixmap pm = load_pix->pixmap();
#endif // FC_QT5_MODE
load_pix->setFixedSize(pm.width(),
pm.height());
client/gui-qt/repodlgs.cpp
/************************************************************************//**
Mouse entered widget
****************************************************************************/
#ifndef FC_QT5_MODE
void unittype_item::enterEvent(QEnterEvent *event)
#else // FC_QT5_MODE
void unittype_item::enterEvent(QEvent *event)
#endif // FC_QT5_MODE
{
entered = true;
update();
......
tt_text = def_str + tt_text.toHtmlEscaped();
tooltip_text = tt_text.trimmed();
tooltip_rect = rttp->rect;
tooltip_pos = mevent_gpos(event);
tooltip_pos = event->globalPosition().toPoint();
if (!QToolTip::isVisible() && !timer_active) {
timer_active = true;
QTimer::singleShot(500, this, SLOT(show_tooltip()));
client/gui-qt/repodlgs.h
void upgrade_units();
protected:
#ifndef FC_QT5_MODE
void enterEvent(QEnterEvent *event);
#else // FC_QT5_MODE
void enterEvent(QEvent *event);
#endif // FC_QT5_MODE
void leaveEvent(QEvent *event);
void paintEvent(QPaintEvent *event);
void wheelEvent(QWheelEvent *event);
client/gui-qt/sidebar.cpp
/***********************************************************************//**
Mouse entered on widget area
***************************************************************************/
#ifndef FC_QT5_MODE
void fc_sidewidget::enterEvent(QEnterEvent *event)
#else // FC_QT5_MODE
void fc_sidewidget::enterEvent(QEvent *event)
#endif // FC_QT5_MODE
{
if (!hover) {
hover = true;
client/gui-qt/sidebar.h
void some_slot();
protected:
void contextMenuEvent(QContextMenuEvent *event);
#ifndef FC_QT5_MODE
void enterEvent(QEnterEvent *event);
#else // FC_QT5_MODE
void enterEvent(QEvent *event);
#endif // FC_QT5_MODE
void leaveEvent(QEvent *event);
void mousePressEvent(QMouseEvent *event);
void paintEvent(QPaintEvent *event);
client/gui-qt/sprite.cpp
u8"\u24F4"
};
#ifdef FC_QT5_MODE
ns = QString((const char *)numsbuf[num]);
}
w = fm.horizontalAdvance(ns);
h = fm.height();
pm = new QPixmap(w, h);
pm->fill(Qt::transparent);
QPainter paint(pm);
paint.setFont(*qf);
paint.setBrush(Qt::transparent);
paint.setPen(QColor(Qt::black));
paint.drawText(QRect(0, 0, w, h), Qt::AlignLeft | Qt::AlignVCenter,
QString((const char *)u8"\u26AB"));
if (num > 20) {
paint.setPen(QColor(Qt::yellow));
paint.drawText(QRect(-2, 0, w, h), Qt::AlignLeft | Qt::AlignVCenter,
QString((const char *)u8"\u2B24"));
paint.drawText(QRect(4, -2, w, h), Qt::AlignLeft | Qt::AlignVCenter,
QString((const char *)u8"\u2B24"));
paint.drawText(QRect(4, 2, w, h), Qt::AlignLeft | Qt::AlignVCenter,
QString((const char *)u8"\u2B24"));
paint.drawText(QRect(8, 0, w, h), Qt::AlignLeft | Qt::AlignVCenter,
QString((const char *)u8"\u2B24"));
}
#else // FC_QT5_MODE
ns = QString(numsbuf[num]);
}
......
paint.drawText(QRect(8, 0, w, h), Qt::AlignLeft | Qt::AlignVCenter,
QString(u8"\u2B24"));
}
#endif // FC_QT5_MODE
paint.setPen(QColor((num > 20) ? Qt::black : Qt::yellow));
paint.drawText(QRect(0, 0, w, h), Qt::AlignLeft | Qt::AlignVCenter, ns);
tools/fcmp/mpgui_qt.cpp
rev_ver = fc_git_revision();
#ifdef FC_QT5_MODE
mode = R__("built in Qt5 mode.");
#elif defined(FC_QT6X_MODE)
#if defined(FC_QT6X_MODE)
mode = R__("built in Qt6x mode.");
#else // FC_QT5_MODE
#else // FC_QT6X_MODE
mode = R__("built in Qt6 mode.");
#endif // FC_QT5_MODE
#endif // FC_QT6X_MODE
if (rev_ver == nullptr) {
fc_snprintf(verbuf, sizeof(verbuf), "%s%s\n%s", word_version(),
tools/ruledit/ruledit_qt.cpp
rev_ver = fc_git_revision();
#ifdef FC_QT5_MODE
mode = R__("built in Qt5 mode.");
#elif defined(FC_QT6X_MODE)
#if defined(FC_QT6X_MODE)
mode = R__("built in Qt6x mode.");
#else // FC_QT5_MODE
#else // FC_QT6X_MODE
mode = R__("built in Qt6 mode.");
#endif // FC_QT5_MODE
#endif // FC_QT6X_MODE
if (rev_ver == nullptr) {
fc_snprintf(verbuf, sizeof(verbuf), "%s%s\n%s", word_version(),
    (1-1/1)