diff options
Diffstat (limited to 'examples/widgets/painting/affine')
-rw-r--r-- | examples/widgets/painting/affine/affine.pro | 4 | ||||
-rw-r--r-- | examples/widgets/painting/affine/main.cpp | 8 | ||||
-rw-r--r-- | examples/widgets/painting/affine/xform.cpp | 13 |
3 files changed, 8 insertions, 17 deletions
diff --git a/examples/widgets/painting/affine/affine.pro b/examples/widgets/painting/affine/affine.pro index 0ad869183c..0af18b82ca 100644 --- a/examples/widgets/painting/affine/affine.pro +++ b/examples/widgets/painting/affine/affine.pro @@ -1,10 +1,6 @@ SOURCES += main.cpp xform.cpp HEADERS += xform.h -qtHaveModule(opengl) { - DEFINES += QT_OPENGL_SUPPORT - QT += opengl -} QT += widgets SHARED_FOLDER = ../shared diff --git a/examples/widgets/painting/affine/main.cpp b/examples/widgets/painting/affine/main.cpp index a820c784f0..6ce8efe482 100644 --- a/examples/widgets/painting/affine/main.cpp +++ b/examples/widgets/painting/affine/main.cpp @@ -58,12 +58,12 @@ int main(int argc, char **argv) QApplication app(argc, argv); - XFormWidget xformWidget(0); - QStyle *arthurStyle = new ArthurStyle(); + XFormWidget xformWidget(nullptr); + QStyle *arthurStyle = new ArthurStyle; xformWidget.setStyle(arthurStyle); - QList<QWidget *> widgets = xformWidget.findChildren<QWidget *>(); - foreach (QWidget *w, widgets) { + const QList<QWidget *> widgets = xformWidget.findChildren<QWidget *>(); + for (QWidget *w : widgets) { w->setStyle(arthurStyle); w->setAttribute(Qt::WA_AcceptTouchEvents); } diff --git a/examples/widgets/painting/affine/xform.cpp b/examples/widgets/painting/affine/xform.cpp index 20f6eb3c6d..482e0f3268 100644 --- a/examples/widgets/painting/affine/xform.cpp +++ b/examples/widgets/painting/affine/xform.cpp @@ -160,10 +160,7 @@ void XFormView::updateCtrlPoints(const QPolygonF &points) ctrlPoints = points; QLineF line(ctrlPoints.at(0), ctrlPoints.at(1)); - m_rotation = line.angle(QLineF(0, 0, 1, 0)); - if (line.dy() < 0) - m_rotation = 360 - m_rotation; - + m_rotation = 360 - QLineF(0, 0, 1, 0).angleTo(line); if (trans.isNull()) emit rotationChanged(int(m_rotation*10)); } @@ -830,13 +827,11 @@ XFormWidget::XFormWidget(QWidget *parent) QPushButton *showSourceButton = new QPushButton(mainGroup); showSourceButton->setText(tr("Show Source")); -#ifdef QT_OPENGL_SUPPORT +#if QT_CONFIG(opengl) QPushButton *enableOpenGLButton = new QPushButton(mainGroup); enableOpenGLButton->setText(tr("Use OpenGL")); enableOpenGLButton->setCheckable(true); enableOpenGLButton->setChecked(view->usesOpenGL()); - if (!QGLFormat::hasOpenGL()) - enableOpenGLButton->hide(); #endif QPushButton *whatsThisButton = new QPushButton(mainGroup); whatsThisButton->setText(tr("What's This?")); @@ -871,7 +866,7 @@ XFormWidget::XFormWidget(QWidget *parent) mainGroupLayout->addWidget(resetButton); mainGroupLayout->addWidget(animateButton); mainGroupLayout->addWidget(showSourceButton); -#ifdef QT_OPENGL_SUPPORT +#if QT_CONFIG(opengl) mainGroupLayout->addWidget(enableOpenGLButton); #endif mainGroupLayout->addWidget(whatsThisButton); @@ -897,7 +892,7 @@ XFormWidget::XFormWidget(QWidget *parent) connect(view, &XFormView::descriptionEnabledChanged, view->hoverPoints(), &HoverPoints::setDisabled); connect(view, &XFormView::descriptionEnabledChanged, whatsThisButton, &QPushButton::setChecked); connect(showSourceButton, &QPushButton::clicked, view, &XFormView::showSource); -#ifdef QT_OPENGL_SUPPORT +#if QT_CONFIG(opengl) connect(enableOpenGLButton, &QPushButton::clicked, view, &XFormView::enableOpenGL); #endif view->loadSourceFile(":res/affine/xform.cpp"); |