Bug #735 ยป 0005-Qt-Avoid-deprecated-QMouseEvent-globalPos-in-Qt6-mod.patch
client/gui-qt/citydlg.cpp | ||
---|---|---|
#include "text.h"
|
||
#include "tilespec.h"
|
||
//gui-qt
|
||
// gui-qt
|
||
#include "citydlg.h"
|
||
#include "colors.h"
|
||
#include "fc_client.h"
|
||
... | ... | |
help_event = static_cast<QHelpEvent *>(ev);
|
||
QPoint pos = help_event->pos();
|
||
QModelIndex index = view->indexAt(pos);
|
||
QPoint hpos;
|
||
if (!index.isValid()) {
|
||
return false;
|
||
... | ... | |
item_tooltip = view->model()->data(index, Qt::ToolTipRole).toString();
|
||
rect = view->visualRect(index);
|
||
rect.setX(rect.x() + help_event->globalPos().x());
|
||
rect.setY(rect.y() + help_event->globalPos().y());
|
||
hpos = help_event->globalPos();
|
||
rect.setX(rect.x() + hpos.x());
|
||
rect.setY(rect.y() + hpos.y());
|
||
if (!item_tooltip.isEmpty()) {
|
||
QToolTip::showText(help_event->globalPos(), item_tooltip, view, rect);
|
client/gui-qt/dialogs.cpp | ||
---|---|---|
void qfc_dialog::mouseMoveEvent(QMouseEvent *event)
|
||
{
|
||
if (moving_now) {
|
||
move(event->globalPos() - point);
|
||
move(mevent_gpos(event) - point);
|
||
}
|
||
}
|
||
... | ... | |
if (y <= titlebar_height
|
||
&& x <= width() - close_pix.width()) {
|
||
point = event->globalPos() - geometry().topLeft();
|
||
point = mevent_gpos(event) - geometry().topLeft();
|
||
moving_now = true;
|
||
setCursor(Qt::SizeAllCursor);
|
||
} else if (y <= titlebar_height
|
||
... | ... | |
***************************************************************************/
|
||
void notify_dialog::mousePressEvent(QMouseEvent *event)
|
||
{
|
||
cursor = event->globalPos() - geometry().topLeft();
|
||
cursor = mevent_gpos(event) - geometry().topLeft();
|
||
if (event->button() == Qt::RightButton) {
|
||
was_destroyed = true;
|
||
close();
|
||
... | ... | |
***************************************************************************/
|
||
void notify_dialog::mouseMoveEvent(QMouseEvent *event)
|
||
{
|
||
move(event->globalPos() - cursor);
|
||
move(mevent_gpos(event) - cursor);
|
||
setCursor(Qt::SizeAllCursor);
|
||
}
|
||
client/gui-qt/gui_main.h | ||
---|---|---|
#define CAPTURE_DEFAULT_THIS [=]
|
||
#endif // FREECIV_HAVE_CXX20_CAPTURE_THIS
|
||
// 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
|
||
#endif // FC__GUI_MAIN_H
|
client/gui-qt/mapview.cpp | ||
---|---|---|
// gui-qt
|
||
#include "colors.h"
|
||
#include "fc_client.h"
|
||
#include "qtg_cxxside.h"
|
||
#include "gui_main.h"
|
||
#include "mapview.h"
|
||
#include "qtg_cxxside.h"
|
||
#include "sidebar.h"
|
||
const char *get_timeout_label_text();
|
||
... | ... | |
void move_widget::mouseMoveEvent(QMouseEvent *event)
|
||
{
|
||
if (!gui()->interface_locked) {
|
||
parentWidget()->move(event->globalPos() - point);
|
||
parentWidget()->move(mevent_gpos(event) - point);
|
||
}
|
||
}
|
||
/**********************************************************************//**
|
||
Sets moving point for move widget;
|
||
Sets moving point for move widget
|
||
**************************************************************************/
|
||
void move_widget::mousePressEvent(QMouseEvent* event)
|
||
void move_widget::mousePressEvent(QMouseEvent *event)
|
||
{
|
||
if (!gui()->interface_locked) {
|
||
point = event->globalPos() - parentWidget()->geometry().topLeft();
|
||
point = mevent_gpos(event) - parentWidget()->geometry().topLeft();
|
||
}
|
||
update();
|
||
}
|
||
... | ... | |
/**********************************************************************//**
|
||
Mouse handler for resize widget (resizes parent widget)
|
||
**************************************************************************/
|
||
void resize_widget::mouseMoveEvent(QMouseEvent * event)
|
||
void resize_widget::mouseMoveEvent(QMouseEvent *event)
|
||
{
|
||
QPoint qp, np;
|
||
if (gui()->interface_locked) {
|
||
return;
|
||
}
|
||
qp = event->globalPos();
|
||
qp = mevent_gpos(event);
|
||
np.setX(qp.x() - point.x());
|
||
np.setY(qp.y() - point.y());
|
||
np.setX(qMax(np.x(), 32));
|
||
... | ... | |
/**********************************************************************//**
|
||
Sets moving point for resize widget;
|
||
**************************************************************************/
|
||
void resize_widget::mousePressEvent(QMouseEvent* event)
|
||
void resize_widget::mousePressEvent(QMouseEvent *event)
|
||
{
|
||
QPoint qp;
|
||
if (gui()->interface_locked) {
|
||
return;
|
||
}
|
||
qp = event->globalPos();
|
||
qp = mevent_gpos(event);
|
||
point.setX(qp.x() - parentWidget()->width());
|
||
point.setY(qp.y() - parentWidget()->height());
|
||
update();
|
||
... | ... | |
Right button - recenters on some point
|
||
For wheel look mouseWheelEvent
|
||
**************************************************************************/
|
||
void minimap_view::mousePressEvent(QMouseEvent * event)
|
||
void minimap_view::mousePressEvent(QMouseEvent *event)
|
||
{
|
||
int fx, fy;
|
||
int x, y;
|
||
... | ... | |
if (gui()->interface_locked) {
|
||
return;
|
||
}
|
||
cursor = event->globalPos() - geometry().topLeft();
|
||
cursor = mevent_gpos(event) - geometry().topLeft();
|
||
}
|
||
if (event->button() == Qt::RightButton) {
|
||
cursor = event->pos();
|
||
fx = event->pos().x();
|
||
... | ... | |
center_tile_mapcanvas(map_pos_to_tile(&(wld.map), x, y));
|
||
update_image();
|
||
}
|
||
event->setAccepted(true);
|
||
}
|
||
/**********************************************************************//**
|
||
Called when mouse button was pressed. Used to moving minimap.
|
||
**************************************************************************/
|
||
void minimap_view::mouseMoveEvent(QMouseEvent* event)
|
||
void minimap_view::mouseMoveEvent(QMouseEvent *event)
|
||
{
|
||
if (gui()->interface_locked) {
|
||
return;
|
||
}
|
||
if (event->buttons() & Qt::LeftButton) {
|
||
QPoint p, r;
|
||
p = event->pos();
|
||
r = mapTo(gui()->mapview_wdg, p);
|
||
p = r - p;
|
||
move(event->globalPos() - cursor);
|
||
move(mevent_gpos(event) - 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 | ||
---|---|---|
// gui-qt
|
||
#include "fc_client.h"
|
||
#include "gui_main.h"
|
||
#include "messagewin.h"
|
||
#include "qtg_cxxside.h"
|
||
#include "sprite.h"
|
||
... | ... | |
int x = pos.x();
|
||
int y = pos.y();
|
||
cursor = event->globalPos() - geometry().topLeft();
|
||
cursor = mevent_gpos(event) - geometry().topLeft();
|
||
if (y > 0 && y < 25 && x > width() - 25 && x < width()) {
|
||
resize_mode = true;
|
||
resxy = true;
|
||
... | ... | |
/***********************************************************************//**
|
||
Restores cursor when resizing is done
|
||
***************************************************************************/
|
||
void info_tab::mouseReleaseEvent(QMouseEvent* event)
|
||
void info_tab::mouseReleaseEvent(QMouseEvent *event)
|
||
{
|
||
QPoint p;
|
||
if (gui()->interface_locked) {
|
||
return;
|
||
}
|
||
if (resize_mode) {
|
||
resize_mode = false;
|
||
resx = false;
|
||
... | ... | |
int newheight = event->globalY() - cursor.y() - geometry().y();
|
||
resize(width(), this->geometry().height()-newheight);
|
||
to_move = event->globalPos() - cursor;
|
||
to_move = mevent_gpos(event) - cursor;
|
||
move(this->x(), to_move.y());
|
||
setCursor(Qt::SizeVerCursor);
|
||
restore_chat();
|
||
... | ... | |
int newheight = event->globalY() - cursor.y() - geometry().y();
|
||
resize(ex, this->geometry().height()- newheight);
|
||
to_move = event->globalPos() - cursor;
|
||
to_move = mevent_gpos(event) - cursor;
|
||
move(this->x(), to_move.y());
|
||
setCursor(Qt::SizeBDiagCursor);
|
||
restore_chat();
|
client/gui-qt/repodlgs.cpp | ||
---|---|---|
// client
|
||
#include "client_main.h"
|
||
#include "gui_main.h"
|
||
#include "helpdata.h"
|
||
#include "options.h"
|
||
#include "repodlgs_common.h"
|
||
... | ... | |
tt_text = def_str + tt_text.toHtmlEscaped();
|
||
tooltip_text = tt_text.trimmed();
|
||
tooltip_rect = rttp->rect;
|
||
tooltip_pos = event->globalPos();
|
||
tooltip_pos = mevent_gpos(event);
|
||
if (!QToolTip::isVisible() && !timer_active) {
|
||
timer_active = true;
|
||
QTimer::singleShot(500, this, SLOT(show_tooltip()));
|