1
0
Fork 0
mirror of https://git.jami.net/savoirfairelinux/jami-client-qt.git synced 2025-03-28 14:56:19 +01:00

fullscreen: reimplement fullscreen for reliability

Reimplement the fullscreen behavior to only work during calls
and to make it more consistent.

Change-Id: I8fbad30dfcf577f5af7d809073e20105374deb35
This commit is contained in:
pmagnier-slimani 2025-03-03 13:50:26 -05:00 committed by Page Magnier-Slimani
parent 3143d60760
commit a407fa2c47
7 changed files with 52 additions and 40 deletions

View file

@ -17,6 +17,7 @@
import QtQuick
import QtQuick.Controls
import QtWebEngine
import net.jami.Adapters 1.1
import net.jami.Enums 1.1
@ -37,9 +38,12 @@ QtObject {
readonly property bool isHidden: visibility === Window.Hidden ||
visibility === Window.Minimized
// Used to store if a OngoingCallPage component is fullscreened.
// Used to store if a CallStackView component is fullscreened.
property bool isCallFullscreen: false
// Used to store if a WebEngineView component is fullscreened.
property bool isWebFullscreen: false
// QWK: Provide spacing for widgets that may be occluded by the system buttons.
property QtObject qwkSystemButtonSpacing: QtObject {
id: qwkSystemButtonSpacing
@ -150,9 +154,8 @@ QtObject {
// Adds an item to the fullscreen item stack. Automatically puts
// the main window in fullscreen mode if needed. Callbacks should be used
// to perform component-specific tasks upon successful transitions.
function pushFullScreenItem(item, prevParent, pushedCb, removedCb) {
if (item === null || item === undefined
|| priv.fullScreenItems.length >= 3) {
function pushFullScreenItem(item, removedCb=undefined) {
if (!item || priv.fullScreenItems.length >= 3) {
return
}
@ -162,15 +165,13 @@ QtObject {
// Add the item to our list and reparent it to appContainer.
priv.fullScreenItems.push({
"item": item,
"prevParent": prevParent,
"prevParent": item.parent,
"prevAnchorsFill": item.anchors.fill,
"removedCb": removedCb
})
item.parent = appContainer
item.anchors.fill = item.parent
if (pushedCb) {
pushedCb()
}
item.anchors.fill = appContainer
// Reevaluate isCallFullscreen.
priv.fullScreenItemsChanged()
@ -178,34 +179,37 @@ QtObject {
// Remove an item if specified, or by default, the top item. Automatically
// resets the main window to windowed mode if no items remain in the stack.
function popFullScreenItem(obj=null) {
function popFullScreenItem(obj = undefined) {
// Remove the item and reparent it to its original parent.
if (obj === null) {
obj = priv.fullScreenItems.pop()
if (obj === undefined) {
obj = priv.fullScreenItems.pop();
} else {
const index = priv.fullScreenItems.indexOf(obj);
if (index > -1) {
priv.fullScreenItems.splice(index, 1);
}
}
if (obj !== undefined) {
if (obj && typeof obj === 'object') {
if (obj.item !== appWindow) {
obj.item.anchors.fill = obj.prevAnchorsFill
obj.item.parent = obj.prevParent
if (obj.removedCb) {
obj.removedCb()
// Clear anchors first, then set parent, then reset anchors.
obj.item.anchors.fill = undefined;
obj.item.parent = obj.prevParent;
obj.item.anchors.fill = obj.prevAnchorsFill;
// Call removed callback if it's a function.
if (typeof obj.removedCb === 'function') {
obj.removedCb();
}
}
// Reevaluate isCallFullscreen.
priv.fullScreenItemsChanged()
priv.fullScreenItemsChanged();
}
// Only leave fullscreen mode if our window isn't in fullscreen
// mode already.
// Only leave fullscreen mode if our window isn't in fullscreen mode already.
if (priv.fullScreenItems.length === 0 && priv.windowedVisibility !== Window.Hidden) {
// Simply recall the last visibility state.
visibility = priv.windowedVisibility
visibility = priv.windowedVisibility;
}
}
@ -247,7 +251,10 @@ QtObject {
// When fullScreenItems is changed, we can recompute isCallFullscreen.
onFullScreenItemsChanged: {
isCallFullscreen = fullScreenItems
.filter(o => o.item instanceof OngoingCallPage)
.filter(o => o.item.objectName === "callViewLoader")
.length
isWebFullscreen = fullScreenItems
.filter(o => o.item instanceof WebEngineView)
.length
}
@ -258,7 +265,7 @@ QtObject {
function onHasCallChanged() {
if (!CallAdapter.hasCall && isCallFullscreen) {
priv.fullScreenItems.forEach(o => {
if (o.item instanceof OngoingCallPage) {
if (o.item.objectName === "callViewLoader") {
popFullScreenItem(o)
return
}

View file

@ -136,17 +136,12 @@ Rectangle {
}
Shortcut {
sequence: "F11"
sequence: "Esc"
context: Qt.ApplicationShortcut
onActivated: layoutManager.toggleWindowFullScreen()
}
Keys.onPressed: function (keyEvent) {
if (keyEvent.key === Qt.Key_Escape) {
onActivated: {
MessagesAdapter.replyToId = "";
MessagesAdapter.editId = "";
layoutManager.popFullScreenItem();
keyEvent.accepted = true;
}
}

View file

@ -171,8 +171,10 @@ ItemDelegate {
Connections {
target: menuAction !== undefined ? menuAction : null
function onTriggered() {
if (menuAction.popupMode !== CallActionBar.ActionPopupMode.ListElement)
itemListView.currentIndex = menuAction.listModel.getCurrentIndex();
if (menuAction.popupMode !== CallActionBar.ActionPopupMode.ListElement) {
var index = menuAction.listModel.currentIndex;
itemListView.currentIndex = index !== undefined ? index : 0;
}
}
}

View file

@ -40,6 +40,13 @@ Item {
onActivatedAmbiguously: CallAdapter.hangUpThisCall()
}
Shortcut {
sequence: "F11"
context: Qt.ApplicationShortcut
enabled: CurrentConversation.hasCall && !layoutManager.isWebFullscreen
onActivated: toggleFullScreen();
}
Keys.onPressed: {
if (LRCInstance.currentAccountType !== Profile.Type.SIP)
return;
@ -72,14 +79,15 @@ Item {
function toggleFullScreen() {
if (!layoutManager.isCallFullscreen) {
layoutManager.pushFullScreenItem(callStackMainView.item, callStackMainView, null, null);
layoutManager.pushFullScreenItem(callStackMainView);
} else {
layoutManager.removeFullScreenItem(callStackMainView.item);
layoutManager.removeFullScreenItem(callStackMainView);
}
}
Loader {
id: callStackMainView
objectName: "callViewLoader"
anchors.fill: parent

View file

@ -59,10 +59,6 @@ Window {
shortcut: "Ctrl+F"
description: qsTr("Search bar")
}
ListElement {
shortcut: "F11"
description: qsTr("Full screen")
}
ListElement {
shortcut: "Ctrl++"
description: qsTr("Increase font size")
@ -131,6 +127,10 @@ Window {
shortcut: "Ctrl+Shift+D"
description: qsTr("Decline call")
}
ListElement {
shortcut: "F11"
description: qsTr("Full screen")
}
ListElement {
shortcut: "M"
description: qsTr("Mute microphone")

View file

@ -53,7 +53,7 @@ WebEngineView {
}
onFullScreenRequested: function (request) {
if (request.toggleOn) {
layoutManager.pushFullScreenItem(this, localMediaCompLoader, null, function () {
layoutManager.pushFullScreenItem(this, function () {
wev.fullScreenCancelled();
});
} else if (!request.toggleOn) {

View file

@ -38,7 +38,7 @@ Rectangle {
Component.onCompleted: loadHtml(root.html, 'file:///')
onFullScreenRequested: function (request) {
if (request.toggleOn) {
layoutManager.pushFullScreenItem(this, root, null, function () {
layoutManager.pushFullScreenItem(this, function () {
wev.fullScreenCancelled();
});
} else if (!request.toggleOn) {