diff options
author | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-05-22 12:55:25 +0200 |
---|---|---|
committer | J-P Nurmi <jpnurmi@theqtcompany.com> | 2015-05-22 18:34:42 +0000 |
commit | 7d39b4ff7d555f4731aa235ecb286efc43535cb7 (patch) | |
tree | e3943fbaf44a6602f5ab7aaeec05376e3d40b81a /src/controls | |
parent | a3b1db8586cc10da12314cf21a0a377b50874703 (diff) |
Promote layoutDirection & effectiveLayoutDirection to Control
Change-Id: I44df09c17d6d20cfd929af4e331e15f48b19587e
Reviewed-by: J-P Nurmi <jpnurmi@theqtcompany.com>
Diffstat (limited to 'src/controls')
-rw-r--r-- | src/controls/qquickcheckable.cpp | 41 | ||||
-rw-r--r-- | src/controls/qquickcheckable_p.h | 10 | ||||
-rw-r--r-- | src/controls/qquickcheckable_p_p.h | 1 | ||||
-rw-r--r-- | src/controls/qquickcontrol.cpp | 37 | ||||
-rw-r--r-- | src/controls/qquickcontrol_p.h | 8 | ||||
-rw-r--r-- | src/controls/qquickcontrol_p_p.h | 1 | ||||
-rw-r--r-- | src/controls/qquickprogressbar.cpp | 39 | ||||
-rw-r--r-- | src/controls/qquickprogressbar_p.h | 8 | ||||
-rw-r--r-- | src/controls/qquickslider.cpp | 42 | ||||
-rw-r--r-- | src/controls/qquickslider_p.h | 8 |
10 files changed, 50 insertions, 145 deletions
diff --git a/src/controls/qquickcheckable.cpp b/src/controls/qquickcheckable.cpp index c5526c0b..24abb5f9 100644 --- a/src/controls/qquickcheckable.cpp +++ b/src/controls/qquickcheckable.cpp @@ -49,7 +49,7 @@ QT_BEGIN_NAMESPACE */ QQuickCheckablePrivate::QQuickCheckablePrivate() : - checked(false), exclusive(false), indicator(Q_NULLPTR), layoutDirection(Qt::LeftToRight) + checked(false), exclusive(false), indicator(Q_NULLPTR) { } @@ -122,40 +122,6 @@ void QQuickCheckable::setIndicator(QQuickItem *indicator) } /*! - \qmlproperty enumeration QtQuickControls2::Checkable::layoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickCheckable::layoutDirection() const -{ - Q_D(const QQuickCheckable); - return d->layoutDirection; -} - -/*! - \qmlproperty enumeration QtQuickControls2::Checkable::effectiveLayoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickCheckable::effectiveLayoutDirection() const -{ - Q_D(const QQuickCheckable); - if (isMirrored()) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - return d->layoutDirection; -} - -void QQuickCheckable::setLayoutDirection(Qt::LayoutDirection direction) -{ - Q_D(QQuickCheckable); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! \qmlmethod void QtQuickControls2::Checkable::toggle() TODO @@ -182,9 +148,4 @@ void QQuickCheckable::mouseReleaseEvent(QMouseEvent *event) setChecked(d->exclusive || !d->checked); } -void QQuickCheckable::mirrorChange() -{ - emit effectiveLayoutDirectionChanged(); -} - QT_END_NAMESPACE diff --git a/src/controls/qquickcheckable_p.h b/src/controls/qquickcheckable_p.h index 71629a49..38408477 100644 --- a/src/controls/qquickcheckable_p.h +++ b/src/controls/qquickcheckable_p.h @@ -59,8 +59,6 @@ class Q_QUICKCONTROLS_EXPORT QQuickCheckable : public QQuickButton Q_OBJECT Q_PROPERTY(bool checked READ isChecked WRITE setChecked NOTIFY checkedChanged FINAL) Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) public: explicit QQuickCheckable(QQuickItem *parent = Q_NULLPTR); @@ -74,18 +72,12 @@ public: QQuickItem *indicator() const; void setIndicator(QQuickItem *indicator); - Qt::LayoutDirection layoutDirection() const; - Qt::LayoutDirection effectiveLayoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection direction); - public Q_SLOTS: void toggle(); Q_SIGNALS: void checkedChanged(); void indicatorChanged(); - void layoutDirectionChanged(); - void effectiveLayoutDirectionChanged(); protected: QQuickCheckable(QQuickCheckablePrivate &dd, QQuickItem *parent); @@ -93,8 +85,6 @@ protected: void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE; void mouseReleaseEvent(QMouseEvent *event) Q_DECL_OVERRIDE; - void mirrorChange() Q_DECL_OVERRIDE; - private: Q_DISABLE_COPY(QQuickCheckable) Q_DECLARE_PRIVATE(QQuickCheckable) diff --git a/src/controls/qquickcheckable_p_p.h b/src/controls/qquickcheckable_p_p.h index 2e5b9e39..d13af86b 100644 --- a/src/controls/qquickcheckable_p_p.h +++ b/src/controls/qquickcheckable_p_p.h @@ -60,7 +60,6 @@ public: bool checked; bool exclusive; QQuickItem *indicator; - Qt::LayoutDirection layoutDirection; }; QT_END_NAMESPACE diff --git a/src/controls/qquickcontrol.cpp b/src/controls/qquickcontrol.cpp index 427dde0f..5b2c869b 100644 --- a/src/controls/qquickcontrol.cpp +++ b/src/controls/qquickcontrol.cpp @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE QQuickControlPrivate::QQuickControlPrivate() : hasTopPadding(false), hasLeftPadding(false), hasRightPadding(false), hasBottomPadding(false), padding(0), topPadding(0), leftPadding(0), rightPadding(0), bottomPadding(0), - background(Q_NULLPTR) + layoutDirection(Qt::LeftToRight), background(Q_NULLPTR) { } @@ -60,6 +60,7 @@ void QQuickControlPrivate::mirrorChange() { Q_Q(QQuickControl); q->mirrorChange(); + emit q->effectiveLayoutDirectionChanged(); } void QQuickControlPrivate::setTopPadding(qreal value, bool reset) @@ -239,6 +240,40 @@ void QQuickControl::resetBottomPadding() } /*! + \qmlproperty enumeration QtQuickControls2::Control::layoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickControl::layoutDirection() const +{ + Q_D(const QQuickControl); + return d->layoutDirection; +} + +/*! + \qmlproperty enumeration QtQuickControls2::Control::effectiveLayoutDirection + + TODO +*/ +Qt::LayoutDirection QQuickControl::effectiveLayoutDirection() const +{ + Q_D(const QQuickControl); + if (d->isMirrored()) + return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; + return d->layoutDirection; +} + +void QQuickControl::setLayoutDirection(Qt::LayoutDirection direction) +{ + Q_D(QQuickControl); + if (d->layoutDirection != direction) { + d->layoutDirection = direction; + emit layoutDirectionChanged(); + emit effectiveLayoutDirectionChanged(); + } +} + +/*! \qmlproperty Item QtQuickControls2::Control::background This property holds the background item. diff --git a/src/controls/qquickcontrol_p.h b/src/controls/qquickcontrol_p.h index 7fadddf7..2f000a4f 100644 --- a/src/controls/qquickcontrol_p.h +++ b/src/controls/qquickcontrol_p.h @@ -63,6 +63,8 @@ class Q_QUICKCONTROLS_EXPORT QQuickControl : public QQuickItem Q_PROPERTY(qreal leftPadding READ leftPadding WRITE setLeftPadding RESET resetLeftPadding NOTIFY leftPaddingChanged FINAL) Q_PROPERTY(qreal rightPadding READ rightPadding WRITE setRightPadding RESET resetRightPadding NOTIFY rightPaddingChanged FINAL) Q_PROPERTY(qreal bottomPadding READ bottomPadding WRITE setBottomPadding RESET resetBottomPadding NOTIFY bottomPaddingChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) + Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) public: @@ -88,6 +90,10 @@ public: void setBottomPadding(qreal padding); void resetBottomPadding(); + Qt::LayoutDirection layoutDirection() const; + Qt::LayoutDirection effectiveLayoutDirection() const; + void setLayoutDirection(Qt::LayoutDirection direction); + QQuickItem *background() const; void setBackground(QQuickItem *background); @@ -97,6 +103,8 @@ Q_SIGNALS: void leftPaddingChanged(); void rightPaddingChanged(); void bottomPaddingChanged(); + void layoutDirectionChanged(); + void effectiveLayoutDirectionChanged(); void backgroundChanged(); protected: diff --git a/src/controls/qquickcontrol_p_p.h b/src/controls/qquickcontrol_p_p.h index 4a3cf8af..63d84b4b 100644 --- a/src/controls/qquickcontrol_p_p.h +++ b/src/controls/qquickcontrol_p_p.h @@ -75,6 +75,7 @@ public: qreal leftPadding; qreal rightPadding; qreal bottomPadding; + Qt::LayoutDirection layoutDirection; QQuickItem *background; }; diff --git a/src/controls/qquickprogressbar.cpp b/src/controls/qquickprogressbar.cpp index 5bd15091..0824cd13 100644 --- a/src/controls/qquickprogressbar.cpp +++ b/src/controls/qquickprogressbar.cpp @@ -53,12 +53,10 @@ QT_BEGIN_NAMESPACE class QQuickProgressBarPrivate : public QQuickControlPrivate { public: - QQuickProgressBarPrivate() : value(0), indeterminate(false), - layoutDirection(Qt::LeftToRight), indicator(Q_NULLPTR) { } + QQuickProgressBarPrivate() : value(0), indeterminate(false), indicator(Q_NULLPTR) { } qreal value; bool indeterminate; - Qt::LayoutDirection layoutDirection; QQuickItem *indicator; }; @@ -123,40 +121,6 @@ void QQuickProgressBar::setIndeterminate(bool indeterminate) } /*! - \qmlproperty enumeration QtQuickControls2::ProgressBar::layoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickProgressBar::layoutDirection() const -{ - Q_D(const QQuickProgressBar); - return d->layoutDirection; -} - -/*! - \qmlproperty enumeration QtQuickControls2::ProgressBar::effectiveLayoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickProgressBar::effectiveLayoutDirection() const -{ - Q_D(const QQuickProgressBar); - if (isMirrored()) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - return d->layoutDirection; -} - -void QQuickProgressBar::setLayoutDirection(Qt::LayoutDirection direction) -{ - Q_D(QQuickProgressBar); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! \qmlproperty Item QtQuickControls2::ProgressBar::indicator TODO @@ -181,7 +145,6 @@ void QQuickProgressBar::setIndicator(QQuickItem *indicator) void QQuickProgressBar::mirrorChange() { - emit effectiveLayoutDirectionChanged(); emit visualPositionChanged(); } diff --git a/src/controls/qquickprogressbar_p.h b/src/controls/qquickprogressbar_p.h index 9b046890..263e3186 100644 --- a/src/controls/qquickprogressbar_p.h +++ b/src/controls/qquickprogressbar_p.h @@ -60,8 +60,6 @@ class Q_QUICKCONTROLS_EXPORT QQuickProgressBar : public QQuickControl Q_PROPERTY(qreal value READ value WRITE setValue NOTIFY valueChanged FINAL) Q_PROPERTY(qreal visualPosition READ visualPosition NOTIFY visualPositionChanged FINAL) Q_PROPERTY(bool indeterminate READ isIndeterminate WRITE setIndeterminate NOTIFY indeterminateChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) Q_PROPERTY(QQuickItem *indicator READ indicator WRITE setIndicator NOTIFY indicatorChanged FINAL) public: @@ -75,10 +73,6 @@ public: bool isIndeterminate() const; void setIndeterminate(bool indeterminate); - Qt::LayoutDirection layoutDirection() const; - Qt::LayoutDirection effectiveLayoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection direction); - QQuickItem *indicator() const; void setIndicator(QQuickItem *indicator); @@ -86,8 +80,6 @@ Q_SIGNALS: void valueChanged(); void visualPositionChanged(); void indeterminateChanged(); - void layoutDirectionChanged(); - void effectiveLayoutDirectionChanged(); void indicatorChanged(); protected: diff --git a/src/controls/qquickslider.cpp b/src/controls/qquickslider.cpp index 551ba0d6..1d318d51 100644 --- a/src/controls/qquickslider.cpp +++ b/src/controls/qquickslider.cpp @@ -57,9 +57,9 @@ class QQuickSliderPrivate : public QQuickControlPrivate Q_DECLARE_PUBLIC(QQuickSlider) public: - QQuickSliderPrivate() : value(0), position(0), stepSize(0), - pressed(false), orientation(Qt::Horizontal), layoutDirection(Qt::LeftToRight), - snapMode(QQuickSlider::NoSnap), handle(Q_NULLPTR), track(Q_NULLPTR) { } + QQuickSliderPrivate() : value(0), position(0), stepSize(0), pressed(false), + orientation(Qt::Horizontal), snapMode(QQuickSlider::NoSnap), + handle(Q_NULLPTR), track(Q_NULLPTR) { } qreal snapPosition(qreal position) const; qreal positionAt(const QPoint &point) const; @@ -70,7 +70,6 @@ public: bool pressed; QPoint pressPoint; Qt::Orientation orientation; - Qt::LayoutDirection layoutDirection; QQuickSlider::SnapMode snapMode; QQuickItem *handle; QQuickItem *track; @@ -251,40 +250,6 @@ void QQuickSlider::setOrientation(Qt::Orientation orientation) } /*! - \qmlproperty enumeration QtQuickControls2::Slider::layoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickSlider::layoutDirection() const -{ - Q_D(const QQuickSlider); - return d->layoutDirection; -} - -/*! - \qmlproperty enumeration QtQuickControls2::Slider::effectiveLayoutDirection - - TODO -*/ -Qt::LayoutDirection QQuickSlider::effectiveLayoutDirection() const -{ - Q_D(const QQuickSlider); - if (isMirrored()) - return d->layoutDirection == Qt::RightToLeft ? Qt::LeftToRight : Qt::RightToLeft; - return d->layoutDirection; -} - -void QQuickSlider::setLayoutDirection(Qt::LayoutDirection direction) -{ - Q_D(QQuickSlider); - if (d->layoutDirection != direction) { - d->layoutDirection = direction; - emit layoutDirectionChanged(); - emit effectiveLayoutDirectionChanged(); - } -} - -/*! \qmlproperty Item QtQuickControls2::Slider::handle TODO @@ -447,7 +412,6 @@ void QQuickSlider::mouseUngrabEvent() void QQuickSlider::mirrorChange() { - emit effectiveLayoutDirectionChanged(); emit visualPositionChanged(); } diff --git a/src/controls/qquickslider_p.h b/src/controls/qquickslider_p.h index 8215565d..bd5411ed 100644 --- a/src/controls/qquickslider_p.h +++ b/src/controls/qquickslider_p.h @@ -64,8 +64,6 @@ class Q_QUICKCONTROLS_EXPORT QQuickSlider : public QQuickControl Q_PROPERTY(SnapMode snapMode READ snapMode WRITE setSnapMode NOTIFY snapModeChanged FINAL) Q_PROPERTY(bool pressed READ isPressed WRITE setPressed NOTIFY pressedChanged FINAL) Q_PROPERTY(Qt::Orientation orientation READ orientation WRITE setOrientation NOTIFY orientationChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection layoutDirection READ layoutDirection WRITE setLayoutDirection NOTIFY layoutDirectionChanged FINAL) - Q_PROPERTY(Qt::LayoutDirection effectiveLayoutDirection READ effectiveLayoutDirection NOTIFY effectiveLayoutDirectionChanged FINAL) Q_PROPERTY(QQuickItem *handle READ handle WRITE setHandle NOTIFY handleChanged FINAL) Q_PROPERTY(QQuickItem *track READ track WRITE setTrack NOTIFY trackChanged FINAL) @@ -98,10 +96,6 @@ public: Qt::Orientation orientation() const; void setOrientation(Qt::Orientation orientation); - Qt::LayoutDirection layoutDirection() const; - Qt::LayoutDirection effectiveLayoutDirection() const; - void setLayoutDirection(Qt::LayoutDirection direction); - QQuickItem *handle() const; void setHandle(QQuickItem *handle); @@ -120,8 +114,6 @@ Q_SIGNALS: void snapModeChanged(); void pressedChanged(); void orientationChanged(); - void layoutDirectionChanged(); - void effectiveLayoutDirectionChanged(); void handleChanged(); void trackChanged(); |