diff options
author | David Schulz <david.schulz@digia.com> | 2012-11-23 11:52:51 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-23 17:04:00 +0100 |
commit | cbf3771e86272c10519394627784d6c1088f3a3b (patch) | |
tree | f526458bba0f2c5fe8ae1c05b678d9966a4eaf77 /examples/widgets/painting/deform | |
parent | 92724e533d13f56d359122d7d83ddc2316a75ef8 (diff) |
QtBase: examples/widgets/painting code style
Change-Id: I3d3c6f3bae20ac8383279437f8f89c92195a704f
Reviewed-by: hjk <qthjk@ovi.com>
Diffstat (limited to 'examples/widgets/painting/deform')
-rw-r--r-- | examples/widgets/painting/deform/main.cpp | 1 | ||||
-rw-r--r-- | examples/widgets/painting/deform/pathdeform.cpp | 51 | ||||
-rw-r--r-- | examples/widgets/painting/deform/pathdeform.h | 11 |
3 files changed, 22 insertions, 41 deletions
diff --git a/examples/widgets/painting/deform/main.cpp b/examples/widgets/painting/deform/main.cpp index 370afd7438..8c8b3d24f6 100644 --- a/examples/widgets/painting/deform/main.cpp +++ b/examples/widgets/painting/deform/main.cpp @@ -42,7 +42,6 @@ #include "pathdeform.h" #include <QApplication> -#include <QDebug> int main(int argc, char **argv) { diff --git a/examples/widgets/painting/deform/pathdeform.cpp b/examples/widgets/painting/deform/pathdeform.cpp index 418c5ffd8b..8b27fa2516 100644 --- a/examples/widgets/painting/deform/pathdeform.cpp +++ b/examples/widgets/painting/deform/pathdeform.cpp @@ -53,7 +53,8 @@ #include <QDesktopWidget> #include <qmath.h> -PathDeformControls::PathDeformControls(QWidget *parent, PathDeformRenderer* renderer, bool smallScreen) +PathDeformControls::PathDeformControls(QWidget *parent, + PathDeformRenderer* renderer, bool smallScreen) : QWidget(parent) { m_renderer = renderer; @@ -64,7 +65,6 @@ PathDeformControls::PathDeformControls(QWidget *parent, PathDeformRenderer* rend layoutForDesktop(); } - void PathDeformControls::layoutForDesktop() { QGroupBox* mainGroup = new QGroupBox(this); @@ -223,8 +223,8 @@ void PathDeformControls::layoutForSmallScreen() mainLayout->addWidget(okButton); mainLayout->addWidget(quitButton); - connect(quitButton, SIGNAL(clicked()), this, SLOT(emitQuitSignal())); - connect(okButton, SIGNAL(clicked()), this, SLOT(emitOkSignal())); + connect(quitButton, SIGNAL(clicked()), this, SIGNAL(quitPressed())); + connect(okButton, SIGNAL(clicked()), this, SIGNAL(okPressed())); connect(radiusSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setRadius(int))); connect(deformSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setIntensity(int))); connect(fontSizeSlider, SIGNAL(valueChanged(int)), m_renderer, SLOT(setFontSize(int))); @@ -244,14 +244,6 @@ void PathDeformControls::layoutForSmallScreen() m_renderer->setText(tr("Qt")); } - -void PathDeformControls::emitQuitSignal() -{ emit quitPressed(); } - -void PathDeformControls::emitOkSignal() -{ emit okPressed(); } - - PathDeformWidget::PathDeformWidget(QWidget *parent, bool smallScreen) : QWidget(parent) { @@ -293,14 +285,14 @@ void PathDeformWidget::hideControls() void PathDeformWidget::setStyle( QStyle * style ) { QWidget::setStyle(style); - if (m_controls != 0) - { - m_controls->setStyle(style); + if (m_controls == 0) + return; + + m_controls->setStyle(style); - QList<QWidget *> widgets = m_controls->findChildren<QWidget *>(); - foreach (QWidget *w, widgets) - w->setStyle(style); - } + QList<QWidget *> widgets = m_controls->findChildren<QWidget *>(); + foreach (QWidget *w, widgets) + w->setStyle(style); } static inline QRect circle_bounds(const QPointF ¢er, qreal radius, qreal compensation) @@ -445,8 +437,6 @@ void PathDeformRenderer::timerEvent(QTimerEvent *e) m_pos += QPointF(dx, dy); - - if (m_pos.x() - m_radius < 0) { m_direction.setX(-m_direction.x()); m_pos.setX(m_radius); @@ -565,7 +555,6 @@ QPainterPath PathDeformRenderer::lensDeform(const QPainterPath &source, const QP return path; } - void PathDeformRenderer::paint(QPainter *painter) { int pad_x = 5; @@ -611,8 +600,6 @@ void PathDeformRenderer::paint(QPainter *painter) } } - - void PathDeformRenderer::setRadius(int radius) { qreal max = qMax(m_radius, (qreal)radius); @@ -620,13 +607,12 @@ void PathDeformRenderer::setRadius(int radius) generateLensPixmap(); if (!m_animated || m_radius < max) { #ifdef QT_OPENGL_SUPPORT - if (usesOpenGL()) { + if (usesOpenGL()){ update(); - } else -#endif - { - update(circle_bounds(m_pos, max, m_fontSize)); + return; } +#endif + update(circle_bounds(m_pos, max, m_fontSize)); } } @@ -637,10 +623,9 @@ void PathDeformRenderer::setIntensity(int intensity) #ifdef QT_OPENGL_SUPPORT if (usesOpenGL()) { update(); - } else -#endif - { - update(circle_bounds(m_pos, m_radius, m_fontSize)); + return; } +#endif + update(circle_bounds(m_pos, m_radius, m_fontSize)); } } diff --git a/examples/widgets/painting/deform/pathdeform.h b/examples/widgets/painting/deform/pathdeform.h index 8e44c4ac4f..8bb2c9667c 100644 --- a/examples/widgets/painting/deform/pathdeform.h +++ b/examples/widgets/painting/deform/pathdeform.h @@ -44,9 +44,9 @@ #include "arthurwidgets.h" -#include <QPainterPath> #include <QBasicTimer> #include <QDateTime> +#include <QPainterPath> class PathDeformRenderer : public ArthurFrame { @@ -113,8 +113,8 @@ private: QPointF m_offset; QPointF m_direction; QPointF m_mousePress; - bool m_mouseDrag; - bool m_smallScreen; + bool m_mouseDrag; + bool m_smallScreen; }; class PathDeformControls : public QWidget @@ -129,9 +129,6 @@ private: PathDeformRenderer* m_renderer; void layoutForDesktop(); void layoutForSmallScreen(); -private slots: - void emitQuitSignal(); - void emitOkSignal(); }; class PathDeformWidget : public QWidget @@ -139,7 +136,7 @@ class PathDeformWidget : public QWidget Q_OBJECT public: PathDeformWidget(QWidget *parent, bool smallScreen); - void setStyle ( QStyle * style ); + void setStyle (QStyle * style ); private: PathDeformRenderer *m_renderer; |