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 {
required property Item leftPaneItem
required property Item rightPaneItem
property bool isRTL: UtilsAdapter.isRTL
property alias leftPane: leftPane
property alias rightPane: rightPane
......@@ -33,34 +35,34 @@ BaseView {
property real minorPaneMinWidth: JamiTheme.mainViewLeftPaneMinWidth
property real majorPaneMinWidth: JamiTheme.mainViewPaneMinWidth
property real previousMinorPaneWidth: leftPane.width
property real previousMajorPaneWidth: rightPane.width
property real previousMinorPaneWidth: isRTL ? leftPane.width : rightPane.width
property real previousMajorPaneWidth: isRTL ? rightPane.width : leftPane.width
property bool isSinglePane
onPresented: {
if (leftPaneItem)
leftPaneItem.parent = leftPane;
leftPaneItem.parent = leftPane
if (rightPaneItem)
rightPaneItem.parent = rightPane;
splitView.restoreSplitViewState();
resolvePanes();
rightPaneItem.parent = rightPane
splitView.restoreSplitViewState()
resolvePanes()
}
onDismissed: splitView.saveSplitViewState()
Component.onCompleted: {
// Avoid double triggering this handler during instantiation.
onIsSinglePaneChanged.connect(isSinglePaneChangedHandler);
onIsSinglePaneChanged.connect(isSinglePaneChangedHandler)
}
onWidthChanged: resolvePanes()
function resolvePanes() {
isSinglePane = width < majorPaneMinWidth + previousMinorPaneWidth;
isSinglePane = width < majorPaneMinWidth + previousMinorPaneWidth
}
// Override this if needed.
property var isSinglePaneChangedHandler: function () {
rightPaneItem.parent = isSinglePane ? leftPane : rightPane;
rightPaneItem.parent = isSinglePane ? leftPane : rightPane
}
JamiSplitView {
......@@ -83,11 +85,24 @@ BaseView {
clip: true
required property bool isMinorPane
onWidthChanged: {
if (!isSinglePane && isMinorPane)
previousMinorPaneWidth = width;
if (!isSinglePane && ((isRTL && !isMinorPane) || (!isRTL && isMinorPane)))
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)
SplitView.preferredWidth: isMinorPane ? minorPaneMinWidth : majorPaneMinWidth
Connections {
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 {
property bool isRTL: UtilsAdapter.isRTL
property bool isSinglePane: false
property bool isSwapped: UtilsAdapter.isRTL
property bool isSwapped: false
onIsRTLChanged: swapItems()
onIsSinglePaneChanged: swapItems()
onIsRTLChanged: {
if (isRTL && isSinglePane && !isSwapped)
return
if ((isRTL && !isSwapped) || (!isRTL && isSwapped))
swapItems()
}
onIsSinglePaneChanged: {
if (isSwapped || isRTL)
swapItems()
}
property string splitViewStateKey: objectName
property bool autoManageState: !(parent instanceof BaseView)
......@@ -49,16 +57,13 @@ SplitView {
}
function swapItems() {
if ((isSinglePane && !isSwapped) // Do not swap in isSinglePane mode
|| (!isRTL && !isSwapped)) // Do not swap if not RTL
return;
isSwapped = !isSwapped
var qqci = children[0];
if (qqci.children.length > 1) {
// swap the children
var tempPane = qqci.children[0];
qqci.children[0] = qqci.children[1];
qqci.children.push(tempPane);
isSwapped = true
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment