Skip to content

Commit

Permalink
[Sketcher] Remove deprecated Qt < 5.9 code
Browse files Browse the repository at this point in the history
  • Loading branch information
chennes authored and wwmayer committed Apr 1, 2021
1 parent 00d9dd9 commit 6227a71
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 39 deletions.
2 changes: 0 additions & 2 deletions src/Mod/Sketcher/Gui/CommandConstraints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -905,14 +905,12 @@ class DrawSketchHandlerGenConstraint: public DrawSketchHandler
cursorPainter.end();
int hotX = 8;
int hotY = 8;
#if QT_VERSION >= 0x050000
cursorPixmap.setDevicePixelRatio(pixelRatio);
// only X11 needs hot point coordinates to be scaled
if (qGuiApp->platformName() == QLatin1String("xcb")) {
hotX *= pixelRatio;
hotY *= pixelRatio;
}
#endif
setCursor(cursorPixmap, hotX, hotY, false);
}

Expand Down
27 changes: 0 additions & 27 deletions src/Mod/Sketcher/Gui/DrawSketchHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@
# include <Inventor/nodes/SoText2.h>
# include <Inventor/nodes/SoFont.h>
# include <QPainter>
# if QT_VERSION >= 0x050000
# include <QGuiApplication>
# endif
# include <cmath>
#endif // #ifndef _PreComp_

Expand Down Expand Up @@ -119,23 +117,18 @@ void DrawSketchHandler::setSvgCursor(const QString & cursorName, int x, int y, c
qreal defaultCursorSize = isRatioOne ? 64 : 32;
qreal hotX = x;
qreal hotY = y;
#if QT_VERSION >= 0x050000
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
if (qGuiApp->platformName() == QLatin1String("xcb")) {
hotX *= pRatio;
hotY *= pRatio;
}
#endif
#endif
qreal cursorSize = defaultCursorSize * pRatio;

QPixmap pointer = Gui::BitmapFactory().pixmapFromSvg(cursorName.toStdString().c_str(), QSizeF(cursorSize, cursorSize), colorMapping);
if (isRatioOne)
pointer = pointer.scaled(32, 32);
#if QT_VERSION >= 0x050000
pointer.setDevicePixelRatio(pRatio);
#endif

setCursor(pointer, hotX, hotY, false);
}

Expand All @@ -151,26 +144,18 @@ void DrawSketchHandler::setCursor(const QPixmap &p,int x,int y, bool autoScale)
QPixmap p1(p);
// TODO remove autoScale after all cursors are SVG-based
if (autoScale) {
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
qreal pRatio = viewer->devicePixelRatio();
#else
qreal pRatio = 1;
#endif
int newWidth = p.width()*pRatio;
int newHeight = p.height()*pRatio;
p1 = p1.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation);
#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
p1.setDevicePixelRatio(pRatio);
#endif
qreal hotX = x;
qreal hotY = y;
#if QT_VERSION >= 0x050000
#if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC)
if (qGuiApp->platformName() == QLatin1String("xcb")) {
hotX *= pRatio;
hotY *= pRatio;
}
#endif
#endif
cursor = QCursor(p1, hotX, hotY);
} else {
Expand All @@ -190,12 +175,8 @@ void DrawSketchHandler::addCursorTail( std::vector<QPixmap> &pixmaps ) {
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
QPixmap baseIcon = QPixmap(actCursorPixmap);
#if QT_VERSION >= 0x050000
baseIcon.setDevicePixelRatio(actCursorPixmap.devicePixelRatio());
qreal pixelRatio = baseIcon.devicePixelRatio();
#else
qreal pixelRatio = 1;
#endif
// cursor size in device independent pixels
qreal baseCursorWidth = baseIcon.width();
qreal baseCursorHeight = baseIcon.height();
Expand Down Expand Up @@ -238,11 +219,7 @@ void DrawSketchHandler::addCursorTail( std::vector<QPixmap> &pixmaps ) {

// Create the new cursor with the icon.
QPoint p=actCursor.hotSpot();

#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0)
newIcon.setDevicePixelRatio(pixelRatio);
#endif

QCursor newCursor(newIcon, p.x(), p.y());
applyCursor(newCursor);
}
Expand Down Expand Up @@ -273,13 +250,11 @@ void DrawSketchHandler::unsetCursor(void)

qreal DrawSketchHandler::devicePixelRatio() {
qreal pixelRatio = 1;
# if QT_VERSION >= 0x050000
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
pixelRatio = viewer->devicePixelRatio();
}
# endif
return pixelRatio;
}

Expand Down Expand Up @@ -313,13 +288,11 @@ std::vector<QPixmap> DrawSketchHandler::suggestedConstraintsPixmaps(
}
if (!iconType.isEmpty()) {
qreal pixelRatio = 1;
# if QT_VERSION >= 0x050000
Gui::MDIView* view = Gui::getMainWindow()->activeWindow();
if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) {
Gui::View3DInventorViewer* viewer = static_cast<Gui::View3DInventor*>(view)->getViewer();
pixelRatio = viewer->devicePixelRatio();
}
# endif
int iconWidth = 16 * pixelRatio;
QPixmap icon = Gui::BitmapFactory()
.pixmapFromSvg(iconType.toStdString().c_str(), QSize(iconWidth, iconWidth));
Expand Down
4 changes: 0 additions & 4 deletions src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,11 +394,7 @@ class ExpressionDelegate : public QStyledItemDelegate
}

void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const {
#if QT_VERSION >= 0x050000
QStyleOptionViewItem options = option;
#else
QStyleOptionViewItemV4 options = option;
#endif
initStyleOption(&options, index);

options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter);
Expand Down
2 changes: 0 additions & 2 deletions src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent)
: QWidget(parent), ui(new Ui_TaskSketcherGeneral)
{
ui->setupUi(this);
#if QT_VERSION >= 0x050200
ui->renderingOrder->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents);
#endif

// connecting the needed signals
connect(ui->checkBoxShowGrid, SIGNAL(toggled(bool)),
Expand Down
4 changes: 0 additions & 4 deletions src/Mod/Sketcher/Gui/ViewProviderSketch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1373,11 +1373,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
}
case STATUS_SKETCH_UseRubberBand: {
// Here we must use the device-pixel-ratio to compute the correct y coordinate (#0003130)
#if QT_VERSION >= 0x050600
qreal dpr = viewer->getGLWidget()->devicePixelRatioF();
#else
qreal dpr = 1;
#endif
newCursorPos = cursorPos;
rubberband->setCoords(prvCursorPos.getValue()[0],
viewer->getGLWidget()->height()*dpr - prvCursorPos.getValue()[1],
Expand Down

0 comments on commit 6227a71

Please sign in to comment.