Skip to content
Snippets Groups Projects
Commit 762cbbff authored by Andreas Traczyk's avatar Andreas Traczyk
Browse files

mainview: prevent details panel from opening maximized

also-misc: Removes SplitPanel state-saving

Gitlab: #1370
Change-Id: I71f5c209922ad69fb701e935a03078fb8e5ad2de
parent 500681fb
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,7 @@ import QtQuick.Controls ...@@ -19,6 +19,7 @@ import QtQuick.Controls
import net.jami.Adapters 1.1 import net.jami.Adapters 1.1
import net.jami.Constants 1.1 import net.jami.Constants 1.1
// A SplitView that supports dynamic RTL and splitView state saving.
SplitView { SplitView {
id: root id: root
......
...@@ -32,6 +32,9 @@ ListSelectionView { ...@@ -32,6 +32,9 @@ ListSelectionView {
splitViewStateKey: "Main" splitViewStateKey: "Main"
hasValidSelection: CurrentConversation.id !== '' hasValidSelection: CurrentConversation.id !== ''
visible: false
onPresented: visible = true
Connections { Connections {
target: CurrentConversation target: CurrentConversation
function onReloadInteractions() { function onReloadInteractions() {
...@@ -75,7 +78,7 @@ ListSelectionView { ...@@ -75,7 +78,7 @@ ListSelectionView {
anchors.fill: parent anchors.fill: parent
inCallView: parent == callStackView.chatViewContainer inCallView: parent == callStackView.chatViewContainer
property string currentConvId: CurrentConversation.id readonly property string currentConvId: CurrentConversation.id
onCurrentConvIdChanged: { onCurrentConvIdChanged: {
if (!CurrentConversation.hasCall) { if (!CurrentConversation.hasCall) {
Qt.callLater(focusChatView); Qt.callLater(focusChatView);
...@@ -86,7 +89,7 @@ ListSelectionView { ...@@ -86,7 +89,7 @@ ListSelectionView {
} }
onDismiss: { onDismiss: {
if (parent == chatViewContainer) { if (!inCallView) {
viewNode.dismiss(); viewNode.dismiss();
} else { } else {
callStackView.chatViewContainer.visible = false; callStackView.chatViewContainer.visible = false;
...@@ -94,10 +97,10 @@ ListSelectionView { ...@@ -94,10 +97,10 @@ ListSelectionView {
} }
} }
// Handle visibility change for the in-call chat only.
onVisibleChanged: { onVisibleChanged: {
if (!inCallView) if (inCallView) {
return; if (visible) {
if (visible && !parent.showDetails) {
focusChatView(); focusChatView();
} else { } else {
callStackView.contentView.forceActiveFocus(); callStackView.contentView.forceActiveFocus();
...@@ -105,6 +108,7 @@ ListSelectionView { ...@@ -105,6 +108,7 @@ ListSelectionView {
} }
} }
} }
}
CallStackView { CallStackView {
id: callStackView id: callStackView
......
...@@ -21,6 +21,7 @@ import net.jami.Models 1.1 ...@@ -21,6 +21,7 @@ import net.jami.Models 1.1
import net.jami.Adapters 1.1 import net.jami.Adapters 1.1
import net.jami.Constants 1.1 import net.jami.Constants 1.1
import net.jami.Enums 1.1 import net.jami.Enums 1.1
import "../../commoncomponents" import "../../commoncomponents"
import "../js/pluginhandlerpickercreation.js" as PluginHandlerPickerCreation import "../js/pluginhandlerpickercreation.js" as PluginHandlerPickerCreation
...@@ -28,7 +29,7 @@ Rectangle { ...@@ -28,7 +29,7 @@ Rectangle {
id: root id: root
// An enum to make the details panels more readable. // An enum to make the details panels more readable.
enum Panel { enum ExtrasPanel {
SwarmDetailsPanel, SwarmDetailsPanel,
MessagesResearchPanel, MessagesResearchPanel,
AddMemberPanel AddMemberPanel
...@@ -40,6 +41,18 @@ Rectangle { ...@@ -40,6 +41,18 @@ Rectangle {
required property bool inCallView required property bool inCallView
// Hide the extrasPanel when going into a call view, but save the previous
// state to restore it when leaving the call view.
property int chatExtrasPanelIndex: extrasPanel.currentIndex
onInCallViewChanged: {
if (inCallView) {
chatExtrasPanelIndex = extrasPanel.currentIndex;
extrasPanel.closePanel();
} else if (chatExtrasPanelIndex >= 0) {
extrasPanel.openPanel(chatExtrasPanelIndex);
}
}
signal dismiss signal dismiss
function focusChatView() { function focusChatView() {
...@@ -61,6 +74,16 @@ Rectangle { ...@@ -61,6 +74,16 @@ Rectangle {
} }
} }
// Used externally to switch to a extras panel.
function switchToPanel(panel, toggle = true) {
extrasPanel.switchToPanel(panel, toggle);
}
// Used externally to close the extras panel.
function closePanel() {
extrasPanel.closePanel();
}
Connections { Connections {
target: PositionManager target: PositionManager
function onOpenNewMap() { function onOpenNewMap() {
...@@ -71,23 +94,13 @@ Rectangle { ...@@ -71,23 +94,13 @@ Rectangle {
Connections { Connections {
target: CurrentConversation target: CurrentConversation
function onIdChanged() { function onIdChanged() {
extrasPanel.restoreState();
MessagesAdapter.loadMoreMessages(); MessagesAdapter.loadMoreMessages();
} }
} }
Component.onCompleted: extrasPanel.restoreState()
onVisibleChanged: { onVisibleChanged: {
if (visible) { if (visible) {
chatViewSplitView.resolvePanes(true); chatViewSplitView.resolvePanes(true);
if (root.parent.objectName === "CallViewChatViewContainer") {
if (root.parent.showDetails) {
extrasPanel.switchToPanel(ChatView.SwarmDetailsPanel);
} else {
extrasPanel.closePanel();
}
}
} }
} }
...@@ -99,9 +112,6 @@ Rectangle { ...@@ -99,9 +112,6 @@ Rectangle {
ChatViewHeader { ChatViewHeader {
id: chatViewHeader id: chatViewHeader
addParticipantOpened: extrasPanel.currentIndex === ChatView.AddMemberPanel
swarmDetailsOpened: extrasPanel.currentIndex === ChatView.SwarmDetailsPanel
Layout.alignment: Qt.AlignHCenter Layout.alignment: Qt.AlignHCenter
Layout.fillWidth: true Layout.fillWidth: true
Layout.preferredHeight: JamiTheme.chatViewHeaderPreferredHeight Layout.preferredHeight: JamiTheme.chatViewHeaderPreferredHeight
...@@ -114,9 +124,6 @@ Rectangle { ...@@ -114,9 +124,6 @@ Rectangle {
} }
onBackClicked: root.dismiss() onBackClicked: root.dismiss()
onShowDetailsClicked: extrasPanel.switchToPanel(ChatView.SwarmDetailsPanel)
onSearchClicked: extrasPanel.switchToPanel(ChatView.MessagesResearchPanel)
onAddToConversationClicked: extrasPanel.switchToPanel(ChatView.AddMemberPanel)
Connections { Connections {
target: CurrentConversation target: CurrentConversation
...@@ -190,47 +197,69 @@ Rectangle { ...@@ -190,47 +197,69 @@ Rectangle {
Layout.fillWidth: true Layout.fillWidth: true
Layout.fillHeight: true Layout.fillHeight: true
splitViewStateKey: "Chat"
property real previousDetailsWidth: extrasPanel.width
property real previousWidth: width property real previousWidth: width
onWidthChanged: resolvePanes() onWidthChanged: {
// This function governs the visibility of the chatContents and tracks the resolvePanes();
// the width of the SplitView and the details panel. This function should be // Track the previous width of the split view.
// called when the width of the SplitView changes, when the SplitView is shown, previousWidth = width;
// and when the details panel is shown. When called with force=true, it is being }
// called from a visibleChanged event, and we should not update the previous widths.
// Track the previous width of the split view.
property real extrasPanelWidth: extrasPanel.width
// The previousExtrasPanelWidth is initialized to the minimum width
// of the extras panel. The value is updated within the "open"-state
// range of the panel (e.g. not 0 or maximized).
property real previousExtrasPanelWidth: JamiTheme.extrasPanelMinWidth
onExtrasPanelWidthChanged: {
resolvePanes();
// This range should ensure that the panel won't restore to maximized.
if (extrasPanelWidth != 0 && extrasPanelWidth != width) {
console.debug("Saving previous extras panel width: %1".arg(extrasPanelWidth));
previousExtrasPanelWidth = extrasPanelWidth;
}
}
// Respond to visibility changes for the extras panel in order to
// determine the structure of the split view.
property bool extrasPanelVisible: extrasPanel.visible
onExtrasPanelVisibleChanged: {
if (extrasPanelVisible) {
extrasPanelWidth = previousExtrasPanelWidth;
} else {
previousExtrasPanelWidth = extrasPanelWidth;
}
resolvePanes();
}
function resolvePanes(force = false) { function resolvePanes(force = false) {
if (!viewNode.visible) {
return;
}
// If the details panel is not visible, then show the chatContents. // If the details panel is not visible, then show the chatContents.
if (!extrasPanel.visible) { if (!extrasPanel.visible) {
chatContents.visible = true; chatContents.visible = true;
return; return;
} }
// Next we compute whether the SplitView is expanding or shrinking.
const isExpanding = width > previousWidth; const isExpanding = width > previousWidth;
// Provide a detailed log here, as this function seems problematic.
console.debug("ChatViewSplitView.resolvePanes: f: %1 w: %2 pw: %3 epw: %4 pepw: %5 ie: %6"
.arg(force).arg(width).arg(previousWidth)
.arg(extrasPanelWidth).arg(previousExtrasPanelWidth).arg(isExpanding));
const maximizePredicate = (!isExpanding || force) && chatContents.visible;
const minimizePredicate = (isExpanding || force) && !chatContents.visible;
const mainViewMinWidth = JamiTheme.mainViewPaneMinWidth;
// If the SplitView is not wide enough to show both the chatContents // If the SplitView is not wide enough to show both the chatContents
// and the details panel, then hide the chatContents. // and the details panel, then hide the chatContents.
if (width < JamiTheme.mainViewPaneMinWidth + extrasPanel.width && (!isExpanding || force) && chatContents.visible) { if (maximizePredicate && width < mainViewMinWidth + extrasPanelWidth) {
if (!force)
previousDetailsWidth = extrasPanel.width;
chatContents.visible = false; chatContents.visible = false;
} else if (width >= JamiTheme.mainViewPaneMinWidth + previousDetailsWidth && (isExpanding || force) && !chatContents.visible) { } else if (minimizePredicate && width >= mainViewMinWidth + previousExtrasPanelWidth) {
chatContents.visible = true; chatContents.visible = true;
} }
if (!force)
previousWidth = width;
}
Connections {
target: viewNode
function onPresented() {
chatViewSplitView.restoreSplitViewState();
}
function onDismissed() {
chatViewSplitView.saveSplitViewState();
}
} }
ColumnLayout { ColumnLayout {
...@@ -315,19 +344,12 @@ Rectangle { ...@@ -315,19 +344,12 @@ Rectangle {
} }
} }
onResizingChanged: if (chatContents.visible)
extrasPanel.previousWidth = extrasPanel.width
ConversationExtrasPanel { ConversationExtrasPanel {
id: extrasPanel id: extrasPanel
property int previousWidth: JamiTheme.extrasPanelMinWidth
SplitView.maximumWidth: root.width SplitView.maximumWidth: root.width
SplitView.minimumWidth: JamiTheme.extrasPanelMinWidth SplitView.minimumWidth: JamiTheme.extrasPanelMinWidth
SplitView.preferredWidth: JamiTheme.extrasPanelMinWidth SplitView.preferredWidth: JamiTheme.extrasPanelMinWidth
onVisibleChanged: chatViewSplitView.resolvePanes(true)
} }
} }
} }
......
...@@ -23,16 +23,14 @@ import net.jami.Adapters 1.1 ...@@ -23,16 +23,14 @@ import net.jami.Adapters 1.1
import net.jami.Constants 1.1 import net.jami.Constants 1.1
import net.jami.Enums 1.1 import net.jami.Enums 1.1
import net.jami.Models 1.1 import net.jami.Models 1.1
import "../../commoncomponents" import "../../commoncomponents"
Rectangle { Rectangle {
id: root id: root
signal backClicked signal backClicked
signal addToConversationClicked
signal pluginSelector signal pluginSelector
signal showDetailsClicked
signal searchClicked
Connections { Connections {
target: CurrentConversation target: CurrentConversation
...@@ -44,7 +42,7 @@ Rectangle { ...@@ -44,7 +42,7 @@ Rectangle {
description.eText = CurrentConversation.description; description.eText = CurrentConversation.description;
} }
function onShowSwarmDetails() { function onShowSwarmDetails() {
root.showDetailsClicked(); extrasPanel.switchToPanel(ChatView.SwarmDetailsPanel);
} }
} }
...@@ -60,11 +58,10 @@ Rectangle { ...@@ -60,11 +58,10 @@ Rectangle {
return true; return true;
} }
property bool addParticipantOpened: false
property bool swarmDetailsOpened: false
property bool addMemberVisibility: { property bool addMemberVisibility: {
return swarmDetailsVisibility && !CurrentConversation.isCoreDialog && !CurrentConversation.isRequest; return swarmDetailsVisibility
&& !CurrentConversation.isCoreDialog
&& !CurrentConversation.isRequest;
} }
property bool swarmDetailsVisibility: { property bool swarmDetailsVisibility: {
...@@ -171,9 +168,7 @@ Rectangle { ...@@ -171,9 +168,7 @@ Rectangle {
MessagesAdapter.searchbarPrompt = text; MessagesAdapter.searchbarPrompt = text;
} }
onSearchClicked: { onSearchClicked: extrasPanel.switchToPanel(ChatView.MessagesResearchPanel)
root.searchClicked();
}
Shortcut { Shortcut {
sequence: "Ctrl+Shift+F" sequence: "Ctrl+Shift+F"
...@@ -209,12 +204,12 @@ Rectangle { ...@@ -209,12 +204,12 @@ Rectangle {
id: addParticipantsButton id: addParticipantsButton
checkable: true checkable: true
checked: root.addParticipantOpened checked: extrasPanel.isOpen(ChatView.AddMemberPanel)
visible: interactionButtonsVisibility && addMemberVisibility visible: interactionButtonsVisibility && addMemberVisibility
source: JamiResources.add_people_24dp_svg source: JamiResources.add_people_24dp_svg
toolTipText: JamiStrings.addParticipants toolTipText: JamiStrings.addParticipants
onClicked: addToConversationClicked() onClicked: extrasPanel.switchToPanel(ChatView.AddMemberPanel)
} }
JamiPushButton { JamiPushButton {
...@@ -241,12 +236,12 @@ Rectangle { ...@@ -241,12 +236,12 @@ Rectangle {
id: detailsButton id: detailsButton
checkable: true checkable: true
checked: root.swarmDetailsOpened checked: extrasPanel.isOpen(ChatView.SwarmDetailsPanel)
visible: interactionButtonsVisibility && (swarmDetailsVisibility || LRCInstance.currentAccountType === Profile.Type.SIP) // TODO if SIP not a request visible: interactionButtonsVisibility && (swarmDetailsVisibility || LRCInstance.currentAccountType === Profile.Type.SIP) // TODO if SIP not a request
source: JamiResources.swarm_details_panel_svg source: JamiResources.swarm_details_panel_svg
toolTipText: JamiStrings.details toolTipText: JamiStrings.details
onClicked: showDetailsClicked() onClicked: extrasPanel.switchToPanel(ChatView.SwarmDetailsPanel)
} }
} }
......
...@@ -21,24 +21,46 @@ import net.jami.Adapters 1.1 ...@@ -21,24 +21,46 @@ import net.jami.Adapters 1.1
StackLayout { StackLayout {
id: root id: root
// We need to set the currentIndex to -1 to make sure the
// panel is closed when the application starts.
Component.onCompleted: closePanel()
// The index of the tab in the swarm details panel.
property int detailsIndex: -1 property int detailsIndex: -1
function isOpen(panel) { // Best to avoid using the visible property directly.
return visible && currentIndex === panel; // Pass through the following open/close wrappers instead.
function openPanel(panel) {
currentIndex = panel;
visible = true;
} }
visible: currentIndex > -1 function closePanel() {
currentIndex = -1;
visible = false;
}
property bool detailsShouldOpen: false function isOpen(panel) {
onVisibleChanged: if (visible) return visible && currentIndex === panel;
detailsShouldOpen = true }
function restoreState() { // This will open the details panel if it's not already visible.
// Only applies to Jami accounts, and we musn't be in a call. // Additionally, `toggle` being true (default) will close the panel
if (detailsShouldOpen && !inCallView && !CurrentConversation.needsSyncing && !CurrentConversation.isRequest) { // if it is already open to `panel`.
switchToPanel(ChatView.SwarmDetailsPanel, false); function switchToPanel(panel, toggle = true) {
} else { console.debug("switchToPanel: %1, toggle: %2".arg(panel).arg(toggle));
if (visible) {
// We need to close the panel if it's open and we're switching to
// the same panel.
if (toggle && currentIndex === panel) {
// Toggle off.
closePanel(); closePanel();
} else {
// Switch to the new panel.
openPanel(panel);
}
} else {
openPanel(panel);
} }
} }
...@@ -54,24 +76,6 @@ StackLayout { ...@@ -54,24 +76,6 @@ StackLayout {
} }
} }
// This will open the details panel if it's not already visible.
// Additionally, `toggle` being true (default) will close the panel
// if it is already open to `panel`.
function switchToPanel(panel, toggle = true) {
if (visible && toggle && currentIndex === panel) {
closePanel();
} else {
currentIndex = panel;
}
}
function closePanel() {
// We need to close the panel, but not save it when appropriate.
currentIndex = -1;
if (!inCallView)
detailsShouldOpen = false;
}
SwarmDetailsPanel { SwarmDetailsPanel {
id: detailsPanel id: detailsPanel
...@@ -81,8 +85,6 @@ StackLayout { ...@@ -81,8 +85,6 @@ StackLayout {
// Save it when it changes. // Save it when it changes.
onTabBarIndexChanged: root.detailsIndex = tabBarIndex onTabBarIndexChanged: root.detailsIndex = tabBarIndex
} }
MessagesResearchPanel { MessagesResearchPanel {}
} AddMemberPanel {}
AddMemberPanel {
}
} }
...@@ -39,6 +39,9 @@ Rectangle { ...@@ -39,6 +39,9 @@ Rectangle {
property alias chatViewContainer: chatViewContainer property alias chatViewContainer: chatViewContainer
property string callPreviewId property string callPreviewId
// A link to the first child will provide access to the chat view.
property var chatView: chatViewContainer.children[0]
onCallPreviewIdChanged: { onCallPreviewIdChanged: {
controlPreview.start(); controlPreview.start();
} }
...@@ -61,6 +64,20 @@ Rectangle { ...@@ -61,6 +64,20 @@ Rectangle {
} }
} }
function setCallChatVisibility(visible) {
if (visible) {
mainColumnLayout.isHorizontal = UtilsAdapter.getAppValue(Settings.Key.ShowChatviewHorizontally);
chatViewContainer.visible = false;
chatViewContainer.visible = true;
} else {
chatViewContainer.visible = false;
}
}
function toggleCallChatVisibility() {
setCallChatVisibility(!chatViewContainer.visible);
}
function openInCallConversation() { function openInCallConversation() {
mainColumnLayout.isHorizontal = UtilsAdapter.getAppValue(Settings.Key.ShowChatviewHorizontally); mainColumnLayout.isHorizontal = UtilsAdapter.getAppValue(Settings.Key.ShowChatviewHorizontally);
chatViewContainer.visible = false; chatViewContainer.visible = false;
...@@ -291,10 +308,7 @@ Rectangle { ...@@ -291,10 +308,7 @@ Rectangle {
anchors.fill: parent anchors.fill: parent
function toggleConversation() { function toggleConversation() {
if (inCallMessageWebViewStack.visible) toggleCallChatVisibility();
closeInCallConversation();
else
openInCallConversation();
} }
Connections { Connections {
...@@ -322,19 +336,13 @@ Rectangle { ...@@ -322,19 +336,13 @@ Rectangle {
participantsLayer.hoveredOverVideoMuted = true; participantsLayer.hoveredOverVideoMuted = true;
} }
onChatButtonClicked: { onChatButtonClicked: toggleCallChatVisibility()
var detailsVisible = chatViewContainer.showDetails; onFullScreenClicked: callStackView.toggleFullScreen()
chatViewContainer.showDetails = false;
!chatViewContainer.visible || detailsVisible ? openInCallConversation() : closeInCallConversation();
}
onFullScreenClicked: {
callStackView.toggleFullScreen();
}
onSwarmDetailsClicked: { onSwarmDetailsClicked: {
chatViewContainer.showDetails = !chatViewContainer.showDetails; toggleCallChatVisibility();
chatViewContainer.showDetails ? openInCallConversation() : closeInCallConversation(); if (chatViewContainer.visible) {
chatView.switchToPanel(ChatView.SwarmDetailsPanel);
}
} }
} }
......
...@@ -23,6 +23,7 @@ import Qt5Compat.GraphicalEffects ...@@ -23,6 +23,7 @@ import Qt5Compat.GraphicalEffects
import net.jami.Models 1.1 import net.jami.Models 1.1
import net.jami.Adapters 1.1 import net.jami.Adapters 1.1
import net.jami.Constants 1.1 import net.jami.Constants 1.1
import "../../commoncomponents" import "../../commoncomponents"
import "../../settingsview/components" import "../../settingsview/components"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment