diff options
| author | Richard Moe Gustavsen <richard.gustavsen@digia.com> | 2013-07-09 15:57:09 +0200 |
|---|---|---|
| committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-07-11 16:44:59 +0200 |
| commit | 2c4f86faafff1f68783f9c813a551ad7244fdb62 (patch) | |
| tree | 8cf4dfc4a7cab3f07385aeb08cb968680f8be70f /src/controls/SplitView.qml | |
| parent | ebe882ba67b0e52e6fd78a3cd599f37588b73514 (diff) | |
SplitView: support changing orientation
Change-Id: I8a5f7ec5bd6315a8a74ac6f8b5c9bc0d0f9c19fa
Reviewed-by: Jens Bache-Wiig <jens.bache-wiig@digia.com>
Diffstat (limited to 'src/controls/SplitView.qml')
| -rw-r--r-- | src/controls/SplitView.qml | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/src/controls/SplitView.qml b/src/controls/SplitView.qml index a0558aa8f..2dbbbf758 100644 --- a/src/controls/SplitView.qml +++ b/src/controls/SplitView.qml @@ -163,12 +163,13 @@ Item { Component.onCompleted: d.init() onWidthChanged: d.updateLayout() onHeightChanged: d.updateLayout() + onOrientationChanged: d.changeOrientation() SystemPalette { id: pal } QtObject { id: d - readonly property bool horizontal: orientation == Qt.Horizontal + property bool horizontal: orientation == Qt.Horizontal readonly property string minimum: horizontal ? "minimumWidth" : "minimumHeight" readonly property string maximum: horizontal ? "maximumWidth" : "maximumHeight" readonly property string otherMinimum: horizontal ? "minimumHeight" : "minimumWidth" @@ -224,6 +225,39 @@ Item { d.updateLayout() } + function changeOrientation() + { + if (__items.length == 0) + return; + d.updateLayoutGuard = true + + // Swap width/height for items and handles: + for (var i=0; i<__items.length; ++i) { + var item = __items[i] + var tmp = item.x + item.x = item.y + item.y = tmp + tmp = item.width + item.width = item.height + item.height = tmp + + var handle = __handles[i] + if (handle) { + tmp = handle.x + handle.x = handle.y + handle.y = handle.x + tmp = handle.width + handle.width = handle.height + handle.height = tmp + } + } + + // Change d.horizontal explicit, since the binding will change too late: + d.horizontal = orientation == Qt.Horizontal + d.updateLayoutGuard = false + d.updateFillIndex() + } + function calculateImplicitSize() { var implicitSize = 0 |
