Skip to content
Snippets Groups Projects
Commit 58a96d14 authored by Aline Gondim Santos's avatar Aline Gondim Santos
Browse files

RTL: fix layout width resizing

Change-Id: I65234d22ecd1e3cb3fc6544a449ec8fc1e78aee0
GitLab: #235
parent e073c6f8
No related branches found
No related tags found
No related merge requests found
...@@ -25,6 +25,8 @@ BaseView { ...@@ -25,6 +25,8 @@ BaseView {
required property Item leftPaneItem required property Item leftPaneItem
required property Item rightPaneItem required property Item rightPaneItem
property bool isRTL: UtilsAdapter.isRTL
property alias leftPane: leftPane property alias leftPane: leftPane
property alias rightPane: rightPane property alias rightPane: rightPane
...@@ -33,34 +35,34 @@ BaseView { ...@@ -33,34 +35,34 @@ BaseView {
property real minorPaneMinWidth: JamiTheme.mainViewLeftPaneMinWidth property real minorPaneMinWidth: JamiTheme.mainViewLeftPaneMinWidth
property real majorPaneMinWidth: JamiTheme.mainViewPaneMinWidth property real majorPaneMinWidth: JamiTheme.mainViewPaneMinWidth
property real previousMinorPaneWidth: leftPane.width property real previousMinorPaneWidth: isRTL ? leftPane.width : rightPane.width
property real previousMajorPaneWidth: rightPane.width property real previousMajorPaneWidth: isRTL ? rightPane.width : leftPane.width
property bool isSinglePane property bool isSinglePane
onPresented: { onPresented: {
if (leftPaneItem) if (leftPaneItem)
leftPaneItem.parent = leftPane; leftPaneItem.parent = leftPane
if (rightPaneItem) if (rightPaneItem)
rightPaneItem.parent = rightPane; rightPaneItem.parent = rightPane
splitView.restoreSplitViewState(); splitView.restoreSplitViewState()
resolvePanes(); resolvePanes()
} }
onDismissed: splitView.saveSplitViewState() onDismissed: splitView.saveSplitViewState()
Component.onCompleted: { Component.onCompleted: {
// Avoid double triggering this handler during instantiation. // Avoid double triggering this handler during instantiation.
onIsSinglePaneChanged.connect(isSinglePaneChangedHandler); onIsSinglePaneChanged.connect(isSinglePaneChangedHandler)
} }
onWidthChanged: resolvePanes() onWidthChanged: resolvePanes()
function resolvePanes() { function resolvePanes() {
isSinglePane = width < majorPaneMinWidth + previousMinorPaneWidth; isSinglePane = width < majorPaneMinWidth + previousMinorPaneWidth
} }
// Override this if needed. // Override this if needed.
property var isSinglePaneChangedHandler: function () { property var isSinglePaneChangedHandler: function () {
rightPaneItem.parent = isSinglePane ? leftPane : rightPane; rightPaneItem.parent = isSinglePane ? leftPane : rightPane
} }
JamiSplitView { JamiSplitView {
...@@ -83,11 +85,24 @@ BaseView { ...@@ -83,11 +85,24 @@ BaseView {
clip: true clip: true
required property bool isMinorPane required property bool isMinorPane
onWidthChanged: { onWidthChanged: {
if (!isSinglePane && isMinorPane) if (!isSinglePane && ((isRTL && !isMinorPane) || (!isRTL && isMinorPane)))
previousMinorPaneWidth = width; previousMinorPaneWidth = width
if (!isSinglePane && ((isRTL && isMinorPane) || (!isRTL && !isMinorPane)))
previousMajorPaneWidth = width
} }
SplitView.minimumWidth: isSinglePane ? viewNode.width : (isMinorPane ? minorPaneMinWidth : majorPaneMinWidth)
SplitView.maximumWidth: isSinglePane ? viewNode.width : viewNode.width - (isMinorPane ? majorPaneMinWidth : minorPaneMinWidth) Connections {
SplitView.preferredWidth: isMinorPane ? minorPaneMinWidth : majorPaneMinWidth target: UtilsAdapter
function onIsRTLChanged() {
var bck = previousMinorPaneWidth
previousMinorPaneWidth = previousMajorPaneWidth
previousMajorPaneWidth = bck
}
}
SplitView.minimumWidth: isSinglePane ? viewNode.width : (isMinorPane && !isRTL ? minorPaneMinWidth : majorPaneMinWidth)
SplitView.maximumWidth: isSinglePane ? viewNode.width : viewNode.width - (isMinorPane && !isRTL ? majorPaneMinWidth : minorPaneMinWidth)
SplitView.preferredWidth: isMinorPane && !isRTL ? minorPaneMinWidth : majorPaneMinWidth
} }
} }
...@@ -24,10 +24,18 @@ SplitView { ...@@ -24,10 +24,18 @@ SplitView {
property bool isRTL: UtilsAdapter.isRTL property bool isRTL: UtilsAdapter.isRTL
property bool isSinglePane: false property bool isSinglePane: false
property bool isSwapped: UtilsAdapter.isRTL property bool isSwapped: false
onIsRTLChanged: swapItems() onIsRTLChanged: {
onIsSinglePaneChanged: swapItems() if (isRTL && isSinglePane && !isSwapped)
return
if ((isRTL && !isSwapped) || (!isRTL && isSwapped))
swapItems()
}
onIsSinglePaneChanged: {
if (isSwapped || isRTL)
swapItems()
}
property string splitViewStateKey: objectName property string splitViewStateKey: objectName
property bool autoManageState: !(parent instanceof BaseView) property bool autoManageState: !(parent instanceof BaseView)
...@@ -49,16 +57,13 @@ SplitView { ...@@ -49,16 +57,13 @@ SplitView {
} }
function swapItems() { function swapItems() {
if ((isSinglePane && !isSwapped) // Do not swap in isSinglePane mode isSwapped = !isSwapped
|| (!isRTL && !isSwapped)) // Do not swap if not RTL
return;
var qqci = children[0]; var qqci = children[0];
if (qqci.children.length > 1) { if (qqci.children.length > 1) {
// swap the children // swap the children
var tempPane = qqci.children[0]; var tempPane = qqci.children[0];
qqci.children[0] = qqci.children[1]; qqci.children[0] = qqci.children[1];
qqci.children.push(tempPane); qqci.children.push(tempPane);
isSwapped = true
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment