From fe6976265297ce7329dc30cb61e5942ba5c94fb4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 11 Sep 2024 15:41:04 +0200 Subject: [PATCH 1/4] Qt6: QColor::setNamedColor is deprecated since Qt 6.6 --- src/Gui/MainWindow.cpp | 6 ++---- src/Gui/Splashscreen.cpp | 2 +- src/Gui/View3DPy.cpp | 4 ++-- src/Mod/Spreadsheet/Gui/SheetTableView.cpp | 3 +-- 4 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 25e0222707..7dfcbd03ad 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -2118,8 +2118,7 @@ QPixmap MainWindow::splashImage() const y = h - 20; } - QColor color; - color.setNamedColor(QString::fromLatin1(tc->second.c_str())); + QColor color(QString::fromLatin1(tc->second.c_str())); if (color.isValid()) { painter.setPen(color); painter.setFont(fontExe); @@ -2129,8 +2128,7 @@ QPixmap MainWindow::splashImage() const } painter.setFont(fontVer); painter.drawText(x + (l + 235), y - 7, version); - QColor warningColor; - warningColor.setNamedColor(QString::fromLatin1(wc->second.c_str())); + QColor warningColor(QString::fromLatin1(wc->second.c_str())); if (suffix == QLatin1String("dev") && warningColor.isValid()) { fontVer.setPointSizeF(14.0); painter.setFont(fontVer); diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 28ebd96d39..da6f9e48cf 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -162,7 +162,7 @@ public: // choose text color auto tc = cfg.find("SplashTextColor"); if (tc != cfg.end()) { - QColor col; col.setNamedColor(QString::fromLatin1(tc->second.c_str())); + QColor col(QString::fromStdString(tc->second)); if (col.isValid()) { textColor = col; } diff --git a/src/Gui/View3DPy.cpp b/src/Gui/View3DPy.cpp index 9ec7fb3a07..4936080ce2 100644 --- a/src/Gui/View3DPy.cpp +++ b/src/Gui/View3DPy.cpp @@ -877,7 +877,7 @@ Py::Object View3DInventorPy::saveImage(const Py::Tuple& args) if (colname.compare(QLatin1String("Current"), Qt::CaseInsensitive) == 0) bg = QColor(); // assign an invalid color here else - bg.setNamedColor(colname); + bg = QColor(colname); QImage img; getView3DIventorPtr()->getViewer()->savePicture(w, h, s, bg, img); @@ -926,7 +926,7 @@ Py::Object View3DInventorPy::saveVectorGraphic(const Py::Tuple& args) if (colname.compare(QLatin1String("Current"), Qt::CaseInsensitive) == 0) bg = getView3DIventorPtr()->getViewer()->backgroundColor(); else - bg.setNamedColor(colname); + bg = QColor(colname); getView3DIventorPtr()->getViewer()->saveGraphic(ps,bg,vo.get()); out->closeFile(); diff --git a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp index fb57a8f85c..3a9f33585c 100644 --- a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp @@ -1159,8 +1159,7 @@ QString SheetTableView::toHtml() const boldFont.setBold(true); boldFormat.setFont(boldFont); - QColor bgColor; - bgColor.setNamedColor(QLatin1String("#f0f0f0")); + QColor bgColor(QLatin1String("#f0f0f0")); QTextCharFormat bgFormat; bgFormat.setBackground(QBrush(bgColor)); From 10a5d67109736555725ad9399e51715804d543af Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 11 Sep 2024 16:33:19 +0200 Subject: [PATCH 2/4] Qt6: Several methods of QMouseEvent are deprecated since Qt 6.0 --- src/Gui/ToolBarManager.cpp | 4 ++++ .../PathSimulator/AppGL/DlgCAMSimulator.cpp | 24 +++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/Gui/ToolBarManager.cpp b/src/Gui/ToolBarManager.cpp index eb8c4d50f4..ee01114b36 100644 --- a/src/Gui/ToolBarManager.cpp +++ b/src/Gui/ToolBarManager.cpp @@ -308,7 +308,11 @@ void ToolBarGrip::mouseMoveEvent(QMouseEvent *me) return; } +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) QPoint pos = me->globalPos(); +#else + QPoint pos = me->globalPosition().toPoint(); +#endif QRect rect(toolbar->mapToGlobal(QPoint(0,0)), toolbar->size()); // if mouse did not leave the area of toolbar do not continue with undocking it diff --git a/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp b/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp index 6bf28fa2d0..14efe387a4 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp @@ -36,7 +36,7 @@ using namespace MillSim; namespace CAMSimulator { -static const float MouseScrollDelta = 120.0f; +static const float MouseScrollDelta = 120.0F; DlgCAMSimulator::DlgCAMSimulator(QWindow* parent) : QWindow(parent) @@ -86,17 +86,33 @@ void DlgCAMSimulator::mouseMoveEvent(QMouseEvent* ev) int modifiers = (ev->modifiers() & Qt::ShiftModifier) != 0 ? MS_KBD_SHIFT : 0; modifiers |= (ev->modifiers() & Qt::ControlModifier) != 0 ? MS_KBD_CONTROL : 0; modifiers |= (ev->modifiers() & Qt::AltModifier) != 0 ? MS_KBD_ALT : 0; - mMillSimulator->MouseMove(ev->x(), ev->y(), modifiers); + +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QPoint pnt = ev->pos(); +#else + QPoint pnt = ev->position().toPoint(); +#endif + mMillSimulator->MouseMove(pnt.x(), pnt.y(), modifiers); } void DlgCAMSimulator::mousePressEvent(QMouseEvent* ev) { - mMillSimulator->MousePress(ev->button(), true, ev->x(), ev->y()); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QPoint pnt = ev->pos(); +#else + QPoint pnt = ev->position().toPoint(); +#endif + mMillSimulator->MousePress(ev->button(), true, pnt.x(), pnt.y()); } void DlgCAMSimulator::mouseReleaseEvent(QMouseEvent* ev) { - mMillSimulator->MousePress(ev->button(), false, ev->x(), ev->y()); +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QPoint pnt = ev->pos(); +#else + QPoint pnt = ev->position().toPoint(); +#endif + mMillSimulator->MousePress(ev->button(), false, pnt.x(), pnt.y()); } void DlgCAMSimulator::wheelEvent(QWheelEvent* ev) From 36db6a98cb9c760ad6877b3da2b282a9c471fd27 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 11 Sep 2024 16:34:59 +0200 Subject: [PATCH 3/4] Qt6: QLocale::countryToString and QLocale::country() are deprecated since Qt 6.6 --- src/Gui/Splashscreen.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index da6f9e48cf..da3241dc18 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -871,12 +871,20 @@ void AboutDialog::copyToClipboard() #endif QLocale loc; str << "Locale: " << QLocale::languageToString(loc.language()) << "/" +#if QT_VERSION < QT_VERSION_CHECK(6,6,0) << QLocale::countryToString(loc.country()) +#else + << QLocale::territoryToString(loc.territory()) +#endif << " (" << loc.name() << ")"; if (loc != QLocale::system()) { loc = QLocale::system(); str << " [ OS: " << QLocale::languageToString(loc.language()) << "/" +#if QT_VERSION < QT_VERSION_CHECK(6,6,0) << QLocale::countryToString(loc.country()) +#else + << QLocale::territoryToString(loc.territory()) +#endif << " (" << loc.name() << ") ]"; } str << "\n"; From 9d040467ac8a4071db89d6b98b47dc03c7dba362 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:39:16 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp b/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp index 14efe387a4..5163786f8a 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp @@ -87,7 +87,7 @@ void DlgCAMSimulator::mouseMoveEvent(QMouseEvent* ev) modifiers |= (ev->modifiers() & Qt::ControlModifier) != 0 ? MS_KBD_CONTROL : 0; modifiers |= (ev->modifiers() & Qt::AltModifier) != 0 ? MS_KBD_ALT : 0; -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QPoint pnt = ev->pos(); #else QPoint pnt = ev->position().toPoint(); @@ -97,7 +97,7 @@ void DlgCAMSimulator::mouseMoveEvent(QMouseEvent* ev) void DlgCAMSimulator::mousePressEvent(QMouseEvent* ev) { -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QPoint pnt = ev->pos(); #else QPoint pnt = ev->position().toPoint(); @@ -107,7 +107,7 @@ void DlgCAMSimulator::mousePressEvent(QMouseEvent* ev) void DlgCAMSimulator::mouseReleaseEvent(QMouseEvent* ev) { -#if QT_VERSION < QT_VERSION_CHECK(6,0,0) +#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) QPoint pnt = ev->pos(); #else QPoint pnt = ev->position().toPoint();