From a999a249e355a656252eea3e86d9eaea5abdfa63 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 19 Mar 2022 23:27:28 +0100 Subject: [PATCH] Qt: remove some more leftovers of Qt4 --- src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h | 12 ++----- src/Gui/3Dconnexion/GuiNativeEventWin32.h | 2 -- src/Gui/Assistant.cpp | 7 ---- src/Gui/DlgPropertyLink.cpp | 4 --- src/Gui/SoFCOffscreenRenderer.cpp | 13 ------- src/Gui/SoFCOffscreenRenderer.h | 4 --- src/Gui/View3DInventorViewer.cpp | 6 ---- src/Gui/Widgets.cpp | 36 ------------------- src/Mod/Draft/draftutils/translate.py | 5 ++- src/Mod/Drawing/Gui/DrawingView.h | 9 ----- src/Mod/Image/Gui/ImageView.cpp | 4 --- src/Mod/Mesh/Gui/MeshSelection.cpp | 3 +- .../PartDesign/Gui/TaskFeatureParameters.cpp | 4 --- 13 files changed, 6 insertions(+), 103 deletions(-) diff --git a/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h b/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h index 9166709a23..66633ff83c 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h +++ b/src/Gui/3Dconnexion/GuiNativeEventLinuxX11.h @@ -26,11 +26,9 @@ #include "GuiAbstractNativeEvent.h" #include -#if QT_VERSION >= 0x050000 - #include - #include - #include -#endif +#include +#include +#include class QMainWindow; class GUIApplicationNativeEventAware; @@ -51,11 +49,7 @@ namespace Gui GuiNativeEvent(const GuiNativeEvent&); GuiNativeEvent& operator=(const GuiNativeEvent&); public: - #if QT_VERSION >= 0x050000 static bool xcbEventFilter(void *message, long* result); - #else - bool x11EventFilter(XEvent *event); - #endif // if/else QT_VERSION >= 0x050000 }; } diff --git a/src/Gui/3Dconnexion/GuiNativeEventWin32.h b/src/Gui/3Dconnexion/GuiNativeEventWin32.h index 62fc8a57bf..59602e5cb1 100644 --- a/src/Gui/3Dconnexion/GuiNativeEventWin32.h +++ b/src/Gui/3Dconnexion/GuiNativeEventWin32.h @@ -31,9 +31,7 @@ //#define _WIN32_WINNT 0x0501 //target at least windows XP #include -#if QT_VERSION >= 0x050000 #include "GuiRawInputEventFilter.h" -#endif class QMainWindow; class GUIApplicationNativeEventAware; diff --git a/src/Gui/Assistant.cpp b/src/Gui/Assistant.cpp index 421a81ac7d..e55202f0fc 100644 --- a/src/Gui/Assistant.cpp +++ b/src/Gui/Assistant.cpp @@ -67,13 +67,6 @@ void Assistant::showDocumentation(const QString &page) bool Assistant::startAssistant() { -#if QT_VERSION < 0x040400 - QMessageBox::critical(0, QObject::tr("Help"), - QObject::tr("Unable to load documentation.\n" - "In order to load it Qt 4.4 or higher is required.")); - return false; -#endif - if (!proc) { proc = new QProcess(); connect(proc, SIGNAL(readyReadStandardOutput()), diff --git a/src/Gui/DlgPropertyLink.cpp b/src/Gui/DlgPropertyLink.cpp index a74e06c1e3..41fd0ad56d 100644 --- a/src/Gui/DlgPropertyLink.cpp +++ b/src/Gui/DlgPropertyLink.cpp @@ -293,11 +293,7 @@ void DlgPropertyLink::init(const App::DocumentObjectT &prop, bool tryFilter) { ui->treeWidget->setColumnCount(2); // make sure to show a horizontal scrollbar if needed -#if QT_VERSION >= 0x050000 ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -#else - ui->treeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); -#endif } std::set expandDocs; diff --git a/src/Gui/SoFCOffscreenRenderer.cpp b/src/Gui/SoFCOffscreenRenderer.cpp index 65dc378ea7..be4d923140 100644 --- a/src/Gui/SoFCOffscreenRenderer.cpp +++ b/src/Gui/SoFCOffscreenRenderer.cpp @@ -413,7 +413,6 @@ void SoQtOffscreenRenderer::init(const SbViewportRegion & vpr, //this->texFormat = GL_RGBA32F_ARB; this->texFormat = GL_RGB32F_ARB; this->cache_context = 0; - this->pbuffer = false; } /*! @@ -537,18 +536,6 @@ SoQtOffscreenRenderer::internalTextureFormat() const return PRIVATE(this)->texFormat; } -void -SoQtOffscreenRenderer::setPbufferEnable(SbBool enable) -{ - PRIVATE(this)->pbuffer = enable; -} - -SbBool -SoQtOffscreenRenderer::getPbufferEnable(void) const -{ - return PRIVATE(this)->pbuffer; -} - // ************************************************************************* void diff --git a/src/Gui/SoFCOffscreenRenderer.h b/src/Gui/SoFCOffscreenRenderer.h index b46c4610e9..36b35c55f9 100644 --- a/src/Gui/SoFCOffscreenRenderer.h +++ b/src/Gui/SoFCOffscreenRenderer.h @@ -121,9 +121,6 @@ public: void setInternalTextureFormat(GLenum internalTextureFormat); GLenum internalTextureFormat() const; - void setPbufferEnable(SbBool enable); - SbBool getPbufferEnable(void) const; - SbBool render(SoNode * scene); SbBool render(SoPath * scene); @@ -144,7 +141,6 @@ private: SbColor4f backgroundopaque; SoGLRenderAction * renderaction; SbBool didallocation; - SbBool pbuffer; int numSamples; GLenum texFormat; QImage glImage; diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index f4d49663ab..5799af4ab0 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -1501,14 +1501,12 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI // Save picture methods: // FramebufferObject -- viewer renders into FBO (no offscreen) // CoinOffscreenRenderer -- Coin's offscreen rendering method - // PixelBuffer -- Qt's pixel buffer used for offscreen rendering (only Qt4) // Otherwise (Default) -- Qt's FBO used for offscreen rendering std::string saveMethod = App::GetApplication().GetParameterGroupByPath ("User parameter:BaseApp/Preferences/View")->GetASCII("SavePicture"); bool useFramebufferObject = false; bool useGrabFramebuffer = false; - bool usePixelBuffer = false; bool useCoinOffscreenRenderer = false; if (saveMethod == "FramebufferObject") { useFramebufferObject = true; @@ -1516,9 +1514,6 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI else if (saveMethod == "GrabFramebuffer") { useGrabFramebuffer = true; } - else if (saveMethod == "PixelBuffer") { - usePixelBuffer = true; - } else if (saveMethod == "CoinOffscreenRenderer") { useCoinOffscreenRenderer = true; } @@ -1607,7 +1602,6 @@ void View3DInventorViewer::savePicture(int w, int h, int s, const QColor& bg, QI SoQtOffscreenRenderer renderer(vp); renderer.setNumPasses(s); renderer.setInternalTextureFormat(getInternalTextureFormat()); - renderer.setPbufferEnable(usePixelBuffer); if (bgColor.isValid()) renderer.setBackgroundColor(SbColor4f(bgColor.redF(), bgColor.greenF(), bgColor.blueF(), bgColor.alphaF())); if (!renderer.render(root)) diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 3a71d700f5..866a1dda83 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -522,7 +522,6 @@ void ModifierLineEdit::keyPressEvent (QKeyEvent * e) // ------------------------------------------------------------------------------ -#if QT_VERSION >= 0x050200 ClearLineEdit::ClearLineEdit (QWidget * parent) : QLineEdit(parent) { @@ -542,41 +541,6 @@ void ClearLineEdit::updateClearButton(const QString& text) { clearAction->setVisible(!text.isEmpty()); } -#else -ClearLineEdit::ClearLineEdit (QWidget * parent) - : QLineEdit(parent) -{ - clearButton = new QToolButton(this); - QPixmap pixmap(BitmapFactory().pixmapFromSvg(":/icons/edit-cleartext.svg", QSize(18, 18))); - clearButton->setIcon(QIcon(pixmap)); - clearButton->setIconSize(pixmap.size()); - clearButton->setCursor(Qt::ArrowCursor); - clearButton->setStyleSheet(QString::fromLatin1("QToolButton { border: none; padding: 0px; }")); - clearButton->hide(); - connect(clearButton, SIGNAL(clicked()), this, SLOT(clear())); - connect(this, SIGNAL(textChanged(const QString&)), - this, SLOT(updateClearButton(const QString&))); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px; } ") - .arg(clearButton->sizeHint().width() + frameWidth + 1)); - QSize msz = minimumSizeHint(); - setMinimumSize(qMax(msz.width(), clearButton->sizeHint().height() + frameWidth * 2 + 2), - msz.height()); -} - -void ClearLineEdit::resizeEvent(QResizeEvent *) -{ - QSize sz = clearButton->sizeHint(); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - clearButton->move(rect().right() - frameWidth - sz.width(), - (rect().bottom() + 1 - sz.height())/2); -} - -void ClearLineEdit::updateClearButton(const QString& text) -{ - clearButton->setVisible(!text.isEmpty()); -} -#endif // ------------------------------------------------------------------------------ diff --git a/src/Mod/Draft/draftutils/translate.py b/src/Mod/Draft/draftutils/translate.py index 5d2b3c56de..2e0cbebb66 100644 --- a/src/Mod/Draft/draftutils/translate.py +++ b/src/Mod/Draft/draftutils/translate.py @@ -109,9 +109,8 @@ def translate(context, text, utf8_decode=False): # Python 3 and Qt5 # The text is a utf8 string, and since it is Qt5 # the translate function doesn't use the 4th parameter - if six.PY3: - return Qtranslate(context, text, None) - + return Qtranslate(context, text, None) + # Original code no longer used. It is listed here for reference # to show how the different pairings Py2/Qt4, Py3/Qt5, Py2/Qt5, Py3/Qt4 diff --git a/src/Mod/Drawing/Gui/DrawingView.h b/src/Mod/Drawing/Gui/DrawingView.h index 8683a862d8..18a0d6479a 100644 --- a/src/Mod/Drawing/Gui/DrawingView.h +++ b/src/Mod/Drawing/Gui/DrawingView.h @@ -107,11 +107,7 @@ protected: void contextMenuEvent(QContextMenuEvent *event); void closeEvent(QCloseEvent*); void findPrinterSettings(const QString&); -#if QT_VERSION >= 0x050300 QPageSize::PageSizeId getPageSize(int w, int h) const; -#else - QPrinter::PageSize getPageSize(int w, int h) const; -#endif private: QAction *m_nativeAction; @@ -125,13 +121,8 @@ private: std::string m_objectName; QString m_currentPath; -#if QT_VERSION >= 0x050300 QPageLayout::Orientation m_orientation; QPageSize::PageSizeId m_pageSize; -#else - QPrinter::Orientation m_orientation; - QPrinter::PageSize m_pageSize; -#endif }; } // namespace DrawingViewGui diff --git a/src/Mod/Image/Gui/ImageView.cpp b/src/Mod/Image/Gui/ImageView.cpp index bb8ee34b14..b2a65e8cb3 100644 --- a/src/Mod/Image/Gui/ImageView.cpp +++ b/src/Mod/Image/Gui/ImageView.cpp @@ -482,11 +482,7 @@ void ImageView::wheelEvent(QWheelEvent * cEvent) #endif // Zoom around centrally displayed image point -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) int numTicks = cEvent->angleDelta().y() / 120; -#else - int numTicks = cEvent->delta() / 120; -#endif if (_invertZoom) numTicks = -numTicks; diff --git a/src/Mod/Mesh/Gui/MeshSelection.cpp b/src/Mod/Mesh/Gui/MeshSelection.cpp index 2f7b3a7d09..319c3bd07f 100644 --- a/src/Mod/Mesh/Gui/MeshSelection.cpp +++ b/src/Mod/Mesh/Gui/MeshSelection.cpp @@ -220,9 +220,8 @@ void MeshSelection::prepareFreehandSelection(bool add,SoEventCallbackCB *cb) QCursor custom(cursor, mask, CROSS_HOT_X, CROSS_HOT_Y); viewer->setComponentCursor(custom); }; -#if (QT_VERSION >= 0x050000) + QObject::connect(viewer, &Gui::View3DInventorViewer::devicePixelRatioChanged, setComponentCursor); -#endif setComponentCursor(); this->addToSelection = add; } diff --git a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp index e015a90b20..fafbde66a7 100644 --- a/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskFeatureParameters.cpp @@ -129,11 +129,7 @@ bool TaskDlgFeatureParameters::accept() { Gui::Command::commitCommand(); } catch (const Base::Exception& e) { // Generally the only thing that should fail is feature->isValid() others should be fine -#if (QT_VERSION >= 0x050000) QString errorText = QApplication::translate(feature->getTypeId().getName(), e.what()); -#else - QString errorText = QApplication::translate(feature->getTypeId().getName(), e.what(), 0, QApplication::UnicodeUTF8); -#endif QMessageBox::warning(Gui::getMainWindow(), tr("Input error"), errorText); return false; }