From a90f2a43691e58b39b3ac5bdb3ba8c9129c82940 Mon Sep 17 00:00:00 2001 From: Aaron Colwell <300262+acolwell@users.noreply.github.com> Date: Tue, 19 Mar 2024 20:28:16 -0700 Subject: [PATCH] Remove Qt4 code in Gui/ and Tests/ --- Gui/AboutWindow.cpp | 13 ------ Gui/ComboBox.cpp | 29 ------------- Gui/CurveGui.cpp | 2 - Gui/CurveWidget.cpp | 50 +-------------------- Gui/CurveWidget.h | 4 -- Gui/CurveWidgetPrivate.cpp | 19 -------- Gui/CustomParamInteract.cpp | 17 -------- Gui/CustomParamInteract.h | 4 -- Gui/DocumentationManager.cpp | 14 +----- Gui/DopeSheetEditor.h | 4 -- Gui/DopeSheetHierarchyView.cpp | 26 +---------- Gui/DopeSheetHierarchyView.h | 6 +-- Gui/DopeSheetView.cpp | 45 +------------------ Gui/DopeSheetView.h | 4 -- Gui/Edge.cpp | 32 ++------------ Gui/EditScriptDialog.cpp | 4 -- Gui/FileTypeMainWindow_win.cpp | 23 ---------- Gui/FileTypeMainWindow_win.h | 4 -- Gui/FloatingWidget.cpp | 11 +---- Gui/Gui.h | 6 --- Gui/Gui10.cpp | 9 ---- Gui/Gui40.cpp | 19 -------- Gui/Gui50.cpp | 29 ------------- Gui/GuiAppInstance.cpp | 22 ---------- Gui/GuiApplicationManager.cpp | 9 ---- Gui/GuiApplicationManager10.cpp | 21 +-------- Gui/GuiFwd.h | 5 --- Gui/GuiPrivate.cpp | 15 ------- Gui/GuiPrivate.h | 5 +-- Gui/Histogram.cpp | 45 ------------------- Gui/Histogram.h | 4 -- Gui/HostOverlay.cpp | 5 --- Gui/InfoViewerWidget.cpp | 32 -------------- Gui/KnobGui20.cpp | 4 -- Gui/KnobGuiString.cpp | 4 -- Gui/KnobGuiTable.cpp | 5 --- Gui/KnobWidgetDnD.cpp | 4 -- Gui/Label.h | 8 ---- Gui/MultiInstancePanel.cpp | 13 ------ Gui/NodeGraph25.cpp | 8 ---- Gui/NodeGraph30.cpp | 9 ---- Gui/NodeGui.cpp | 16 ------- Gui/NodeSettingsPanel.cpp | 4 -- Gui/PreferencesPanel.cpp | 17 -------- Gui/PythonPanels.cpp | 2 - Gui/PythonPanels.h | 2 - Gui/QGLExtrasCompat.h | 42 ------------------ Gui/QGLWidgetCompat.h | 39 ----------------- Gui/QtColorTriangle.cpp | 4 -- Gui/QtMac.mm | 12 ----- Gui/RenderStatsDialog.cpp | 5 --- Gui/RotoPanel.cpp | 12 ----- Gui/ScaleSliderQWidget.cpp | 12 ----- Gui/ScriptEditor.cpp | 5 --- Gui/ScriptTextEdit.cpp | 4 -- Gui/SequenceFileDialog.cpp | 17 -------- Gui/SpinBox.cpp | 9 ---- Gui/SplashScreen.cpp | 36 --------------- Gui/TabWidget.cpp | 13 ------ Gui/TableModelView.cpp | 24 ---------- Gui/TableModelView.h | 5 --- Gui/TextRenderer.cpp | 30 ------------- Gui/TimeLineGui.cpp | 21 --------- Gui/TimeLineGui.h | 4 -- Gui/TrackerPanel.cpp | 4 -- Gui/VerticalColorBar.h | 4 -- Gui/ViewerGL.cpp | 77 ++------------------------------- Gui/ViewerGL.h | 4 -- Gui/ViewerGLPrivate.cpp | 23 +--------- Gui/ViewerGLPrivate.h | 5 --- Gui/ViewerTab.cpp | 24 ---------- Gui/ViewerTab10.cpp | 8 ---- Tests/KnobFile_Test.cpp | 14 ------ 73 files changed, 19 insertions(+), 1071 deletions(-) delete mode 100644 Gui/QGLExtrasCompat.h delete mode 100644 Gui/QGLWidgetCompat.h diff --git a/Gui/AboutWindow.cpp b/Gui/AboutWindow.cpp index 2dfb8082ac..e7827a1281 100644 --- a/Gui/AboutWindow.cpp +++ b/Gui/AboutWindow.cpp @@ -64,15 +64,6 @@ AboutWindow::AboutWindow(QWidget* parent) : QDialog(parent) { _scale = 1.; -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#if defined(Q_OS_WIN) - // code from Gui::devicePixelRatio() - HDC wscreen = GetDC(winId()); - FLOAT horizontalDPI = GetDeviceCaps(wscreen, LOGPIXELSX); - ReleaseDC(0, wscreen); - _scale = static_cast(horizontalDPI) / 96.; -#endif -#endif setWindowTitle( tr("About %1").arg( QString::fromUtf8(NATRON_APPLICATION_NAME) ) ); _mainLayout = new QVBoxLayout(this); @@ -498,11 +489,7 @@ AboutWindow::AboutWindow(QWidget* parent) _view->setUniformRowHeights(true); _view->setSelectionMode(QAbstractItemView::SingleSelection); _view->header()->close(); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _view->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _view->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif _view->header()->setStretchLastSection(true); splitter->addWidget(_view); diff --git a/Gui/ComboBox.cpp b/Gui/ComboBox.cpp index cbd2a45be5..a8c67678d0 100644 --- a/Gui/ComboBox.cpp +++ b/Gui/ComboBox.cpp @@ -139,11 +139,7 @@ ComboBox::sizeForWidth(int w) const int hextra = DROP_DOWN_ICON_SIZE * 2, vextra = 0; ///Indent of 1 character -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int indent = fm.horizontalAdvance( QLatin1Char('x') ); -#else - int indent = fm.width( QLatin1Char('x') ); -#endif if (indent > 0) { if ( (align & Qt::AlignLeft) || (align & Qt::AlignRight) ) { @@ -243,11 +239,7 @@ ComboBox::layoutRect() const { QRect cr = contentsRect(); Qt::Alignment align = QStyle::visualAlignment( Qt::LeftToRight, QFlag(_align) ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int indent = fontMetrics().horizontalAdvance( QLatin1Char('x') ) / 2; -#else - int indent = fontMetrics().width( QLatin1Char('x') ) / 2; -#endif if (indent > 0) { if (align & Qt::AlignLeft) { @@ -414,11 +406,7 @@ ComboBox::wheelEvent(QWheelEvent *e) return; } // a standard wheel click is 120 -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) _currentDelta += e->angleDelta().y(); -#else - _currentDelta += e->delta(); -#endif if ( (_currentDelta <= -120) || (120 <= _currentDelta) ) { int c = count(); @@ -733,11 +721,7 @@ ComboBox::setCurrentText_internal(const QString & text) } if (_sizePolicy.horizontalPolicy() != QSizePolicy::Fixed) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int w = m.horizontalAdvance(str) + 2 * DROP_DOWN_ICON_SIZE; -#else - int w = m.width(str) + 2 * DROP_DOWN_ICON_SIZE; -#endif setMinimumWidth(w); } @@ -757,11 +741,7 @@ ComboBox::setMaximumWidthFromText(const QString & str) if (_sizePolicy.horizontalPolicy() == QSizePolicy::Fixed) { return; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int w = fontMetrics().horizontalAdvance(str); -#else - int w = fontMetrics().width(str); -#endif setMaximumWidth(w + DROP_DOWN_ICON_SIZE * 2); } @@ -771,12 +751,7 @@ ComboBox::growMaximumWidthFromText(const QString & str) if (_sizePolicy.horizontalPolicy() == QSizePolicy::Fixed) { return; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int w = fontMetrics().horizontalAdvance(str) + 2 * DROP_DOWN_ICON_SIZE; -#else - int w = fontMetrics().width(str) + 2 * DROP_DOWN_ICON_SIZE; -#endif - if ( w > maximumWidth() ) { setMaximumWidth(w); } @@ -865,11 +840,7 @@ ComboBox::setCurrentIndex_internal(int index) if (_sizePolicy.horizontalPolicy() != QSizePolicy::Fixed) { QFontMetrics m = fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int w = m.horizontalAdvance(str) + 2 * DROP_DOWN_ICON_SIZE; -#else - int w = m.width(str) + 2 * DROP_DOWN_ICON_SIZE; -#endif setMinimumWidth(w); } diff --git a/Gui/CurveGui.cpp b/Gui/CurveGui.cpp index 511fad9653..0452af3ae4 100644 --- a/Gui/CurveGui.cpp +++ b/Gui/CurveGui.cpp @@ -46,9 +46,7 @@ #include "Gui/CurveWidgetPrivate.h" #include "Gui/KnobGui.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif NATRON_NAMESPACE_ENTER diff --git a/Gui/CurveWidget.cpp b/Gui/CurveWidget.cpp index a57ede41dc..9fe4a612ec 100644 --- a/Gui/CurveWidget.cpp +++ b/Gui/CurveWidget.cpp @@ -38,15 +38,8 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #include -#else -#include -#endif - -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#endif #include "Engine/Bezier.h" #include "Engine/PyParameter.h" // IntParam @@ -71,9 +64,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/TabWidget.h" #include "Gui/ViewerGL.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif NATRON_NAMESPACE_ENTER @@ -122,11 +113,7 @@ CurveWidget::CurveWidget(Gui* gui, TimeLinePtr timeline, QWidget* parent, const QOpenGLWidget* shareWidget) -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) : QOpenGLWidget(parent) -#else - : QOpenGLWidget(parent, shareWidget) -#endif , _imp( new CurveWidgetPrivate(gui, selection, timeline, this) ) { // always running in the main thread @@ -444,11 +431,7 @@ CurveWidget::swapOpenGLBuffers() // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) update(); -#else - swapBuffers(); -#endif } /** @@ -498,11 +481,7 @@ CurveWidget::getScreenPixelRatio() const // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) return devicePixelRatio(); -#else - return _imp->_gui ? _imp->_gui->devicePixelRatio() : 1.; -#endif } #endif @@ -607,11 +586,9 @@ CurveWidget::resizeGL(int width, glViewport (0, 0, width, height); double zoomWidth = width; double zoomHeight = height; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) double screenPixelRatio = getScreenPixelRatio(); zoomWidth /= screenPixelRatio; zoomHeight /= screenPixelRatio; -#endif // Width and height may be 0 when tearing off a viewer tab to another panel if ( (width > 0) && (height > 0) ) { @@ -823,13 +800,9 @@ CurveWidget::mouseDoubleClickEvent(QMouseEvent* e) if (selectedText) { EditKeyFrameDialog* dialog = new EditKeyFrameDialog(mode, this, selectedText, this); int dialogW = dialog->sizeHint().width(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QScreen* desktop = QGuiApplication::primaryScreen(); QRect screen = desktop->availableGeometry(); -#else - QDesktopWidget* desktop = QApplication::desktop(); - QRect screen = desktop->screenGeometry(); -#endif + QPoint gP = e->globalPos(); if ( gP.x() > (screen.width() - dialogW) ) { gP.rx() -= dialogW; @@ -1443,21 +1416,12 @@ CurveWidget::wheelEvent(QWheelEvent* e) assert( qApp && qApp->thread() == QThread::currentThread() ); // don't handle horizontal wheel (e.g. on trackpad or Might Mouse) -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (e->angleDelta().x() != 0) { -#else - if (e->orientation() != Qt::Vertical) { -#endif return; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->angleDelta().y() ); QPointF zoomCenter = _imp->zoomCtx.toZoomCoordinates( e->position().x(), e->position().y() ); -#else - double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->delta() ); - QPointF zoomCenter = _imp->zoomCtx.toZoomCoordinates( e->x(), e->y() ); -#endif if ( modCASIsControlShift(e) ) { _imp->zoomOrPannedSinceLastFit = true; @@ -1548,11 +1512,7 @@ CurveWidget::getWidgetFontHeight() const int CurveWidget::getStringWidthForCurrentFont(const std::string& string) const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) return fontMetrics().horizontalAdvance( QString::fromUtf8( string.c_str() ) ); -#else - return fontMetrics().width( QString::fromUtf8( string.c_str() ) ); -#endif } QSize @@ -1598,18 +1558,10 @@ CurveWidget::keyPressEvent(QKeyEvent* e) } else if ( isKeybind(kShortcutGroupCurveEditor, kShortcutIDActionCurveEditorPaste, modifiers, key) ) { pasteKeyFramesFromClipBoardToSelectedCurve(); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionZoomIn, Qt::NoModifier, key) ) { // zoom in/out doesn't care about modifiers -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) QWheelEvent e(mapFromGlobal( QCursor::pos() ), QCursor::pos(), QPoint(), QPoint(0, 120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); -#else - QWheelEvent e(mapFromGlobal( QCursor::pos() ), 120, Qt::NoButton, Qt::NoModifier); // one wheel click = +-120 delta -#endif wheelEvent(&e); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionZoomOut, Qt::NoModifier, key) ) { // zoom in/out doesn't care about modifiers -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) QWheelEvent e(mapFromGlobal( QCursor::pos() ), QCursor::pos(), QPoint(), QPoint(0, -120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); -#else - QWheelEvent e(mapFromGlobal( QCursor::pos() ), -120, Qt::NoButton, Qt::NoModifier); // one wheel click = +-120 delta -#endif wheelEvent(&e); } else { accept = false; diff --git a/Gui/CurveWidget.h b/Gui/CurveWidget.h index 0842983091..248e89775c 100644 --- a/Gui/CurveWidget.h +++ b/Gui/CurveWidget.h @@ -41,11 +41,7 @@ CLANG_DIAG_OFF(uninitialized) CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif #include "Global/GlobalDefines.h" diff --git a/Gui/CurveWidgetPrivate.cpp b/Gui/CurveWidgetPrivate.cpp index 33cfaf898e..0cad9bf800 100644 --- a/Gui/CurveWidgetPrivate.cpp +++ b/Gui/CurveWidgetPrivate.cpp @@ -52,9 +52,7 @@ #include "Gui/Menu.h" #include "Gui/ticks.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif #define CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE 5 //maximum distance from a curve that accepts a mouse click // (in widget pixels) @@ -497,11 +495,7 @@ CurveWidgetPrivate::drawScale(double screenPixelRatio) ticks_fill(half_tick, ticks_max, m1, m2, &ticks); const double smallestTickSize = range * smallestTickSizePixel / rangePixel; const double largestTickSize = range * largestTickSizePixel / rangePixel; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const double minTickSizeTextPixel = ( (axis == 0) ? fm.horizontalAdvance( QLatin1String("00") ) : fm.height() ) / _screenPixelRatio; -#else - const double minTickSizeTextPixel = ( (axis == 0) ? fm.width( QLatin1String("00") ) : fm.height() ) / _screenPixelRatio; // AXIS-SPECIFIC -#endif const double minTickSizeText = range * minTickSizeTextPixel / rangePixel; for (int i = m1; i <= m2; ++i) { double value = i * smallTickSize + offset; @@ -526,11 +520,7 @@ CurveWidgetPrivate::drawScale(double screenPixelRatio) if (tickSize > minTickSizeText) { const int tickSizePixel = rangePixel * tickSize / range; const QString s = QString::number(value); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const double sSizePixel = ( (axis == 0) ? fm.horizontalAdvance(s) : fm.height() ) / _screenPixelRatio; // AXIS-SPECIFIC -#else - const double sSizePixel = ( (axis == 0) ? fm.width(s) : fm.height() ) / _screenPixelRatio; // AXIS-SPECIFIC -#endif if (tickSizePixel > sSizePixel) { const double sSizeFullPixel = sSizePixel + minTickSizeTextPixel; double alphaText = 1.0; //alpha; @@ -784,11 +774,7 @@ CurveWidgetPrivate::isNearbyKeyFrameText(const QPoint& pt) const topLeftWidget.ry() += yOffset; QString coordStr = QString::fromUtf8("x: %1, y: %2").arg( (*it2)->key.getTime() ).arg( (*it2)->key.getValue() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QPointF btmRightWidget( topLeftWidget.x() + fm.horizontalAdvance(coordStr) / _screenPixelRatio, topLeftWidget.y() + fm.height() / _screenPixelRatio ); -#else - QPointF btmRightWidget( topLeftWidget.x() + fm.width(coordStr) / _screenPixelRatio, topLeftWidget.y() + fm.height() / _screenPixelRatio ); -#endif if ( (pt.x() >= topLeftWidget.x() - CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) && (pt.x() <= btmRightWidget.x() + CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) && ( pt.y() >= topLeftWidget.y() - CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) && ( pt.y() <= btmRightWidget.y() + CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) ) { @@ -853,13 +839,8 @@ CurveWidgetPrivate::isNearbySelectedTangentText(const QPoint & pt) const QString leftCoordStr = QString( tr("l: %1") ).arg(std::floor( ( (*it2)->key.getLeftDerivative() * rounding ) + 0.5 ) / rounding); QString rightCoordStr = QString( tr("r: %1") ).arg(std::floor( ( (*it2)->key.getRightDerivative() * rounding ) + 0.5 ) / rounding); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QPointF btmRight_LeftTanWidget( topLeft_LeftTanWidget.x() + fm.horizontalAdvance(leftCoordStr) / _screenPixelRatio, topLeft_LeftTanWidget.y() + fm.height() / _screenPixelRatio ); QPointF btmRight_RightTanWidget( topLeft_RightTanWidget.x() + fm.horizontalAdvance(rightCoordStr) / _screenPixelRatio, topLeft_RightTanWidget.y() + fm.height() / _screenPixelRatio ); -#else - QPointF btmRight_LeftTanWidget( topLeft_LeftTanWidget.x() + fm.width(leftCoordStr) / _screenPixelRatio, topLeft_LeftTanWidget.y() + fm.height() / _screenPixelRatio ); - QPointF btmRight_RightTanWidget( topLeft_RightTanWidget.x() + fm.width(rightCoordStr) / _screenPixelRatio, topLeft_RightTanWidget.y() + fm.height() / _screenPixelRatio ); -#endif if ( (pt.x() >= topLeft_LeftTanWidget.x() - CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) && (pt.x() <= btmRight_LeftTanWidget.x() + CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) && ( pt.y() >= topLeft_LeftTanWidget.y() - CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) && ( pt.y() <= btmRight_LeftTanWidget.y() + CLICK_DISTANCE_FROM_CURVE_ACCEPTANCE) ) { diff --git a/Gui/CustomParamInteract.cpp b/Gui/CustomParamInteract.cpp index e3e297b018..a63a4c3bd4 100644 --- a/Gui/CustomParamInteract.cpp +++ b/Gui/CustomParamInteract.cpp @@ -33,9 +33,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#endif #include "Gui/KnobGui.h" #include "Gui/Gui.h" @@ -47,9 +45,7 @@ #include "Engine/AppInstance.h" #include "Engine/TimeLine.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif NATRON_NAMESPACE_ENTER @@ -175,11 +171,7 @@ CustomParamInteract::sizeHint() const void CustomParamInteract::swapOpenGLBuffers() { -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) update(); -#else - swapBuffers(); -#endif } void @@ -208,12 +200,7 @@ CustomParamInteract::getPixelScale(double & xScale, double CustomParamInteract::getScreenPixelRatio() const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) return devicePixelRatio(); -#else - KnobGuiPtr k = _imp->knob.lock(); - return (k && k->getGui()) ? k->getGui()->devicePixelRatio() : 1.; -#endif } #endif @@ -299,11 +286,7 @@ CustomParamInteract::getWidgetFontHeight() const int CustomParamInteract::getStringWidthForCurrentFont(const std::string& string) const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) return fontMetrics().horizontalAdvance( QString::fromUtf8( string.c_str() ) ); -#else - return fontMetrics().width( QString::fromUtf8( string.c_str() ) ); -#endif } RectD diff --git a/Gui/CustomParamInteract.h b/Gui/CustomParamInteract.h index c1511c8046..a5bda50bb6 100644 --- a/Gui/CustomParamInteract.h +++ b/Gui/CustomParamInteract.h @@ -31,11 +31,7 @@ #include "Global/GLIncludes.h" //!= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif #include "Engine/OverlaySupport.h" diff --git a/Gui/DocumentationManager.cpp b/Gui/DocumentationManager.cpp index ef0f429941..c064dec14b 100644 --- a/Gui/DocumentationManager.cpp +++ b/Gui/DocumentationManager.cpp @@ -229,21 +229,12 @@ DocumentationManager::handler(QHttpRequest *req, // get options QStringList options; if ( page.contains( QString::fromUtf8("?") ) ) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QStringList split = page.split(QString::fromUtf8("?"), Qt::SkipEmptyParts); page = split.takeFirst(); if (split.length() > 0) { QString rawOptions = split.takeLast(); options = rawOptions.split(QString::fromUtf8("&"), Qt::SkipEmptyParts); } -#else - QStringList split = page.split(QString::fromUtf8("?"), QString::SkipEmptyParts); - page = split.takeFirst(); - if (split.length() > 0) { - QString rawOptions = split.takeLast(); - options = rawOptions.split(QString::fromUtf8("&"), QString::SkipEmptyParts); - } -#endif } // default page @@ -377,11 +368,8 @@ DocumentationManager::handler(QHttpRequest *req, ""); for (int i = 0; i < options.size(); ++i) { if ( options.at(i).contains( QString::fromUtf8("id=") ) ) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QStringList split = options.at(i).split(QString::fromUtf8("="), Qt::SkipEmptyParts); -#else - QStringList split = options.at(i).split(QString::fromUtf8("="), QString::SkipEmptyParts); -#endif + if (split.length() > 0) { QString groupID = split.takeLast(); group = groupID; diff --git a/Gui/DopeSheetEditor.h b/Gui/DopeSheetEditor.h index ee869acad9..cfda330441 100644 --- a/Gui/DopeSheetEditor.h +++ b/Gui/DopeSheetEditor.h @@ -32,11 +32,7 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_OFF(uninitialized) #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#else -#include -#endif CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) diff --git a/Gui/DopeSheetHierarchyView.cpp b/Gui/DopeSheetHierarchyView.cpp index 6b7d73caaa..5edb84ea8b 100644 --- a/Gui/DopeSheetHierarchyView.cpp +++ b/Gui/DopeSheetHierarchyView.cpp @@ -130,11 +130,7 @@ HierarchyViewSelectionModel::selectChildren(const QModelIndex &index, QItemSelection *selection) const { int row = 0; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QModelIndex childIndex = index.model()->index(row, 0); -#else - QModelIndex childIndex = index.child(row, 0); -#endif while ( childIndex.isValid() ) { if ( !selection->contains(childIndex) ) { @@ -147,11 +143,7 @@ HierarchyViewSelectionModel::selectChildren(const QModelIndex &index, } ++row; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) childIndex = index.model()->index(row, 0); -#else - childIndex = index.child(row, 0); -#endif } } @@ -195,11 +187,7 @@ HierarchyViewSelectionModel::checkParentsSelectedStates(const QModelIndex &index QModelIndex index = (*it); bool selectParent = true; int row = 0; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QModelIndex childIndexIt = index.model()->index(row, 0); -#else - QModelIndex childIndexIt = index.child(row, 0); -#endif while ( childIndexIt.isValid() ) { if ( childIndexIt.data(QT_ROLE_CONTEXT_IS_ANIMATED).toBool() ) { @@ -211,11 +199,7 @@ HierarchyViewSelectionModel::checkParentsSelectedStates(const QModelIndex &index } ++row; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) childIndexIt = index.model()->index(row, 0); -#else - childIndexIt = index.child(row, 0); -#endif } if ( (flags & QItemSelectionModel::Select && selectParent) ) { @@ -814,11 +798,8 @@ HierarchyView::drawRow(QPainter *painter, painter->fillRect(itemRect.adjusted(-1, 0, 0, 0), fillColor); // Draw the item text -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QStyleOptionViewItem newOpt = viewOptions(); -#else - QStyleOptionViewItemV4 newOpt = viewOptions(); -#endif + newOpt.rect = itemRect; if ( selectionModel()->isSelected(index) ) { @@ -868,11 +849,8 @@ HierarchyView::drawBranches(QPainter *painter, painter->fillRect(rectForDull, nodeColorDull); // Draw the branch indicator -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QStyleOptionViewItem option = viewOptions(); -#else - QStyleOptionViewItemV4 option = viewOptions(); -#endif + option.rect = _imp->getParentArrowRect(item, rect); option.displayAlignment = Qt::AlignCenter; diff --git a/Gui/DopeSheetHierarchyView.h b/Gui/DopeSheetHierarchyView.h index a843c31b6d..d99b6160cf 100644 --- a/Gui/DopeSheetHierarchyView.h +++ b/Gui/DopeSheetHierarchyView.h @@ -34,13 +34,9 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_OFF(uninitialized) #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) + #include #include -#else -#include -#include -#endif CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) diff --git a/Gui/DopeSheetView.cpp b/Gui/DopeSheetView.cpp index 8e40a05df7..bbaa4e3c24 100644 --- a/Gui/DopeSheetView.cpp +++ b/Gui/DopeSheetView.cpp @@ -36,9 +36,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#endif // Natron includes #include "Engine/Curve.h" @@ -76,9 +74,7 @@ #include "Gui/ZoomContext.h" #include "Gui/TabWidget.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif #define NATRON_DOPESHEET_MIN_RANGE_FIT 10 @@ -427,11 +423,7 @@ DopeSheetView::getWidgetFontHeight() const int DopeSheetView::getStringWidthForCurrentFont(const std::string& string) const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) return fontMetrics().horizontalAdvance( QString::fromUtf8( string.c_str() ) ); -#else - return fontMetrics().width( QString::fromUtf8( string.c_str() ) ); -#endif } /* @@ -814,9 +806,6 @@ DopeSheetViewPrivate::generateKeyframeTextures() kfTexturesImages[i] = kfTexturesImages[i].scaled(KF_PIXMAP_SIZE, KF_PIXMAP_SIZE, Qt::KeepAspectRatio, Qt::SmoothTransformation); } -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - kfTexturesImages[i] = QOpenGLWidget::convertToGLFormat(kfTexturesImages[i]); -#endif glBindTexture(GL_TEXTURE_2D, kfTexturesIDs[i]); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); @@ -933,11 +922,7 @@ DopeSheetViewPrivate::drawScale() const const double smallestTickSize = range * smallestTickSizePixel / rangePixel; const double largestTickSize = range * largestTickSizePixel / rangePixel; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const double minTickSizeTextPixel = fm.horizontalAdvance( QString::fromUtf8("00") ) / _screenPixelRatio; -#else - const double minTickSizeTextPixel = fm.width( QString::fromUtf8("00") ) / _screenPixelRatio; -#endif const double minTickSizeText = range * minTickSizeTextPixel / rangePixel; glCheckError(); @@ -962,11 +947,7 @@ DopeSheetViewPrivate::drawScale() const if (tickSize > minTickSizeText) { const int tickSizePixel = rangePixel * tickSize / range; const QString s = QString::number(value); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const int sSizePixel = fm.horizontalAdvance(s) / _screenPixelRatio; -#else - const int sSizePixel = fm.width(s) / _screenPixelRatio; -#endif if (tickSizePixel > sSizePixel) { const int sSizeFullPixel = sSizePixel + minTickSizeTextPixel; @@ -1256,11 +1237,8 @@ DopeSheetViewPrivate::drawRange(const DSNodePtr &dsNode) const double fontHeight = fm.height() / _screenPixelRatio; QString leftText = QString::number(range.first); QString rightText = QString::number(range.second - 1); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) double rightTextW = fm.horizontalAdvance(rightText) / _screenPixelRatio; -#else - double rightTextW = fm.width(rightText) / _screenPixelRatio; -#endif + QPointF textLeftPos( zoomContext.toZoomCoordinates(zoomContext.toWidgetCoordinates(range.first, 0).x() + 3, 0).x(), zoomContext.toZoomCoordinates(0, zoomContext.toWidgetCoordinates(0, clipRectCenterY).y() + fontHeight / 2.).y() ); @@ -2690,12 +2668,7 @@ DopeSheetView::swapOpenGLBuffers() { running_in_main_thread(); - -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) update(); -#else - swapBuffers(); -#endif } /** @@ -2745,11 +2718,7 @@ DopeSheetView::getPixelScale(double &xScale, double DopeSheetView::getScreenPixelRatio() const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) return devicePixelRatio(); -#else - return _imp->gui ? _imp->gui->devicePixelRatio() : 1.; -#endif } #endif @@ -3230,11 +3199,10 @@ DopeSheetView::resizeGL(int w, glViewport(0, 0, w, h); double zoomWidth = w; double zoomHeight = h; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) double screenPixelRatio = getScreenPixelRatio(); zoomWidth /= screenPixelRatio; zoomHeight /= screenPixelRatio; -#endif + _imp->zoomContext.setScreenSize(zoomWidth, zoomHeight); // Don't do the following when the height of the widget is irrelevant @@ -3674,21 +3642,12 @@ DopeSheetView::wheelEvent(QWheelEvent *e) running_in_main_thread(); // don't handle horizontal wheel (e.g. on trackpad or Might Mouse) -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (e->angleDelta().x() != 0) { -#else - if (e->orientation() != Qt::Vertical) { -#endif return; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->angleDelta().y() ); QPointF zoomCenter = _imp->zoomContext.toZoomCoordinates( e->position().x(), e->position().y() ); -#else - double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->delta() ); - QPointF zoomCenter = _imp->zoomContext.toZoomCoordinates( e->x(), e->y() ); -#endif _imp->zoomOrPannedSinceLastFit = true; diff --git a/Gui/DopeSheetView.h b/Gui/DopeSheetView.h index d6283ac062..21fabbacbe 100644 --- a/Gui/DopeSheetView.h +++ b/Gui/DopeSheetView.h @@ -33,11 +33,7 @@ #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif #include "Engine/OverlaySupport.h" #include "Engine/ViewIdx.h" diff --git a/Gui/Edge.cpp b/Gui/Edge.cpp index 5e5b013c66..903cb82eab 100644 --- a/Gui/Edge.cpp +++ b/Gui/Edge.cpp @@ -487,11 +487,8 @@ Edge::initLine() if (dest) { for (int i = 0; i < 4; ++i) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType type = dstEdges[i].intersects(line(), &dstIntersection); -#else - QLineF::IntersectType type = dstEdges[i].intersect(line(), &dstIntersection); -#endif + if (type == QLineF::BoundedIntersection) { setLine( QLineF( dstIntersection, line().p2() ) ); foundDstIntersection = true; @@ -506,11 +503,8 @@ Edge::initLine() if (foundDstIntersection) { ///Find the intersection with the source bbox for (int i = 0; i < 4; ++i) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType type = srcEdges[i].intersects(line(), &srcInteresect); -#else - QLineF::IntersectType type = srcEdges[i].intersect(line(), &srcInteresect); -#endif + if (type == QLineF::BoundedIntersection) { foundSrcIntersection = true; break; @@ -536,11 +530,8 @@ Edge::initLine() _imp->label->setPos(pos); QFontMetrics fm( _imp->label->font() ); int fontHeight = fm.height(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) double txtWidth = fm.horizontalAdvance( _imp->label->text() ); -#else - double txtWidth = fm.width( _imp->label->text() ); -#endif + if ( (visibleLength < fontHeight * 2) || (visibleLength < txtWidth) ) { _imp->label->hide(); _imp->enoughSpaceToShowLabel = false; @@ -556,11 +547,8 @@ Edge::initLine() QPointF intersection; bool foundIntersection = false; for (int i = 0; i < 4; ++i) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType type = dstEdges[i].intersects(line(), &intersection); -#else - QLineF::IntersectType type = dstEdges[i].intersect(line(), &intersection); -#endif + if (type == QLineF::BoundedIntersection) { setLine( QLineF( intersection, line().p2() ) ); foundIntersection = true; @@ -583,11 +571,7 @@ Edge::initLine() double cosinus = std::cos(_imp->angle); int yOffset = 0; if (cosinus < 0) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) yOffset = -fm.horizontalAdvance( _imp->label->text() ); -#else - yOffset = -fm.width( _imp->label->text() ); -#endif } else if ( (cosinus >= -0.01) && (cosinus <= 0.01) ) { yOffset = +5; } else { @@ -904,11 +888,7 @@ LinkArrow::refreshPosition() QPointF slaveIntersect; bool foundIntersection = false; for (int i = 0; i < 4; ++i) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType type = slaveEdges[i].intersects(line(), &slaveIntersect); -#else - QLineF::IntersectType type = slaveEdges[i].intersect(line(), &slaveIntersect); -#endif if (type == QLineF::BoundedIntersection) { foundIntersection = true; break; @@ -924,11 +904,7 @@ LinkArrow::refreshPosition() foundIntersection = false; for (int i = 0; i < 4; ++i) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType type = masterEdges[i].intersects(line(), &masterIntersect); -#else - QLineF::IntersectType type = masterEdges[i].intersect(line(), &masterIntersect); -#endif if (type == QLineF::BoundedIntersection) { foundIntersection = true; break; diff --git a/Gui/EditScriptDialog.cpp b/Gui/EditScriptDialog.cpp index a0c5ad564e..2dfed072b3 100644 --- a/Gui/EditScriptDialog.cpp +++ b/Gui/EditScriptDialog.cpp @@ -226,11 +226,7 @@ EditScriptDialog::create(const QString& initialScript, _imp->resultEdit->setFont(font); } QFontMetrics fm = _imp->expressionEdit->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->expressionEdit->setTabStopDistance( 4 * fm.horizontalAdvance( QLatin1Char(' ') ) ); -#else - _imp->expressionEdit->setTabStopWidth( 4 * fm.width( QLatin1Char(' ') ) ); -#endif } // EditScriptDialog::create void diff --git a/Gui/FileTypeMainWindow_win.cpp b/Gui/FileTypeMainWindow_win.cpp index 2edd528130..570054f4e4 100644 --- a/Gui/FileTypeMainWindow_win.cpp +++ b/Gui/FileTypeMainWindow_win.cpp @@ -87,7 +87,6 @@ DocumentWindow::~DocumentWindow() // —— public slots —————————————————————————— // —— protected slots ————————————————————————— // —— events ———————————————————————————— -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) bool DocumentWindow::nativeEvent(const QByteArray& eventType, void* message, long* result) { @@ -109,28 +108,6 @@ DocumentWindow::nativeEvent(const QByteArray& eventType, void* message, long* re return QMainWindow::nativeEvent(eventType, message, result); } -#else -bool -DocumentWindow::winEvent(MSG* msg, long *result) -{ - switch (msg->message) { - case WM_DDE_INITIATE: - - return ddeInitiate(msg, result); - break; - case WM_DDE_EXECUTE: - - return ddeExecute(msg, result); - break; - case WM_DDE_TERMINATE: - - return ddeTerminate(msg, result); - break; - } - - return QMainWindow::winEvent(msg, result); -} -#endif void DocumentWindow::ddeOpenFile(const QString&) diff --git a/Gui/FileTypeMainWindow_win.h b/Gui/FileTypeMainWindow_win.h index 197919b171..0432627c9e 100644 --- a/Gui/FileTypeMainWindow_win.h +++ b/Gui/FileTypeMainWindow_win.h @@ -138,11 +138,7 @@ class DocumentWindow /** * reimpl as DDE events come as windows events and are not translated by Qt. */ - #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) virtual bool nativeEvent(const QByteArray& eventType, void* message, long* result); - #else - virtual bool winEvent(MSG *msg, long *result); - #endif // —— helpers for the file registration —————————————————— /** diff --git a/Gui/FloatingWidget.cpp b/Gui/FloatingWidget.cpp index 05c0f0f063..cca745a267 100644 --- a/Gui/FloatingWidget.cpp +++ b/Gui/FloatingWidget.cpp @@ -33,11 +33,7 @@ #include #include // qApp -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #include -#else -#include -#endif #include #include "Engine/Project.h" @@ -122,15 +118,10 @@ FloatingWidget::setWidget(QWidget* w) w->setVisible(true); w->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QScreen* desktop = QGuiApplication::primaryScreen(); assert(desktop != nullptr); QRect geom = desktop->availableGeometry(); -#else - QDesktopWidget* dw = qApp->desktop(); - assert(dw); - QRect geom = dw->screenGeometry(); -#endif + widgetSize.setWidth( std::min( widgetSize.width(), geom.width() ) ); widgetSize.setHeight( std::min( widgetSize.height(), geom.height() ) ); resize(widgetSize); diff --git a/Gui/Gui.h b/Gui/Gui.h index c6fa2d1ceb..69187ceaa8 100644 --- a/Gui/Gui.h +++ b/Gui/Gui.h @@ -486,12 +486,6 @@ GCC_DIAG_SUGGEST_OVERRIDE_ON virtual void ddeOpenFile(const QString& filePath) OVERRIDE FINAL; #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - /** - * @brief Returns 1.0 on a 96 DPI screen, and 2.0 on a Retina Display. - **/ - qreal devicePixelRatio() const; -#endif AppInstancePtr createNewProject(); diff --git a/Gui/Gui10.cpp b/Gui/Gui10.cpp index c87228be6e..56985927e0 100644 --- a/Gui/Gui10.cpp +++ b/Gui/Gui10.cpp @@ -32,11 +32,7 @@ #include #include // qApp -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #include -#else -#include -#endif #include "Global/FStreamsSupport.h" #include "Global/MathUtils.h" @@ -200,13 +196,8 @@ Gui::restoreLayout(bool wipePrevious, createDefaultLayout1(); } else { std::list floatingDockablePanels; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QScreen* desktop = QGuiApplication::primaryScreen(); QRect screen = desktop->availableGeometry(); -#else - QDesktopWidget* desktop = QApplication::desktop(); - QRect screen = desktop->screenGeometry(); -#endif ///now restore the gui layout for (std::list::const_iterator it = layoutSerialization._windows.begin(); diff --git a/Gui/Gui40.cpp b/Gui/Gui40.cpp index f9aa6c2306..820a5bd141 100644 --- a/Gui/Gui40.cpp +++ b/Gui/Gui40.cpp @@ -38,9 +38,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#endif #include #include // qApp @@ -194,11 +192,7 @@ Gui::updateRecentFileActions() // split each dir, and find the common part of all dirs. std::vector dirParts(dirs.size()); for (int i = 0; i < dirs.size(); ++i) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) dirParts[i] = QDir::toNativeSeparators(dirs.at(i)).split(QDir::separator(), Qt::SkipEmptyParts); -#else - dirParts[i] = QDir::toNativeSeparators(dirs.at(i)).split(QDir::separator(), QString::SkipEmptyParts); -#endif } int minComps = dirParts[0].size(); for (int i = 1; i < dirs.size(); ++i) { @@ -224,11 +218,7 @@ Gui::updateRecentFileActions() // remove the n first element to each dirName corresponding to this filename, and recompose for (int i = 0; i < numRecentFiles; ++i) { if (fileNames[i] == it->first) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) dirNames[i] = QStringList(QDir::toNativeSeparators(dirNames.at(i)).split(QDir::separator(), Qt::SkipEmptyParts).mid(commonComps)).join(QDir::separator()); -#else - dirNames[i] = QStringList(QDir::toNativeSeparators(dirNames.at(i)).split(QDir::separator(), QString::SkipEmptyParts).mid(commonComps)).join(QDir::separator()); -#endif } } } @@ -254,16 +244,7 @@ Gui::updateRecentFileActions() QPixmap Gui::screenShot(QWidget* w) { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - if ( w->objectName() == QString::fromUtf8("CurveEditor") ) { - return QPixmap::grabWidget(w); - } - - return QPixmap::grabWindow( w->winId() ); -#else - return QApplication::primaryScreen()->grabWindow( w->winId() ); -#endif } void diff --git a/Gui/Gui50.cpp b/Gui/Gui50.cpp index 173aff93d9..b126c9dab3 100644 --- a/Gui/Gui50.cpp +++ b/Gui/Gui50.cpp @@ -1061,35 +1061,6 @@ Gui::ddeOpenFile(const QString& filePath) #endif -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -/** - * @brief Returns 1.0 on a 96 DPI screen, and 2.0 on a Retina Display. - **/ -qreal Gui::devicePixelRatio() const -{ -#if defined(Q_OS_WIN) - HDC screen = GetDC(winId()); - FLOAT horizontalDPI = GetDeviceCaps(screen, LOGPIXELSX); - ReleaseDC(0, screen); - - return static_cast(horizontalDPI) / 96.; -#elif defined(Q_OS_DARWIN) - return QtMac::devicePixelRatioInternal(this); -#elif defined(Q_WS_X11) - // Use the Xft.dpi X resource, as described there: - // - https://github.com/glfw/glfw/blob/84f95a7d7fa454ca99efcdd49da89472294b16bf/src/x11_init.c#L971 - // - https://wiki.archlinux.org/title/HiDPI#X_Resources - - // QX11Info uses it to set appDpiX() and appDpiY(), see the code: - // - https://github.com/qt/qt/blob/0a2f2382541424726168804be2c90b91381608c6/src/gui/kernel/qapplication_x11.cpp#L2203 - - return x11Info().appDpiX(x11Info().appScreen()) / 96.; -#else - return 1.; -#endif -} -#endif - bool Gui::isFocusStealingPossible() { diff --git a/Gui/GuiAppInstance.cpp b/Gui/GuiAppInstance.cpp index 41bd9255ab..5a904f8976 100644 --- a/Gui/GuiAppInstance.cpp +++ b/Gui/GuiAppInstance.cpp @@ -25,12 +25,6 @@ #include "GuiAppInstance.h" -#if defined(__APPLE__) && QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#include -#include -#include -#endif - #include #include // stringstream @@ -1016,22 +1010,6 @@ void GuiAppInstance::createLoadProjectSplashScreen(const QString& projectFile) { QCoreApplication::processEvents(); -#if defined(__APPLE__) && QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - short int version_[3] = {0}; - char str[256] = {0}; - size_t size = sizeof(str); - int ret = sysctlbyname("kern.osrelease", str, &size, NULL, 0); - if (ret == 0) { - sscanf(str, "%hd.%hd.%hd", &version_[0], &version_[1], &version_[2]); - } - if (version_[0] >= 21) { - // On macOS 12 Monterey, Qt4 crashes the app when closing - // a window, including the splash screen. - // See: https://github.com/NatronGitHub/Natron/issues/712 - // This is probably a Qt4 bug, so let us avoid the splash screen. - return; - } -#endif if (_imp->loadProjectSplash) { return; } diff --git a/Gui/GuiApplicationManager.cpp b/Gui/GuiApplicationManager.cpp index 9205862447..f59bcaf909 100644 --- a/Gui/GuiApplicationManager.cpp +++ b/Gui/GuiApplicationManager.cpp @@ -851,15 +851,6 @@ GuiApplicationManager::initGui(const CLArgs& args) { QSettings settings( QString::fromUtf8(NATRON_ORGANIZATION_NAME), QString::fromUtf8(NATRON_APPLICATION_NAME) ); -#ifdef __NATRON_UNIX__ -#ifndef __NATRON_OSX__ -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - // workaround for issues with KDE4 - QApplication::setStyle( QString::fromUtf8("plastique") ); -#endif -#endif -#endif - //load custom fonts QString fontResource = QString::fromUtf8(":/Resources/Fonts/%1.ttf"); QStringList fontFilenames; diff --git a/Gui/GuiApplicationManager10.cpp b/Gui/GuiApplicationManager10.cpp index 073109d7aa..9686425e02 100644 --- a/Gui/GuiApplicationManager10.cpp +++ b/Gui/GuiApplicationManager10.cpp @@ -66,11 +66,6 @@ CLANG_DIAG_ON(uninitialized) #include "Gui/KnobGuiFactory.h" #include "Gui/SplashScreen.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -// removed in qt5, just revert the commit (1b58d9acc493111390b31f0bffd6b2a76baca91b) -Q_INIT_RESOURCE_EXTERN(GuiResources); -#endif - /** * @macro Registers a keybind to the application. * @param group The name of the group under which the shortcut should be (e.g: Global, Viewer,NodeGraph...) @@ -109,11 +104,9 @@ Q_INIT_RESOURCE_EXTERN(GuiResources); //in a way. This way the user will get prompted to restore default shortcuts on next launch #define NATRON_SHORTCUTS_DEFAULT_VERSION 8 -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) inline void initGuiResource() { Q_INIT_RESOURCE(GuiResources); } -#endif NATRON_NAMESPACE_ENTER @@ -314,23 +307,13 @@ GuiApplicationManager::initializeQApp(int &argc, app->setQuitOnLastWindowClosed(true); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // use namespace workaround // https://doc.qt.io/qt-5/qdir.html#Q_INIT_RESOURCE initGuiResource(); -#else - // Q_INIT_RESOURCES expanded, and fixed for use from inside a namespace: - // (requires using Q_INIT_RESOURCES_EXTERN(GuiResources) before entering the namespace) - ::qInitResources_GuiResources(); -#endif #ifdef DEBUG - QLocale loc; -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - loc = QApplication::keyboardInputLocale(); -#else - loc = QGuiApplication::inputMethod()->locale(); -#endif + QLocale loc = QGuiApplication::inputMethod()->locale(); + qDebug() << "keyboard input locale:" << loc.bcp47Name(); #endif diff --git a/Gui/GuiFwd.h b/Gui/GuiFwd.h index fc06fc3ded..6938951267 100644 --- a/Gui/GuiFwd.h +++ b/Gui/GuiFwd.h @@ -99,9 +99,7 @@ class QWheelEvent; class QWidget; typedef std::shared_ptr QUndoStackPtr; -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) class QOpenGLShaderProgram; -#endif // Natron Gui NATRON_NAMESPACE_ENTER @@ -241,9 +239,6 @@ class KnobPageGui; #ifdef Q_OS_DARWIN //Implementation in Gui/QtMac.mm namespace QtMac { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -qreal devicePixelRatioInternal(const QWidget* w); -#endif #if OBJC_OLD_DISPATCH_PROTOTYPES != 1 void setupDockClickHandler(void (*)(void)); #endif diff --git a/Gui/GuiPrivate.cpp b/Gui/GuiPrivate.cpp index c99446d4ad..30cc04b0b6 100644 --- a/Gui/GuiPrivate.cpp +++ b/Gui/GuiPrivate.cpp @@ -42,9 +42,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#endif #include GCC_DIAG_UNUSED_PRIVATE_FIELD_OFF // /opt/local/include/QtGui/qmime.h:119:10: warning: private field 'type' is not used [-Wunused-private-field] @@ -55,10 +53,6 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include -#if QT_VERSION < QT_VERSION_CHECK(5, 11, 0) -#include -#endif - #include #include #include @@ -192,11 +186,7 @@ GuiPrivate::GuiPrivate(const GuiAppInstancePtr& app, , _lastPluginDir() , _nextViewerTabPlace(0) , _leftRightSplitter(0) -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) , _viewerTabsMutex() -#else - , _viewerTabsMutex(QMutex::Recursive) // Gui::createNodeViewerInterface() may cause a resizeEvent, which calls Gui:redrawAllViewers() -#endif , _viewerTabs() , _masterSyncViewer(0) , _activeViewer(0) @@ -641,13 +631,8 @@ GuiPrivate::restoreGuiGeometry() _gui->resize(size); } else { ///No window size serialized, give some appropriate default value according to the screen size -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QScreen* desktop = QGuiApplication::primaryScreen(); QRect screen = desktop->availableGeometry(); -#else - QDesktopWidget* desktop = QApplication::desktop(); - QRect screen = desktop->screenGeometry(); -#endif _gui->resize( (int)( 0.93 * screen.width() ), (int)( 0.93 * screen.height() ) ); // leave some space } if ( settings.contains( QString::fromUtf8("maximized")) ) { diff --git a/Gui/GuiPrivate.h b/Gui/GuiPrivate.h index 6bf10171ec..5ed3d5f154 100644 --- a/Gui/GuiPrivate.h +++ b/Gui/GuiPrivate.h @@ -152,11 +152,8 @@ struct GuiPrivate Splitter* _leftRightSplitter; ///a list of ptrs to all the viewer tabs. -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) mutable QRecursiveMutex _viewerTabsMutex; -#else - mutable QMutex _viewerTabsMutex; -#endif + std::list _viewerTabs; ///Used when all viewers are synchronized to determine which one triggered the sync diff --git a/Gui/Histogram.cpp b/Gui/Histogram.cpp index 9c5f713c80..73a130273f 100644 --- a/Gui/Histogram.cpp +++ b/Gui/Histogram.cpp @@ -42,12 +42,8 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include #include -#else -#include "Gui/QGLExtrasCompat.h" -#endif #include "Engine/HistogramCPU.h" #include "Engine/Image.h" @@ -72,9 +68,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/ZoomContext.h" #include "Gui/ticks.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif NATRON_NAMESPACE_ENTER @@ -290,11 +284,7 @@ struct HistogramPrivate Histogram::Histogram(Gui* gui, const QOpenGLWidget* shareWidget) -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) : QOpenGLWidget(gui) -#else - : QOpenGLWidget(gui, shareWidget) -#endif , PanelWidget(this, gui) , _imp( new HistogramPrivate(this) ) { @@ -1251,11 +1241,9 @@ Histogram::resizeGL(int width, glViewport (0, 0, width, height); double zoomWidth = width; double zoomHeight = height; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) double screenPixelRatio = getScreenPixelRatio(); zoomWidth /= screenPixelRatio; zoomHeight /= screenPixelRatio; -#endif _imp->zoomCtx.setScreenSize(zoomWidth, zoomHeight); if (!_imp->hasBeenModifiedSinceResize) { @@ -1401,11 +1389,7 @@ Histogram::wheelEvent(QWheelEvent* e) assert( qApp && qApp->thread() == QThread::currentThread() ); // don't handle horizontal wheel (e.g. on trackpad or Might Mouse) -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (e->angleDelta().x() != 0) { -#else - if (e->orientation() != Qt::Vertical) { -#endif return; } const double zoomFactor_min = 0.000001; @@ -1414,13 +1398,8 @@ Histogram::wheelEvent(QWheelEvent* e) const double par_max = 1000000.; double zoomFactor; double par; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->angleDelta().y() ); QPointF zoomCenter = _imp->zoomCtx.toZoomCoordinates( e->position().x(), e->position().y() ); -#else - double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->delta() ); // no need to use ipow() here, because the result is not cast to int - QPointF zoomCenter = _imp->zoomCtx.toZoomCoordinates( e->x(), e->y() ); -#endif if ( modCASIsControlShift(e) ) { // Alt + Shift + Wheel: zoom values only, keep point under mouse @@ -1588,11 +1567,7 @@ Histogram::onCPUHistogramComputed() double Histogram::getScreenPixelRatio() const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) return devicePixelRatio(); -#else - return getGui() ? getGui()->devicePixelRatio() : 1.; -#endif } void @@ -1639,11 +1614,7 @@ HistogramPrivate::drawScale() ticks_fill(half_tick, ticks_max, m1, m2, &ticks); const double smallestTickSize = range * smallestTickSizePixel / rangePixel; const double largestTickSize = range * largestTickSizePixel / rangePixel; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const double minTickSizeTextPixel = ( (axis == 0) ? fm.horizontalAdvance( QLatin1String("00") ) : fm.height() ) / _screenPixelRatio; -#else - const double minTickSizeTextPixel = ( (axis == 0) ? fm.width( QLatin1String("00") ) : fm.height() ) / _screenPixelRatio; // AXIS-SPECIFIC -#endif const double minTickSizeText = range * minTickSizeTextPixel / rangePixel; for (int i = m1; i <= m2; ++i) { double value = i * smallTickSize + offset; @@ -1667,11 +1638,7 @@ HistogramPrivate::drawScale() if (tickSize > minTickSizeText) { const int tickSizePixel = rangePixel * tickSize / range; const QString s = QString::number(value); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const double sSizePixel = ( (axis == 0) ? fm.horizontalAdvance(s) : fm.height() ) / _screenPixelRatio; // AXIS-SPECIFIC -#else - const double sSizePixel = ( (axis == 0) ? fm.width(s) : fm.height() ) / _screenPixelRatio; // AXIS-SPECIFIC -#endif if (tickSizePixel > sSizePixel) { const double sSizeFullPixel = sSizePixel + minTickSizeTextPixel; double alphaText = 1.0; //alpha; @@ -1706,11 +1673,7 @@ HistogramPrivate::drawWarnings() if (mipmapLevel > 0) { QFontMetrics fm(*_textFont); QString str( tr("Image downscaled") ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) double strWidth = fm.horizontalAdvance(str) / _screenPixelRatio; -#else - double strWidth = fm.width(str) / _screenPixelRatio; -#endif double strHeight = fm.height() / _screenPixelRatio; QPointF pos = zoomCtx.toZoomCoordinates(widget->width() - strWidth - 10, 5 * strHeight + 30); glCheckError(); @@ -1742,11 +1705,7 @@ HistogramPrivate::drawMissingImage() } QString txt( tr("Missing image") ); QFontMetrics fm(*_textFont); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int strWidth = fm.horizontalAdvance(txt) / _screenPixelRatio; -#else - int strWidth = fm.width(txt) / _screenPixelRatio; -#endif QPointF pos = zoomCtx.toZoomCoordinates(widget->width() / 2. - strWidth / 2., fm.height() / _screenPixelRatio + 10); glCheckError(); @@ -1844,11 +1803,7 @@ HistogramPrivate::drawPicker() glCheckError(); QFontMetrics fm(*_textFont, 0); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) double strWidth = std::max( std::max( std::max( fm.horizontalAdvance(rValueStr), fm.horizontalAdvance(gValueStr) ), fm.horizontalAdvance(bValueStr) ), fm.horizontalAdvance(xCoordinateStr) ) / _screenPixelRatio; -#else - double strWidth = std::max( std::max( std::max( fm.width(rValueStr), fm.width(gValueStr) ), fm.width(bValueStr) ), fm.width(xCoordinateStr) ) / _screenPixelRatio; -#endif double strHeight = fm.height() / _screenPixelRatio; QPointF xPos = zoomCtx.toZoomCoordinates(widget->width() - strWidth - 10, strHeight + 10); QPointF rPos = zoomCtx.toZoomCoordinates(widget->width() - strWidth - 10, 2 * strHeight + 15); diff --git a/Gui/Histogram.h b/Gui/Histogram.h index 6d2cfdf0cc..cad1f3854e 100644 --- a/Gui/Histogram.h +++ b/Gui/Histogram.h @@ -34,11 +34,7 @@ CLANG_DIAG_OFF(uninitialized) #include CLANG_DIAG_ON(uninitialized) -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif #include "Gui/PanelWidget.h" #include "Gui/GuiFwd.h" diff --git a/Gui/HostOverlay.cpp b/Gui/HostOverlay.cpp index b9a685cf5e..6395c5e07c 100644 --- a/Gui/HostOverlay.cpp +++ b/Gui/HostOverlay.cpp @@ -54,12 +54,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif - #ifndef M_PI #define M_PI 3.14159265358979323846264338327950288419717 diff --git a/Gui/InfoViewerWidget.cpp b/Gui/InfoViewerWidget.cpp index e09a72c3a2..79fcd6bb6d 100644 --- a/Gui/InfoViewerWidget.cpp +++ b/Gui/InfoViewerWidget.cpp @@ -98,32 +98,20 @@ InfoViewerWidget::InfoViewerWidget(const QString & description, descriptionText.append( QString::fromUtf8("") ); descriptionLabel->setText(descriptionText); QFontMetrics fm = descriptionLabel->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("A:") ); -#else - int width = fm.width( QString::fromUtf8("A:") ); -#endif descriptionLabel->setMinimumWidth(width); } imageFormat = new Label(this); { QFontMetrics fm = imageFormat->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("backward.motion32f") ); -#else - int width = fm.width( QString::fromUtf8("backward.motion32f") ); -#endif imageFormat->setMinimumWidth(width); } resolution = new Label(this); { QFontMetrics fm = resolution->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("2K_Super_35(full-ap) 00000x00000:0.00") ); -#else - int width = fm.width( QString::fromUtf8("2K_Super_35(full-ap) 00000x00000:0.00") ); -#endif resolution->setMinimumWidth(width); } @@ -131,11 +119,7 @@ InfoViewerWidget::InfoViewerWidget(const QString & description, coordDispWindow = new Label(this); { QFontMetrics fm = coordDispWindow->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("RoD: 000 000 0000 0000") ); -#else - int width = fm.width( QString::fromUtf8("RoD: 000 000 0000 0000") ); -#endif coordDispWindow->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); coordDispWindow->setMinimumWidth(width); } @@ -143,11 +127,7 @@ InfoViewerWidget::InfoViewerWidget(const QString & description, _fpsLabel = new Label(this); { QFontMetrics fm = _fpsLabel->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("100 fps") ); -#else - int width = fm.width( QString::fromUtf8("100 fps") ); -#endif _fpsLabel->setMinimumWidth(width); _fpsLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); _fpsLabel->hide(); @@ -156,22 +136,14 @@ InfoViewerWidget::InfoViewerWidget(const QString & description, coordMouse = new Label(this); { QFontMetrics fm = coordMouse->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("x=00000 y=00000") ); -#else - int width = fm.width( QString::fromUtf8("x=00000 y=00000") ); -#endif coordMouse->setMinimumWidth(width); } rgbaValues = new Label(this); { QFontMetrics fm = rgbaValues->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("0.00000 0.00000 0.00000 ~ ") ); -#else - int width = fm.width( QString::fromUtf8("0.00000 0.00000 0.00000 ~ ") ); -#endif rgbaValues->setMinimumWidth(width); } @@ -181,11 +153,7 @@ InfoViewerWidget::InfoViewerWidget(const QString & description, hvl_lastOption = new Label(this); { QFontMetrics fm = hvl_lastOption->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int width = fm.horizontalAdvance( QString::fromUtf8("H:000 S:0.00 V:0.00 L:0.00000") ); -#else - int width = fm.width( QString::fromUtf8("H:000 S:0.00 V:0.00 L:0.00000") ); -#endif hvl_lastOption->setMinimumWidth(width); } diff --git a/Gui/KnobGui20.cpp b/Gui/KnobGui20.cpp index 0ffb2b5251..995826fec8 100644 --- a/Gui/KnobGui20.cpp +++ b/Gui/KnobGui20.cpp @@ -578,11 +578,7 @@ KnobGui::getStringWidthForCurrentFont(const std::string& string) const return _imp->customInteract->getStringWidthForCurrentFont(string); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) return getGui()->fontMetrics().horizontalAdvance( QString::fromUtf8( string.c_str() ) ); -#else - return getGui()->fontMetrics().width( QString::fromUtf8( string.c_str() ) ); -#endif } void diff --git a/Gui/KnobGuiString.cpp b/Gui/KnobGuiString.cpp index 5ebc9e37ac..ed2dff80ad 100644 --- a/Gui/KnobGuiString.cpp +++ b/Gui/KnobGuiString.cpp @@ -96,11 +96,7 @@ AnimatingTextEdit::AnimatingTextEdit(const KnobGuiPtr& knob, , dirty(false) , _dnd( KnobWidgetDnD::create(knob, dimension, this) ) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) setTabStopDistance(20); -#else - setTabStopWidth(20); // a tab width of 20 is more reasonable than 80 for programming languages (e.g. Shadertoy) -#endif } AnimatingTextEdit::~AnimatingTextEdit() diff --git a/Gui/KnobGuiTable.cpp b/Gui/KnobGuiTable.cpp index a13b0066ea..93ff79bd86 100644 --- a/Gui/KnobGuiTable.cpp +++ b/Gui/KnobGuiTable.cpp @@ -222,12 +222,7 @@ KnobGuiTable::createWidget(QHBoxLayout* layout) _imp->table->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); _imp->table->setAttribute(Qt::WA_MacShowFocusRect, 0); - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->table->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _imp->table->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif _imp->table->setDragDropMode(QAbstractItemView::InternalMove); _imp->table->header()->setStretchLastSection(true); _imp->table->setUniformRowHeights(true); diff --git a/Gui/KnobWidgetDnD.cpp b/Gui/KnobWidgetDnD.cpp index 8299231e38..25c863de64 100644 --- a/Gui/KnobWidgetDnD.cpp +++ b/Gui/KnobWidgetDnD.cpp @@ -285,11 +285,7 @@ KnobWidgetDnD::startDrag() textThirdLine = tr("Drag it to a dimension of another parameter of the same type"); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int textWidth = std::max( std::max( fmetrics.horizontalAdvance(textFirstLine), fmetrics.horizontalAdvance(knobLine) ), fmetrics.horizontalAdvance(textThirdLine) ); -#else - int textWidth = std::max( std::max( fmetrics.width(textFirstLine), fmetrics.width(knobLine) ), fmetrics.width(textThirdLine) ); -#endif QImage dragImg(textWidth, (fmetrics.height() + 5) * 3, QImage::Format_ARGB32); dragImg.fill( QColor(0, 0, 0, 200) ); QPainter p(&dragImg); diff --git a/Gui/Label.h b/Gui/Label.h index 19d9c86550..63b38f4d66 100644 --- a/Gui/Label.h +++ b/Gui/Label.h @@ -48,18 +48,10 @@ class Label Label(const QString &text, QWidget *parent = 0, -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) Qt::WindowFlags f = Qt::WindowFlags()); -#else - Qt::WindowFlags f = 0); -#endif Label(QWidget *parent = 0, -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) Qt::WindowFlags f = Qt::WindowFlags()); -#else - Qt::WindowFlags f = 0); -#endif bool getAltered() const; diff --git a/Gui/MultiInstancePanel.cpp b/Gui/MultiInstancePanel.cpp index 7a1bc87f0a..22b788d099 100644 --- a/Gui/MultiInstancePanel.cpp +++ b/Gui/MultiInstancePanel.cpp @@ -36,21 +36,12 @@ CLANG_DIAG_OFF(uninitialized) #include #include // QtCore on Qt4, QtConcurrent on Qt5 -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include #include #include #include #include #include -#else -#include -#include -#include -#include -#include -#include -#endif #include #include @@ -551,11 +542,7 @@ MultiInstancePanel::createMultiInstanceGui(QVBoxLayout* layout) _imp->view->setAttribute(Qt::WA_MacShowFocusRect, 0); _imp->view->setUniformRowHeights(true); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->view->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _imp->view->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif _imp->view->header()->setStretchLastSection(true); diff --git a/Gui/NodeGraph25.cpp b/Gui/NodeGraph25.cpp index 81f494285f..4b185f9a6e 100644 --- a/Gui/NodeGraph25.cpp +++ b/Gui/NodeGraph25.cpp @@ -391,18 +391,10 @@ NodeGraph::keyPressEvent(QKeyEvent* e) } else if ( isKeybind(kShortcutGroupNodegraph, kShortcutIDActionGraphTogglePreview, modifiers, key) ) { togglePreviewsForSelectedNodes(); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionZoomIn, Qt::NoModifier, key) ) { // zoom in/out doesn't care about modifiers -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) QWheelEvent e(mapFromGlobal( QCursor::pos() ), QCursor::pos(), QPoint(), QPoint(0, 120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); -#else - QWheelEvent e(mapFromGlobal( QCursor::pos() ), 120, Qt::NoButton, Qt::NoModifier); // one wheel click = +-120 delta -#endif wheelEvent(&e); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionZoomOut, Qt::NoModifier, key) ) { // zoom in/out doesn't care about modifiers -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) QWheelEvent e(mapFromGlobal( QCursor::pos() ), QCursor::pos(), QPoint(), QPoint(0, -120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); -#else - QWheelEvent e(mapFromGlobal( QCursor::pos() ), -120, Qt::NoButton, Qt::NoModifier); // one wheel click = +-120 delta -#endif wheelEvent(&e); } else if ( isKeybind(kShortcutGroupNodegraph, kShortcutIDActionGraphOpenNodePanel, modifiers, key) ) { if (_imp->_selection.size() == 1) { diff --git a/Gui/NodeGraph30.cpp b/Gui/NodeGraph30.cpp index 2cb3cbac05..e7a2453674 100644 --- a/Gui/NodeGraph30.cpp +++ b/Gui/NodeGraph30.cpp @@ -189,20 +189,11 @@ NodeGraph::wheelEventInternal(bool ctrlDown, void NodeGraph::wheelEvent(QWheelEvent* e) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (e->angleDelta().x() != 0) { -#else - if (e->orientation() != Qt::Vertical) { -#endif return; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) wheelEventInternal( modCASIsControl(e), e->angleDelta().y() ); _imp->_lastMousePos = QPoint(e->position().x(), e->position().y()); -#else - wheelEventInternal( modCASIsControl(e), e->delta() ); - _imp->_lastMousePos = e->pos(); -#endif update(); } diff --git a/Gui/NodeGui.cpp b/Gui/NodeGui.cpp index 9276bfca7f..3efe12077b 100644 --- a/Gui/NodeGui.cpp +++ b/Gui/NodeGui.cpp @@ -1011,11 +1011,7 @@ NodeGui::resize(int width, QString persistentMessage = _persistentMessage->text(); f.setPixelSize(25); metrics = QFontMetrics(f, 0); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int pMWidth = metrics.horizontalAdvance(persistentMessage); -#else - int pMWidth = metrics.width(persistentMessage); -#endif int midNodeX = topLeft.x() + iconWidth + (width - iconWidth) / 2; QPointF bitDepthPos(midNodeX, 0); _streamIssuesWarning->refreshPosition(bitDepthPos); @@ -1898,11 +1894,7 @@ NodeGui::hasEdgeNearbyRect(const QRectF & rect) edgeLine.setP1( (*it)->mapToScene( edgeLine.p1() ) ); edgeLine.setP2( (*it)->mapToScene( edgeLine.p2() ) ); for (int j = 0; j < 4; ++j) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType intersectType = edgeLine.intersects(rectEdges[j], &intersection); -#else - QLineF::IntersectType intersectType = edgeLine.intersect(rectEdges[j], &intersection); -#endif if (intersectType == QLineF::BoundedIntersection) { if (!closest) { closest = *it; @@ -1930,11 +1922,7 @@ NodeGui::hasEdgeNearbyRect(const QRectF & rect) edgeLine.setP1( (_outputEdge)->mapToScene( edgeLine.p1() ) ); edgeLine.setP2( (_outputEdge)->mapToScene( edgeLine.p2() ) ); for (int j = 0; j < 4; ++j) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType intersectType = edgeLine.intersects(rectEdges[j], &intersection); -#else - QLineF::IntersectType intersectType = edgeLine.intersect(rectEdges[j], &intersection); -#endif if (intersectType == QLineF::BoundedIntersection) { return _outputEdge; } @@ -2913,11 +2901,7 @@ struct NodeGuiIndicatorPrivate textItem->setBrush(textColor); textItem->setZValue(depth); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - textItem->scale(0.8, 0.8); -#else textItem->setScale(0.8); -#endif } }; diff --git a/Gui/NodeSettingsPanel.cpp b/Gui/NodeSettingsPanel.cpp index 3ec8671015..cc0bd37fc6 100644 --- a/Gui/NodeSettingsPanel.cpp +++ b/Gui/NodeSettingsPanel.cpp @@ -32,11 +32,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#else -#include -#endif #include "Global/FStreamsSupport.h" diff --git a/Gui/PreferencesPanel.cpp b/Gui/PreferencesPanel.cpp index d5f847a08c..375e358713 100644 --- a/Gui/PreferencesPanel.cpp +++ b/Gui/PreferencesPanel.cpp @@ -32,11 +32,7 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_OFF(uninitialized) #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #include -#else -#include -#endif #include #include @@ -520,11 +516,7 @@ PreferencesPanel::createPluginsView(QGridLayout* pluginsFrameLayout) treeHeader->setText( COL_GL_ENABLED, tr("OpenGL") ); _imp->pluginsView->setHeaderItem(treeHeader); _imp->pluginsView->setSelectionMode(QAbstractItemView::NoSelection); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->pluginsView->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _imp->pluginsView->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif _imp->pluginsView->setSortingEnabled(true); const PluginsMap& plugins = appPTR->getPluginsList(); @@ -765,11 +757,7 @@ PreferencesPanel::createGui() uiTabTreeItem = _imp->tabs[i].treeItem; } QString label = QString::fromUtf8( pageKnob->getLabel().c_str() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int w = fm.horizontalAdvance(label); -#else - int w = fm.width(label); -#endif maxLength = std::max(w, maxLength); } assert(pluginsFrameLayout); @@ -1212,13 +1200,8 @@ PreferencesPanel::saveChangesAndClose() void PreferencesPanel::showEvent(QShowEvent* /*e*/) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QScreen* desktop = QGuiApplication::primaryScreen(); const QRect rect = desktop->availableGeometry(); -#else - QDesktopWidget* desktop = QApplication::desktop(); - const QRect rect = desktop->screenGeometry(); -#endif move( QPoint(rect.width() / 2 - width() / 2, rect.height() / 2 - height() / 2) ); diff --git a/Gui/PythonPanels.cpp b/Gui/PythonPanels.cpp index ea0e5b29fe..20f8f6d285 100644 --- a/Gui/PythonPanels.cpp +++ b/Gui/PythonPanels.cpp @@ -334,7 +334,6 @@ PyModalDialog::getParam(const QString& scriptName) const return Effect::createParamWrapperForKnob(knob); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QSize PyModalDialog::minimumSizeHint() const { @@ -346,7 +345,6 @@ PyModalDialog::sizeHint() const { return QWidget::sizeHint(); } -#endif struct PyPanelPrivate { diff --git a/Gui/PythonPanels.h b/Gui/PythonPanels.h index 2a688fca27..c5f83ed529 100644 --- a/Gui/PythonPanels.h +++ b/Gui/PythonPanels.h @@ -103,11 +103,9 @@ class PyModalDialog void addWidget(QWidget* widget); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) virtual QSize minimumSizeHint() const OVERRIDE FINAL; virtual QSize sizeHint() const OVERRIDE FINAL; -#endif DialogParamHolder* getKnobsHolder() const; diff --git a/Gui/QGLExtrasCompat.h b/Gui/QGLExtrasCompat.h deleted file mode 100644 index eef1353c62..0000000000 --- a/Gui/QGLExtrasCompat.h +++ /dev/null @@ -1,42 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * This file is part of Natron , - * (C) 2018-2023 The Natron developers - * (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat - * - * Natron is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Natron is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Natron. If not, see - * ***** END LICENSE BLOCK ***** */ - -// This is a header that provides type declarations that map a subset of the newer QOpenGL -// classes used by Natron with their older QGL counterparts - -#ifndef NATRON_GUI_QGLEXTRASCOMPAT_H -#define NATRON_GUI_QGLEXTRASCOMPAT_H - -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -#error "This file must not be included while using Qt >= 5.4.0" -#endif - -#include "Global/Macros.h" - -// QGL was deprecated in macOS -CLANG_DIAG_OFF(deprecated) -#include -#include -CLANG_DIAG_ON(deprecated) - -typedef QGLShaderProgram QOpenGLShaderProgram; -typedef QSharedPointer QOpenGLShaderProgramPtr; -typedef QGLShader QOpenGLShader; - -#endif // NATRON_GUI_QGLEXTRASCOMPAT_H diff --git a/Gui/QGLWidgetCompat.h b/Gui/QGLWidgetCompat.h deleted file mode 100644 index 67194fad65..0000000000 --- a/Gui/QGLWidgetCompat.h +++ /dev/null @@ -1,39 +0,0 @@ -/* ***** BEGIN LICENSE BLOCK ***** - * This file is part of Natron , - * (C) 2018-2023 The Natron developers - * (C) 2013-2018 INRIA and Alexandre Gauthier-Foichat - * - * Natron is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * Natron is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Natron. If not, see - * ***** END LICENSE BLOCK ***** */ - -// This is a header that provides type declarations that map a subset of the newer QOpenGL -// classes used by Natron with their older QGL counterparts - -#ifndef NATRON_GUI_QGLWIDGETCOMPAT_H -#define NATRON_GUI_QGLWIDGETCOMPAT_H - -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) -#error "This file must not be included while using Qt >= 5.4.0" -#endif - -#include "Global/Macros.h" - -CLANG_DIAG_OFF(deprecated) -#include -CLANG_DIAG_ON(deprecated) - -typedef QGLWidget QOpenGLWidget; -typedef QGLContext QOpenGLContext; - -#endif // NATRON_GUI_QGLWIDGETCOMPAT_H diff --git a/Gui/QtColorTriangle.cpp b/Gui/QtColorTriangle.cpp index bee6f20a17..5af0690b3b 100644 --- a/Gui/QtColorTriangle.cpp +++ b/Gui/QtColorTriangle.cpp @@ -221,11 +221,7 @@ void QtColorTriangle::genBackground() QConicalGradient gradient(bg.rect().center(), 90); QColor color; for (double i = 0; i <= 1.0; i += 0.1) { -#if QT_VERSION < 0x040100 - color.setHsv(int(i * 360.0), 255, 255); -#else color.setHsv(int(360.0 - (i * 360.0)), 255, 255); -#endif gradient.setColorAt(i, color); } diff --git a/Gui/QtMac.mm b/Gui/QtMac.mm index 180bd08abb..ebc0e09a13 100644 --- a/Gui/QtMac.mm +++ b/Gui/QtMac.mm @@ -88,18 +88,6 @@ - (NSRect)convertRectFromBacking:(NSRect)aRect; NATRON_NAMESPACE_ENTER -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -qreal -QtMac::devicePixelRatioInternal(const QWidget* w) { - CGFloat scaleFactor = 1.0; - NSView* view = reinterpret_cast(w->winId()); - if ([[view window] respondsToSelector: @selector(backingScaleFactor)]) - scaleFactor = [[view window] backingScaleFactor]; - - return qreal(scaleFactor); -} -#endif - #if OBJC_OLD_DISPATCH_PROTOTYPES != 1 void QtMac::setupDockClickHandler(void (*dockClickHandler)(void)) { diff --git a/Gui/RenderStatsDialog.cpp b/Gui/RenderStatsDialog.cpp index f8901044f9..a0ca891714 100644 --- a/Gui/RenderStatsDialog.cpp +++ b/Gui/RenderStatsDialog.cpp @@ -900,12 +900,7 @@ RenderStatsDialog::RenderStatsDialog(Gui* gui) _imp->view->setSelectionMode(QAbstractItemView::SingleSelection); _imp->view->setSelectionBehavior(QAbstractItemView::SelectRows); - -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->view->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _imp->view->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif _imp->view->header()->setStretchLastSection(true); _imp->view->setUniformRowHeights(true); _imp->view->setSortingEnabled(true); diff --git a/Gui/RotoPanel.cpp b/Gui/RotoPanel.cpp index 05e7c2762d..9c4f8a8a19 100644 --- a/Gui/RotoPanel.cpp +++ b/Gui/RotoPanel.cpp @@ -674,11 +674,7 @@ RotoPanel::RotoPanel(const NodeGuiPtr& n, _imp->treeHeader->setIcon( COL_OPERATOR, QIcon(pixmerge) ); _imp->tree->setHeaderItem(_imp->treeHeader); _imp->tree->setMinimumHeight( TO_DPIY(350) ); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->tree->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _imp->tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif _imp->buttonContainer = new QWidget(this); _imp->buttonLayout = new QHBoxLayout(_imp->buttonContainer); _imp->buttonLayout->setContentsMargins(0, 0, 0, 0); @@ -2517,17 +2513,9 @@ RotoPanel::onSettingsPanelClosed(bool closed) void RotoPanel::onOperatorColMinimumSizeChanged(const QSize& size) { -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->tree->header()->setResizeMode(QHeaderView::Fixed); -#else _imp->tree->header()->setSectionResizeMode(QHeaderView::Fixed); -#endif _imp->tree->setColumnWidth( COL_OPERATOR, size.width() ); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->tree->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _imp->tree->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif } ////////////////////////////// diff --git a/Gui/ScaleSliderQWidget.cpp b/Gui/ScaleSliderQWidget.cpp index 2292ad93c3..1f556802f6 100644 --- a/Gui/ScaleSliderQWidget.cpp +++ b/Gui/ScaleSliderQWidget.cpp @@ -510,11 +510,7 @@ ScaleSliderQWidget::paintEvent(QPaintEvent* /*e*/) ticks_fill(half_tick, ticks_max, m1, m2, &ticks); const double smallestTickSize = range * smallestTickSizePixel / rangePixel; const double largestTickSize = range * largestTickSizePixel / rangePixel; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const double minTickSizeTextPixel = fontM.horizontalAdvance( QLatin1String("00") ); // AXIS-SPECIFIC -#else - const double minTickSizeTextPixel = fontM.width( QLatin1String("00") ); // AXIS-SPECIFIC -#endif const double minTickSizeText = range * minTickSizeTextPixel / rangePixel; for (int i = m1; i <= m2; ++i) { double value = i * smallTickSize + offset; @@ -541,11 +537,7 @@ ScaleSliderQWidget::paintEvent(QPaintEvent* /*e*/) if ( renderFloating && (tickSize > minTickSizeText) ) { const int tickSizePixel = rangePixel * tickSize / range; const QString s = QString::number(value); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const int sSizePixel = fontM.horizontalAdvance(s); -#else - const int sSizePixel = fontM.width(s); -#endif if (tickSizePixel > sSizePixel) { const int sSizeFullPixel = sSizePixel + minTickSizeTextPixel; double alphaText = 1.0; //alpha; @@ -562,11 +554,7 @@ ScaleSliderQWidget::paintEvent(QPaintEvent* /*e*/) QPointF textPos = _imp->zoomCtx.toWidgetCoordinates( value, btmLeft.y() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int textWidth = fontM.horizontalAdvance(s); -#else - int textWidth = fontM.width(s); -#endif int textX = std::floor(textPos.x() + 0.5); int textY = std::floor(textPos.y() + 0.5); // center the text, and make sure it fits diff --git a/Gui/ScriptEditor.cpp b/Gui/ScriptEditor.cpp index 9e1fcf2f59..612d4d9871 100644 --- a/Gui/ScriptEditor.cpp +++ b/Gui/ScriptEditor.cpp @@ -249,13 +249,8 @@ ScriptEditor::ScriptEditor(Gui* gui) _imp->inputEdit = new InputScriptTextEdit(gui, this); QObject::connect( _imp->inputEdit, SIGNAL(textChanged()), this, SLOT(onInputScriptTextChanged()) ); QFontMetrics fm = _imp->inputEdit->fontMetrics(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->inputEdit->setTabStopDistance(fm.horizontalAdvance( QLatin1Char(' ') ) * 4); _imp->outputEdit->setTabStopDistance(fm.horizontalAdvance( QLatin1Char(' ') ) * 4); -#else - _imp->inputEdit->setTabStopWidth(fm.width( QLatin1Char(' ') ) * 4); - _imp->outputEdit->setTabStopWidth(fm.width( QLatin1Char(' ') ) * 4); -#endif _imp->mainLayout->addWidget(_imp->buttonsContainer); splitter->addWidget(_imp->outputEdit); diff --git a/Gui/ScriptTextEdit.cpp b/Gui/ScriptTextEdit.cpp index b9ebbbfe3a..74cd9779f1 100644 --- a/Gui/ScriptTextEdit.cpp +++ b/Gui/ScriptTextEdit.cpp @@ -340,11 +340,7 @@ InputScriptTextEdit::getLineNumberAreaWidth() ++digits; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) return 3 + fontMetrics().horizontalAdvance( QLatin1Char('9') ) * digits; -#else - return 3 + fontMetrics().width( QLatin1Char('9') ) * digits; -#endif } void diff --git a/Gui/SequenceFileDialog.cpp b/Gui/SequenceFileDialog.cpp index 345312de8b..eb73ea80e7 100644 --- a/Gui/SequenceFileDialog.cpp +++ b/Gui/SequenceFileDialog.cpp @@ -61,19 +61,11 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_OFF #include GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#include -#include -#include -#include -#include -#else #include #include #include #include #include -#endif #include #include #include @@ -1248,11 +1240,7 @@ SequenceItemDelegate::sizeHint(const QStyleOptionViewItem & option, QString str = index.data(FileSystemModel::FilePathRole).toString(); QFontMetrics metric(option.font); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) return QSize( metric.horizontalAdvance(str), metric.height() ); -#else - return QSize( metric.width(str), metric.height() ); -#endif } void @@ -2464,12 +2452,7 @@ FileDialogComboBox::sizeHint() const if ( (index >= 0) && ( index < count() ) ) { QFontMetrics fm = fontMetrics(); QString txt = itemText(index); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int w = fm.horizontalAdvance(txt); -#else - int w = fm.width(txt); -#endif - return QSize(w + 10, fm.height() * 1.5); } diff --git a/Gui/SpinBox.cpp b/Gui/SpinBox.cpp index 45deddefa9..64de42c301 100644 --- a/Gui/SpinBox.cpp +++ b/Gui/SpinBox.cpp @@ -628,23 +628,14 @@ SpinBox::wheelEvent(QWheelEvent* e) if (ignoreWheelEvent) { return LineEdit::wheelEvent(e); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if ( (e->angleDelta().x() != 0) || ( e->angleDelta().y() == 0) || -#else - if ( (e->orientation() != Qt::Vertical) || - ( e->delta() == 0) || -#endif !isEnabled() || isReadOnly() || !hasFocus() ) { // wheel is only effective when the widget has focus (click it first, then wheel) return; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) int delta = e->angleDelta().y(); -#else - int delta = e->delta(); -#endif int shift = 0; if ( modCASIsShift(e) ) { shift = 1; diff --git a/Gui/SplashScreen.cpp b/Gui/SplashScreen.cpp index 1dc878e7a7..f3e44f2585 100644 --- a/Gui/SplashScreen.cpp +++ b/Gui/SplashScreen.cpp @@ -33,11 +33,7 @@ CLANG_DIAG_OFF(deprecated) #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) #include -#else -#include -#endif CLANG_DIAG_ON(deprecated) @@ -81,15 +77,6 @@ SplashScreen::SplashScreen(const QString & filePath) _pixmap.load(filePath); _scale = 1.; -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#if defined(Q_OS_WIN) - // code from Gui::devicePixelRatio() - HDC wscreen = GetDC(winId()); - FLOAT horizontalDPI = GetDeviceCaps(wscreen, LOGPIXELSX); - ReleaseDC(0, wscreen); - _scale = static_cast(horizontalDPI) / 96.; -#endif -#endif if (_scale != 1.) { _pixmap = _pixmap.scaled( int(_pixmap.width() * _scale), int(_pixmap.height() * _scale), Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -102,13 +89,8 @@ SplashScreen::SplashScreen(const QString & filePath) show(); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QScreen* desktop = QGuiApplication::primaryScreen(); QRect screen = desktop->availableGeometry(); -#else - QDesktopWidget* desktop = QApplication::desktop(); - QRect screen = desktop->screenGeometry(); -#endif move(screen.width() / 2 - width() / 2, screen.height() / 2 - height() / 2); } @@ -153,15 +135,6 @@ LoadProjectSplashScreen::LoadProjectSplashScreen(const QString & filePath) _pixmap.load( QString::fromUtf8(":Resources/Images/loadProjectSplashscreen.png") ); _scale = 1.; -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#if defined(Q_OS_WIN) - // code from Gui::devicePixelRatio() - HDC wscreen = GetDC(winId()); - FLOAT horizontalDPI = GetDeviceCaps(wscreen, LOGPIXELSX); - ReleaseDC(0, wscreen); - _scale = static_cast(horizontalDPI) / 96.; -#endif -#endif if (_scale != 1.) { _pixmap = _pixmap.scaled( int(_pixmap.width() * _scale), int(_pixmap.height() * _scale), Qt::KeepAspectRatio, Qt::SmoothTransformation); @@ -169,13 +142,8 @@ LoadProjectSplashScreen::LoadProjectSplashScreen(const QString & filePath) resize( _pixmap.width(), _pixmap.height() ); show(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) QScreen* desktop = QGuiApplication::primaryScreen(); QRect screen = desktop->availableGeometry(); -#else - QDesktopWidget* desktop = QApplication::desktop(); - QRect screen = desktop->screenGeometry(); -#endif move(screen.width() / 2 - width() / 2, screen.height() / 2 - height() / 2); } @@ -209,11 +177,7 @@ LoadProjectSplashScreen::paintEvent(QPaintEvent* /*e*/) QString loadString( tr("Loading ") ); QFontMetrics fm = p.fontMetrics(); QPointF loadStrPos(300 * _scale, _pixmap.height() / 2.); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) p.drawText(QPointF(loadStrPos.x() + (fm.horizontalAdvance(loadString) + 5) * _scale, _pixmap.height() / 2.), _projectName); -#else - p.drawText(QPointF(loadStrPos.x() + (fm.width(loadString) + 5) * _scale, _pixmap.height() / 2.), _projectName); -#endif p.setPen( QColor(243, 137, 0) ); p.drawText(loadStrPos, loadString); } diff --git a/Gui/TabWidget.cpp b/Gui/TabWidget.cpp index 22dcc77856..9ab7d999e5 100644 --- a/Gui/TabWidget.cpp +++ b/Gui/TabWidget.cpp @@ -1521,11 +1521,7 @@ TabBar::makePixmapForDrag(int index) addTab(tabs[index].second, tabs[index].first); QPixmap currentTabPixmap = Gui::screenShot( _tabWidget->tabAt(index)->getWidget() ); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - QPixmap tabBarPixmap = QPixmap::grabWidget(this); -#else QPixmap tabBarPixmap = grab(); -#endif ///re-insert all the tabs into the tab bar removeTab(0); @@ -1538,15 +1534,6 @@ TabBar::makePixmapForDrag(int index) QImage tabBarImg = tabBarPixmap.toImage(); QImage currentTabImg = currentTabPixmap.toImage(); -#if defined(Q_OS_DARWIN) && (QT_VERSION < QT_VERSION_CHECK(5, 0, 0)) - ///Prevent a bug with grabWidget and retina display on Qt4 - qreal devicePixelRatio = _tabWidget->getGui()->devicePixelRatio(); - if (devicePixelRatio > 1) { - tabBarImg = tabBarImg.scaled(tabBarImg.width() / devicePixelRatio, tabBarImg.height() / devicePixelRatio); - currentTabImg = currentTabImg.scaled(currentTabImg.width() / devicePixelRatio, currentTabImg.height() / devicePixelRatio); - } -#endif - //now we just put together the 2 pixmaps and set it with mid transparency QImage ret(currentTabImg.width(), currentTabImg.height() + tabBarImg.height(), QImage::Format_ARGB32_Premultiplied); diff --git a/Gui/TableModelView.cpp b/Gui/TableModelView.cpp index beeaaff85b..2840793d00 100644 --- a/Gui/TableModelView.cpp +++ b/Gui/TableModelView.cpp @@ -917,21 +917,12 @@ ExpandingLineEdit::updateMinimumWidth() { int left, right; -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) QMargins textMargin = textMargins(); int width = textMargin.left() + textMargin.right() + 4; QMargins contentMargin = contentsMargins(); width += contentMargin.left() + contentMargin.right(); QStyleOptionFrame opt; -#else - getTextMargins(&left, 0, &right, 0); - int width = left + right + 4 /*horizontalMargin in qlineedit.cpp*/; - getContentsMargins(&left, 0, &right, 0); - width += left + right; - - QStyleOptionFrameV2 opt; -#endif initStyleOption(&opt); int minWidth = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(width, 0). @@ -949,11 +940,7 @@ ExpandingLineEdit::resizeToContents() } if ( QWidget * parent = parentWidget() ) { QPoint position = pos(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int hintWidth = minimumWidth() + fontMetrics().horizontalAdvance( displayText() ); -#else - int hintWidth = minimumWidth() + fontMetrics().width( displayText() ); -#endif int parentWidth = parent->width(); int maxWidth = isRightToLeft() ? position.x() + oldWidth : parentWidth - position.x(); int newWidth = qBound(originalWidth, hintWidth, maxWidth); @@ -967,15 +954,9 @@ ExpandingLineEdit::resizeToContents() } } -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -QWidget* -TableItemEditorFactory::createEditor(QVariant::Type userType, - QWidget *parent) const -#else QWidget* TableItemEditorFactory::createEditor(int userType, QWidget *parent) const -#endif { switch (userType) { case QVariant::UInt: { @@ -1020,13 +1001,8 @@ TableItemEditorFactory::createEditor(int userType, return 0; } -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -QByteArray -TableItemEditorFactory::valuePropertyName(QVariant::Type userType) const -#else QByteArray TableItemEditorFactory::valuePropertyName(int userType) const -#endif { switch (userType) { case QVariant::UInt: diff --git a/Gui/TableModelView.h b/Gui/TableModelView.h index 990bf47610..d81040e3ba 100644 --- a/Gui/TableModelView.h +++ b/Gui/TableModelView.h @@ -265,13 +265,8 @@ class TableItemEditorFactory { } -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - virtual QWidget * createEditor(QVariant::Type type, QWidget *parent) const OVERRIDE FINAL; - virtual QByteArray valuePropertyName(QVariant::Type type) const OVERRIDE FINAL; -#else virtual QWidget * createEditor(int userType, QWidget *parent) const OVERRIDE FINAL; virtual QByteArray valuePropertyName(int userType) const OVERRIDE FINAL; -#endif }; diff --git a/Gui/TextRenderer.cpp b/Gui/TextRenderer.cpp index ab7886e47f..e24922a9c5 100644 --- a/Gui/TextRenderer.cpp +++ b/Gui/TextRenderer.cpp @@ -38,12 +38,8 @@ CLANG_DIAG_ON(uninitialized) #include "Global/GLIncludes.h" //!= QT_VERSION_CHECK(5, 4, 0) #include #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif NATRON_NAMESPACE_ENTER @@ -150,9 +146,6 @@ TextRendererPrivate::newTransparentTexture() QImage image(TEXTURE_SIZE, TEXTURE_SIZE, QImage::Format_ARGB32); image.fill(Qt::transparent); -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - image = QOpenGLWidget::convertToGLFormat(image); -#endif glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, TEXTURE_SIZE, TEXTURE_SIZE, 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits() ); @@ -178,11 +171,7 @@ TextRendererPrivate::createCharacter(QChar c) } GLuint texture = _usedTextures.back(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) GLsizei width = _fontMetrics.horizontalAdvance(c); -#else - GLsizei width = _fontMetrics.width(c); -#endif GLsizei height = _fontMetrics.height(); // render into a new transparent pixmap using QPainter @@ -200,9 +189,6 @@ TextRendererPrivate::createCharacter(QChar c) // fill the texture with the QImage -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - image = QOpenGLWidget::convertToGLFormat(image); -#endif glCheckError(); GLuint savedTexture; @@ -294,11 +280,7 @@ TextRenderer::renderText(float x, if (flags & Qt::AlignHCenter || flags & Qt::AlignRight) { int width = 0; for (int i = 0; i < text.length(); ++i) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) width += p->_fontMetrics.horizontalAdvance(text[i]); -#else - width += p->_fontMetrics.width(text[i]); -#endif } if (flags & Qt::AlignHCenter) { x -= width/2. * scalex; @@ -342,7 +324,6 @@ TextRenderer::renderText(float x, assert( glIsTexture(texture) ); } glCheckError(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) glBegin(GL_QUADS); glTexCoord2f(c->xTexCoords[0], c->yTexCoords[1]); glVertex2f(0, 0); @@ -352,17 +333,6 @@ TextRenderer::renderText(float x, glVertex2f(c->w * scalex, c->h * scaley); glTexCoord2f(c->xTexCoords[0], c->yTexCoords[0]); glVertex2f(0, c->h * scaley); -#else - glBegin(GL_QUADS); - glTexCoord2f(c->xTexCoords[0], c->yTexCoords[0]); - glVertex2f(0, 0); - glTexCoord2f(c->xTexCoords[1], c->yTexCoords[0]); - glVertex2f(c->w * scalex, 0); - glTexCoord2f(c->xTexCoords[1], c->yTexCoords[1]); - glVertex2f(c->w * scalex, c->h * scaley); - glTexCoord2f(c->xTexCoords[0], c->yTexCoords[1]); - glVertex2f(0, c->h * scaley); -#endif glEnd(); glCheckErrorIgnoreOSXBug(); glTranslatef(c->w * scalex, 0, 0); diff --git a/Gui/TimeLineGui.cpp b/Gui/TimeLineGui.cpp index 433c62ed58..585466e7ad 100644 --- a/Gui/TimeLineGui.cpp +++ b/Gui/TimeLineGui.cpp @@ -62,9 +62,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/ViewerTab.h" #include "Gui/ticks.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif NATRON_NAMESPACE_ENTER @@ -546,11 +544,7 @@ TimeLineGui::paintGL() ticks_fill(half_tick, ticks_max, m1, m2, &ticks); const double smallestTickSize = range * smallestTickSizePixel / rangePixel; const double largestTickSize = range * largestTickSizePixel / rangePixel; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const double minTickSizeTextPixel = ( _imp->isTimeFormatFrames ? fm.horizontalAdvance( QLatin1String("00000") ) : fm.horizontalAdvance( QLatin1String("00:00:00:00") ) ) / _imp->_screenPixelRatio; -#else - const double minTickSizeTextPixel = ( _imp->isTimeFormatFrames ? fm.width( QLatin1String("00000") ) : fm.width( QLatin1String("00:00:00:00") ) ) / _imp->_screenPixelRatio; // AXIS-SPECIFIC -#endif const double minTickSizeText = range * minTickSizeTextPixel / rangePixel; for (int i = m1; i <= m2; ++i) { double value = i * smallTickSize + offset; @@ -574,11 +568,7 @@ TimeLineGui::paintGL() if (tickSize > minTickSizeText) { const int tickSizePixel = rangePixel * tickSize / range; const QString s = _imp->isTimeFormatFrames ? QString::number(value) : timecodeString(value, fps); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) const int sSizePixel = fm.horizontalAdvance(s) / _imp->_screenPixelRatio; -#else - const int sSizePixel = fm.width(s) / _imp->_screenPixelRatio; -#endif if (tickSizePixel > sSizePixel) { const int sSizeFullPixel = sSizePixel + minTickSizeTextPixel; double alphaText = 1.0; //alpha; @@ -1093,28 +1083,17 @@ TimeLineGui::mouseReleaseEvent(QMouseEvent* e) void TimeLineGui::wheelEvent(QWheelEvent* e) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (e->angleDelta().x() != 0) { return; } const double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->angleDelta().y() ); -#else - if (e->orientation() != Qt::Vertical) { - return; - } - const double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->delta() ); // no need to use ipow() here, because the result is not cast to int -#endif double newZoomFactor = _imp->tlZoomCtx.zoomFactor * scaleFactor; if (newZoomFactor <= 0.01) { // 1 pixel for 100 frames newZoomFactor = 0.01; } else if (newZoomFactor > 100.) { // 100 pixels per frame seems reasonable, see also DopeSheetView::wheelEvent() newZoomFactor = 100.; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QPointF zoomCenter = toTimeLineCoordinates( e->position().x(), e->position().y() ); -#else - QPointF zoomCenter = toTimeLineCoordinates( e->x(), e->y() ); -#endif double zoomRatio = _imp->tlZoomCtx.zoomFactor / newZoomFactor; _imp->tlZoomCtx.left = zoomCenter.x() - (zoomCenter.x() - _imp->tlZoomCtx.left) * zoomRatio; _imp->tlZoomCtx.bottom = zoomCenter.y() - (zoomCenter.y() - _imp->tlZoomCtx.bottom) * zoomRatio; diff --git a/Gui/TimeLineGui.h b/Gui/TimeLineGui.h index 431dae1a8e..43dbbcd234 100644 --- a/Gui/TimeLineGui.h +++ b/Gui/TimeLineGui.h @@ -39,11 +39,7 @@ CLANG_DIAG_OFF(uninitialized) CLANG_DIAG_ON(deprecated) CLANG_DIAG_ON(uninitialized) -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif #include "Global/GlobalDefines.h" diff --git a/Gui/TrackerPanel.cpp b/Gui/TrackerPanel.cpp index 0310034174..dd0c32be29 100644 --- a/Gui/TrackerPanel.cpp +++ b/Gui/TrackerPanel.cpp @@ -468,11 +468,7 @@ TrackerPanel::TrackerPanel(const NodeGuiPtr& n, _imp->view->setAttribute(Qt::WA_MacShowFocusRect, 0); -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) - _imp->view->header()->setResizeMode(QHeaderView::ResizeToContents); -#else _imp->view->header()->setSectionResizeMode(QHeaderView::ResizeToContents); -#endif _imp->view->header()->setStretchLastSection(true); _imp->mainLayout->addWidget(_imp->view); diff --git a/Gui/VerticalColorBar.h b/Gui/VerticalColorBar.h index af7b4471b2..ba8dabaecd 100644 --- a/Gui/VerticalColorBar.h +++ b/Gui/VerticalColorBar.h @@ -32,11 +32,7 @@ CLANG_DIAG_OFF(deprecated) CLANG_DIAG_OFF(uninitialized) #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#else -#include -#endif #include CLANG_DIAG_ON(deprecated) diff --git a/Gui/ViewerGL.cpp b/Gui/ViewerGL.cpp index b8aaf3f122..98ed44f438 100644 --- a/Gui/ViewerGL.cpp +++ b/Gui/ViewerGL.cpp @@ -34,17 +34,11 @@ #include "Global/GLIncludes.h" //!= QT_VERSION_CHECK(5, 0, 0) #include #include #include // qApp #include #include -#else -#include -#include -#include // qApp -#endif GCC_DIAG_UNUSED_PRIVATE_FIELD_OFF // /opt/local/include/QtGui/qmime.h:119:10: warning: private field 'type' is not used [-Wunused-private-field] @@ -54,11 +48,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLExtrasCompat.h" -#endif #include "Engine/Lut.h" #include "Engine/Node.h" @@ -91,9 +81,7 @@ GCC_DIAG_UNUSED_PRIVATE_FIELD_ON #include "Gui/TabWidget.h" #include "Gui/ViewerTab.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif #define USER_ROI_BORDER_TICK_SIZE 15.f @@ -126,11 +114,7 @@ NATRON_NAMESPACE_ENTER ViewerGL::ViewerGL(ViewerTab* parent, const QOpenGLWidget* shareWidget) -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) : QOpenGLWidget(parent) -#else - : QOpenGLWidget(parent, shareWidget) -#endif , _imp( new Implementation(this, parent) ) { // always running in the main thread @@ -194,11 +178,7 @@ ViewerGL::resizeGL(int w, glViewport (0, 0, w, h); double zoomWidth = w; double zoomHeight = h; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - double screenPixelRatio = getScreenPixelRatio(); - zoomWidth /= screenPixelRatio; - zoomHeight /= screenPixelRatio; -#endif + assert( zoomWidth == width() && zoomHeight == height() ); // if this crashes here, then the viewport size has to be stored to compute glShadow bool zoomSinceLastFit; double oldWidth, oldHeight; @@ -585,11 +565,6 @@ ViewerGL::centerWipe() QPoint pos = mapFromGlobal( QCursor::pos() ); int x = pos.x(); int y = pos.y(); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) && QT_VERSION < QT_VERSION_CHECK(5, 4, 0) - double screenPixelRatio = getScreenPixelRatio(); - x *= screenPixelRatio; - y *= screenPixelRatio; -#endif QPointF zoomPos = toZoomCoordinates( QPointF(x, y) ); @@ -1136,11 +1111,7 @@ wordWrap(const QFontMetrics& fm, for (int i = 0; i < words.size(); ++i) { QString word = words[i]; -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) int wordPixels = fm.horizontalAdvance(word); -#else - int wordPixels = fm.width(word); -#endif // If adding the new word to the current line would be too long, // then put it on a new line (and split it up if it's too long). @@ -1167,11 +1138,7 @@ wordWrap(const QFontMetrics& fm, stringL.push_back(curString); curString.clear(); } -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) wordPixels = fm.horizontalAdvance(word); -#else - wordPixels = fm.width(word); -#endif //tmp.append('\n'); } @@ -1753,11 +1720,7 @@ ViewerGL::setLut(int lut) _imp->displayingImageLut = (ViewerColorSpaceEnum)lut; } -#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) -#define QMouseEventLocalPos(e) ( e->posF() ) -#else #define QMouseEventLocalPos(e) ( e->localPos() ) -#endif void ViewerGL::mousePressEvent(QMouseEvent* e) @@ -2768,11 +2731,8 @@ ViewerGL::wheelEvent(QWheelEvent* e) if ( modCASIsControl(e) ) { const int delta_max = 28; // threshold delta to the range -delta_max..delta_max -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) int delta = std::max( -delta_max, std::min(e->angleDelta().y(), delta_max) ); -#else - int delta = std::max( -delta_max, std::min(e->delta(), delta_max) ); -#endif + _imp->wheelDeltaSeekFrame += delta; if (_imp->wheelDeltaSeekFrame <= -delta_max) { _imp->wheelDeltaSeekFrame += delta_max; @@ -2785,11 +2745,7 @@ ViewerGL::wheelEvent(QWheelEvent* e) return; } -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) if (e->angleDelta().x() != 0) { -#else - if (e->orientation() != Qt::Vertical) { -#endif // we only handle vertical motion for zooming return QOpenGLWidget::wheelEvent(e); } @@ -2806,18 +2762,10 @@ ViewerGL::wheelEvent(QWheelEvent* e) double zoomFactor; unsigned int oldMipmapLevel, newMipmapLevel; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->angleDelta().y() ); -#else - double scaleFactor = std::pow( NATRON_WHEEL_ZOOM_PER_DELTA, e->delta() ); // no need to use ipow() here, because the result is not cast to int -#endif { QMutexLocker l(&_imp->zoomCtxMutex); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QPointF zoomCenter = _imp->zoomCtx.toZoomCoordinates( e->position().x(), e->position().y() ); -#else - QPointF zoomCenter = _imp->zoomCtx.toZoomCoordinates( e->x(), e->y() ); -#endif zoomFactor = _imp->zoomCtx.factor(); //oldMipmapLevel = std::log( zoomFactor >= 1 ? 1 : ipow( 2, -std::ceil(std::log(zoomFactor) / M_LN2) ) ) / M_LN2; @@ -3598,12 +3546,8 @@ ViewerGL::swapOpenGLBuffers() { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) // calls glSwapBuffers in the widget stack as described in https://doc.qt.io/qt-5/qopenglwidget.html#threading update(); -#else - swapBuffers(); -#endif } /** @@ -3622,11 +3566,7 @@ ViewerGL::redrawNow() { // always running in the main thread assert( qApp && qApp->thread() == QThread::currentThread() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) update(); -#else - updateGL(); -#endif } /** @@ -3661,11 +3601,7 @@ ViewerGL::getPixelScale(double & xScale, double ViewerGL::getScreenPixelRatio() const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) return devicePixelRatio(); -#else - return (_imp->viewerTab && _imp->viewerTab->getGui()) ? _imp->viewerTab->getGui()->devicePixelRatio() : 1.; -#endif } #endif @@ -3699,11 +3635,7 @@ ViewerGL::getWidgetFontHeight() const int ViewerGL::getStringWidthForCurrentFont(const std::string& string) const { -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) return fontMetrics().horizontalAdvance( QString::fromUtf8( string.c_str() ) ); -#else - return fontMetrics().width( QString::fromUtf8( string.c_str() ) ); -#endif } void @@ -4636,14 +4568,11 @@ ViewerGL::getViewerFrameRange(int* first, double ViewerGL::currentTimeForEvent(QInputEvent* e) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) // timestamp() is usually in milliseconds if ( e->timestamp() ) { return (double)e->timestamp() / 1000000; } -#else - Q_UNUSED(e); -#endif + // Qt 4 has no event timestamp, use gettimeofday (defined in Timer.cpp for windows) struct timeval now; gettimeofday(&now, 0); diff --git a/Gui/ViewerGL.h b/Gui/ViewerGL.h index 1dc11c04d9..7da7b4161e 100644 --- a/Gui/ViewerGL.h +++ b/Gui/ViewerGL.h @@ -36,11 +36,7 @@ #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLWidgetCompat.h" -#endif #include "Engine/OpenGLViewerI.h" #include "Engine/ViewIdx.h" diff --git a/Gui/ViewerGLPrivate.cpp b/Gui/ViewerGLPrivate.cpp index 72deb4f23c..957837e3de 100644 --- a/Gui/ViewerGLPrivate.cpp +++ b/Gui/ViewerGLPrivate.cpp @@ -34,11 +34,7 @@ #include "Global/GLIncludes.h" //! // qApp -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#else -#include "Gui/QGLExtrasCompat.h" -#endif #include "Engine/Lut.h" // Color #include "Engine/Settings.h" @@ -49,9 +45,7 @@ #include "Gui/Menu.h" #include "Gui/ViewerTab.h" -#if QT_VERSION >= QT_VERSION_CHECK(5, 4, 0) #include -#endif #ifndef M_PI #define M_PI 3.14159265358979323846264338327950288 /* pi */ @@ -572,11 +566,8 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped, if (crossProd11 * crossProd21 < 0) { QLineF e(texRectClipped.x1, texRectClipped.y1, texRectClipped.x2, texRectClipped.y1); QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType t = inter.intersects(e, &p); -#else - QLineF::IntersectType t = inter.intersect(e, &p); -#endif + if (t == QLineF::BoundedIntersection) { *polygonPoints << p; } @@ -587,11 +578,7 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped, if (crossProd21 * crossProd22 < 0) { QLineF e(texRectClipped.x2, texRectClipped.y1, texRectClipped.x2, texRectClipped.y2); QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType t = inter.intersects(e, &p); -#else - QLineF::IntersectType t = inter.intersect(e, &p); -#endif if (t == QLineF::BoundedIntersection) { *polygonPoints << p; } @@ -602,11 +589,7 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped, if (crossProd22 * crossProd12 < 0) { QLineF e(texRectClipped.x2, texRectClipped.y2, texRectClipped.x1, texRectClipped.y2); QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType t = inter.intersects(e, &p); -#else - QLineF::IntersectType t = inter.intersect(e, &p); -#endif if (t == QLineF::BoundedIntersection) { *polygonPoints << p; } @@ -617,11 +600,7 @@ ViewerGL::Implementation::getWipePolygon(const RectD & texRectClipped, if (crossProd12 * crossProd11 < 0) { QLineF e(texRectClipped.x1, texRectClipped.y2, texRectClipped.x1, texRectClipped.y1); QPointF p; -#if QT_VERSION >= QT_VERSION_CHECK(5, 14, 0) QLineF::IntersectionType t = inter.intersects(e, &p); -#else - QLineF::IntersectType t = inter.intersect(e, &p); -#endif if (t == QLineF::BoundedIntersection) { *polygonPoints << p; } diff --git a/Gui/ViewerGLPrivate.h b/Gui/ViewerGLPrivate.h index 5e034df35d..5348df6588 100644 --- a/Gui/ViewerGLPrivate.h +++ b/Gui/ViewerGLPrivate.h @@ -42,11 +42,6 @@ CLANG_DIAG_ON(uninitialized) #include "Gui/ZoomContext.h" #include "Gui/GuiFwd.h" -#if QT_VERSION < QT_VERSION_CHECK(5, 4, 0) -#include "Gui/QGLExtrasCompat.h" -#endif - - #define WIPE_MIX_HANDLE_LENGTH 50. #define WIPE_ROTATE_HANDLE_LENGTH 100. #define WIPE_ROTATE_OFFSET 30 diff --git a/Gui/ViewerTab.cpp b/Gui/ViewerTab.cpp index 8d8b7cd9cd..0292f8ef9d 100644 --- a/Gui/ViewerTab.cpp +++ b/Gui/ViewerTab.cpp @@ -146,11 +146,7 @@ ViewerTab::ViewerTab(const std::list & existingNodesContext, "The channels of the layer will be mapped to the RGBA channels of the viewer according to " "its number of channels. (e.g: UV would be mapped to RG)") + QString::fromUtf8("

") ); QObject::connect( _imp->layerChoice, SIGNAL(currentIndexChanged(int)), this, SLOT(onLayerComboChanged(int)) ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->layerChoice->setFixedWidth( fm.horizontalAdvance( QString::fromUtf8("Color.Toto.RGBA") ) + 3 * TO_DPIX(DROP_DOWN_ICON_SIZE) ); -#else - _imp->layerChoice->setFixedWidth( fm.width( QString::fromUtf8("Color.Toto.RGBA") ) + 3 * TO_DPIX(DROP_DOWN_ICON_SIZE) ); -#endif _imp->layerChoice->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _imp->firstRowLayout->addWidget(_imp->layerChoice); @@ -158,11 +154,7 @@ ViewerTab::ViewerTab(const std::list & existingNodesContext, _imp->alphaChannelChoice->setToolTip( QString::fromUtf8("

") + tr("Alpha channel:") + QString::fromUtf8("

") + tr("Select here a channel of any layer that will be used when displaying the " "alpha channel with the Channels choice on the right.") + QString::fromUtf8("

") ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->alphaChannelChoice->setFixedWidth( fm.horizontalAdvance( QString::fromUtf8("Color.alpha") ) + 3 * TO_DPIX(DROP_DOWN_ICON_SIZE) ); -#else - _imp->alphaChannelChoice->setFixedWidth( fm.width( QString::fromUtf8("Color.alpha") ) + 3 * TO_DPIX(DROP_DOWN_ICON_SIZE) ); -#endif _imp->alphaChannelChoice->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); QObject::connect( _imp->alphaChannelChoice, SIGNAL(currentIndexChanged(int)), this, SLOT(onAlphaChannelComboChanged(int)) ); _imp->firstRowLayout->addWidget(_imp->alphaChannelChoice); @@ -171,11 +163,7 @@ ViewerTab::ViewerTab(const std::list & existingNodesContext, _imp->viewerChannels->setToolTip( QString::fromUtf8("

") + tr("Display Channels:") + QString::fromUtf8("

") + tr("The channels to display on the viewer.") + QString::fromUtf8("

") ); _imp->firstRowLayout->addWidget(_imp->viewerChannels); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->viewerChannels->setFixedWidth( fm.horizontalAdvance( QString::fromUtf8("Luminance") ) + 3 * TO_DPIX(DROP_DOWN_ICON_SIZE) ); -#else - _imp->viewerChannels->setFixedWidth( fm.width( QString::fromUtf8("Luminance") ) + 3 * TO_DPIX(DROP_DOWN_ICON_SIZE) ); -#endif _imp->viewerChannels->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); addSpacer(_imp->firstRowLayout); @@ -372,11 +360,7 @@ ViewerTab::ViewerTab(const std::list & existingNodesContext, _imp->firstInputImage = new ComboBox(_imp->firstSettingsRow); _imp->firstInputImage->setToolTip( _imp->firstInputLabel->toolTip() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->firstInputImage->setFixedWidth(fm.horizontalAdvance( QString::fromUtf8("ColorCorrect1") ) + 3 * DROP_DOWN_ICON_SIZE); -#else - _imp->firstInputImage->setFixedWidth(fm.width( QString::fromUtf8("ColorCorrect1") ) + 3 * DROP_DOWN_ICON_SIZE); -#endif _imp->firstInputImage->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _imp->firstInputImage->addItem( QString::fromUtf8(" - ") ); QObject::connect( _imp->firstInputImage, SIGNAL(currentIndexChanged(QString)), this, SLOT(onFirstInputNameChanged(QString)) ); @@ -392,11 +376,7 @@ ViewerTab::ViewerTab(const std::list & existingNodesContext, _imp->compositingOperator = new ComboBox(_imp->firstSettingsRow); QObject::connect( _imp->compositingOperator, SIGNAL(currentIndexChanged(int)), this, SLOT(onCompositingOperatorIndexChanged(int)) ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->compositingOperator->setFixedWidth(fm.horizontalAdvance( QString::fromUtf8("W-OnionSkin") ) + 3 * DROP_DOWN_ICON_SIZE); -#else - _imp->compositingOperator->setFixedWidth(fm.width( QString::fromUtf8("W-OnionSkin") ) + 3 * DROP_DOWN_ICON_SIZE); -#endif _imp->compositingOperator->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _imp->compositingOperator->setToolTip( _imp->compositingOperatorLabel->toolTip() ); _imp->compositingOperator->addItem( tr(" - "), QIcon(), QKeySequence(), tr("No wipe or composite: A") ); @@ -419,11 +399,7 @@ ViewerTab::ViewerTab(const std::list & existingNodesContext, _imp->secondInputImage = new ComboBox(_imp->firstSettingsRow); _imp->secondInputImage->setToolTip( _imp->secondInputLabel->toolTip() ); -#if QT_VERSION >= QT_VERSION_CHECK(5, 11, 0) _imp->secondInputImage->setFixedWidth(fm.horizontalAdvance( QString::fromUtf8("ColorCorrect1") ) + 3 * DROP_DOWN_ICON_SIZE); -#else - _imp->secondInputImage->setFixedWidth(fm.width( QString::fromUtf8("ColorCorrect1") ) + 3 * DROP_DOWN_ICON_SIZE); -#endif _imp->secondInputImage->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); _imp->secondInputImage->addItem( QString::fromUtf8(" - ") ); QObject::connect( _imp->secondInputImage, SIGNAL(currentIndexChanged(QString)), this, SLOT(onSecondInputNameChanged(QString)) ); diff --git a/Gui/ViewerTab10.cpp b/Gui/ViewerTab10.cpp index 3832f4c2fc..b4e8e1b8b0 100644 --- a/Gui/ViewerTab10.cpp +++ b/Gui/ViewerTab10.cpp @@ -858,18 +858,10 @@ ViewerTab::keyPressEvent(QKeyEvent* e) } else if ( isKeybind(kShortcutGroupViewer, kShortcutIDActionHideTop, modifiers, key) ) { toggleTopToolbarVisibility(); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionZoomIn, Qt::NoModifier, key) ) { // zoom in/out doesn't care about modifiers -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) QWheelEvent e(mapFromGlobal( QCursor::pos() ), QCursor::pos(), QPoint(), QPoint(0, 120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); -#else - QWheelEvent e(mapFromGlobal( QCursor::pos() ), 120, Qt::NoButton, Qt::NoModifier); // one wheel click = +-120 delta -#endif wheelEvent(&e); } else if ( isKeybind(kShortcutGroupGlobal, kShortcutIDActionZoomOut, Qt::NoModifier, key) ) { // zoom in/out doesn't care about modifiers -#if QT_VERSION >= QT_VERSION_CHECK(5, 12, 0) QWheelEvent e(mapFromGlobal( QCursor::pos() ), QCursor::pos(), QPoint(), QPoint(0, -120), Qt::NoButton, Qt::NoModifier, Qt::NoScrollPhase, false); -#else - QWheelEvent e(mapFromGlobal( QCursor::pos() ), -120, Qt::NoButton, Qt::NoModifier); // one wheel click = +-120 delta -#endif wheelEvent(&e); } else if (key == Qt::Key_Escape) { _imp->viewer->s_selectionCleared(); diff --git a/Tests/KnobFile_Test.cpp b/Tests/KnobFile_Test.cpp index c5d2352fe4..2a41d9e4f7 100644 --- a/Tests/KnobFile_Test.cpp +++ b/Tests/KnobFile_Test.cpp @@ -30,9 +30,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) #include -#endif #include "Engine/FileSystemModel.h" #include "Engine/StandardPaths.h" @@ -54,11 +52,7 @@ TEST(SequenceParsing, TestHashCharacter) { ///create temporary files as a sequence and try to read that sequence. QString tempPath = StandardPaths::writableLocation(StandardPaths::eStandardLocationTemp); QDir dir(tempPath); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QString dirName = QString::fromUtf8("NatronUnitTest") + QString::number( QRandomGenerator::global()->generate() ); -#else - QString dirName = QString::fromUtf8("NatronUnitTest") + QString::number( qrand() ); -#endif dir.mkpath( QString::fromUtf8(".") ); dir.mkdir(dirName); @@ -229,11 +223,7 @@ TEST(SequenceParsing, TestPrintfLikeSyntax) { ///create temporary files as a sequence and try to read that sequence. QString tempPath = StandardPaths::writableLocation(StandardPaths::eStandardLocationTemp); QDir dir(tempPath); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QString dirName = QString::fromUtf8("NatronUnitTest") + QString::number( QRandomGenerator::global()->generate() ); -#else - QString dirName = QString::fromUtf8("NatronUnitTest") + QString::number( qrand() ); -#endif dir.mkpath( QString::fromUtf8(".") ); dir.mkdir(dirName); dir.cd(dirName); @@ -341,11 +331,7 @@ TEST(SequenceParsing, TestViews) { ///create temporary files as a sequence and try to read that sequence. QString tempPath = StandardPaths::writableLocation(StandardPaths::eStandardLocationTemp); QDir dir(tempPath); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QString dirName = QString::fromUtf8("NatronUnitTest") + QString::number( QRandomGenerator::global()->generate() ); -#else - QString dirName = QString::fromUtf8("NatronUnitTest") + QString::number( qrand() ); -#endif dir.mkpath( QString::fromUtf8(".") ); dir.mkdir(dirName);