diff --git a/src/app/commoncomponents/JamiSplitView.qml b/src/app/commoncomponents/JamiSplitView.qml index b17eb00136433e2498e7714a69bbaca9f5d2433c..64fdb95cabf5a7c116cd217bbb871cc23321fabb 100644 --- a/src/app/commoncomponents/JamiSplitView.qml +++ b/src/app/commoncomponents/JamiSplitView.qml @@ -1,83 +1,97 @@ -/* - * Copyright (C) 2024 Savoir-faire Linux Inc. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ -import QtQuick -import QtQuick.Controls -import net.jami.Adapters 1.1 -import net.jami.Constants 1.1 - -// A SplitView that supports dynamic RTL and splitView state saving. -SplitView { - id: root - - property bool isRTL: UtilsAdapter.isRTL - property bool isSinglePane: false - property bool isSwapped: false - - 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) - - function saveSplitViewState() { - UtilsAdapter.setAppValue("sv_" + splitViewStateKey, root.saveState()); - } - - function restoreSplitViewState() { - root.restoreState(UtilsAdapter.getAppValue("sv_" + splitViewStateKey)); - } - - onResizingChanged: if (!resizing) - saveSplitViewState() - onVisibleChanged: { - if (!autoManageState) - return; - visible ? restoreSplitViewState() : saveSplitViewState(); - } - - function swapItems() { - 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); - } - } - - handle: Rectangle { - visible: !isSinglePane - implicitWidth: JamiTheme.splitViewHandlePreferredWidth - implicitHeight: root.height - color: JamiTheme.primaryBackgroundColor - Rectangle { - anchors.left: parent.left - implicitWidth: 1 - implicitHeight: root.height - color: JamiTheme.tabbarBorderColor - } - } -} +/* + * Copyright (C) 2024 Savoir-faire Linux Inc. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <https://www.gnu.org/licenses/>. + */ +import QtQuick +import QtQuick.Controls +import net.jami.Adapters 1.1 +import net.jami.Constants 1.1 + +// A SplitView that supports dynamic RTL and splitView state saving. +SplitView { + id: control + + property bool isRTL: UtilsAdapter.isRTL + property bool isSinglePane: false + property bool isSwapped: false + property real handleSize: 1 + + 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) + + function saveSplitViewState() { + UtilsAdapter.setAppValue("sv_" + splitViewStateKey, control.saveState()); + } + + function restoreSplitViewState() { + control.restoreState(UtilsAdapter.getAppValue("sv_" + splitViewStateKey)); + } + + onResizingChanged: if (!resizing) + saveSplitViewState() + onVisibleChanged: { + if (!autoManageState) + return; + visible ? restoreSplitViewState() : saveSplitViewState(); + } + + function swapItems() { + 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); + } + } + + handle: Rectangle { + id: handleRoot + + readonly property int defaultSize: control.handleSize + + implicitWidth: control.orientation === Qt.Horizontal ? handleRoot.defaultSize : control.width + implicitHeight: control.orientation === Qt.Horizontal ? control.height : handleRoot.defaultSize + + color: JamiTheme.tabbarBorderColor + + containmentMask: Item { + // In the default configuration, the total handle size is the sum of the default size of the + // handle and the extra handle size (4). If the layout is not right-to-left (RTL), the handle + // is positioned at 0 on the X-axis, otherwise it's positioned to the left by the extra handle + // size (4 pixels). This is done to make it easier to grab small scroll-view handles that are + // adjacent to the SplitView handle. Note: vertically oriented handles are not offset. + readonly property real extraHandleSize: 4 + readonly property real handleXPosition: !isRTL ? 0 : -extraHandleSize + readonly property real handleSize: handleRoot.defaultSize + extraHandleSize + + x: control.orientation === Qt.Horizontal ? handleXPosition : 0 + width: control.orientation === Qt.Horizontal ? handleSize : handleRoot.width + height: control.orientation === Qt.Horizontal ? handleRoot.height : handleSize + } + } +} diff --git a/src/app/mainview/components/ChatView.qml b/src/app/mainview/components/ChatView.qml index a25a8b6fb01aaf4cb266b70a67e4435a90505fbf..a1e62d702f2c52498d4014e575c2169eeae5fe5d 100644 --- a/src/app/mainview/components/ChatView.qml +++ b/src/app/mainview/components/ChatView.qml @@ -222,7 +222,7 @@ Rectangle { onExtrasPanelWidthChanged: { resolvePanes(); // This range should ensure that the panel won't restore to maximized. - if (extrasPanelWidth !== 0 && extrasPanelWidth !== width) { + if (extrasPanelWidth !== 0 && extrasPanelWidth !== this.width) { console.debug("Saving previous extras panel width: %1".arg(extrasPanelWidth)); previousExtrasPanelWidth = extrasPanelWidth; }