diff --git a/src/app/ComponentTestWindow.qml b/src/app/ComponentTestWindow.qml index a072ce828ee1aa1644c985f7659b65e0fa982f05..0fe64693f566248456e4f14d7aebb5eeb7eaa581 100644 --- a/src/app/ComponentTestWindow.qml +++ b/src/app/ComponentTestWindow.qml @@ -55,6 +55,7 @@ ApplicationWindow { Loader { id: loader + source: Qt.resolvedUrl(testComponentURI) onStatusChanged: { console.log("Status changed to:", loader.status) @@ -66,7 +67,6 @@ ApplicationWindow { // If any of the dimensions are not set, set them to the appWindow's dimensions item.width = item.width || Qt.binding(() => appWindow.width); item.height = item.height || Qt.binding(() => appWindow.height); - viewCoordinator.init(item); } } } diff --git a/src/app/mainview/components/CallButtonDelegate.qml b/src/app/mainview/components/CallButtonDelegate.qml index 19e3180de60d47dab3c5e4415621bcf1f9270ddf..317ebfa5c69e049b7df0109da93234d14c3918c6 100644 --- a/src/app/mainview/components/CallButtonDelegate.qml +++ b/src/app/mainview/components/CallButtonDelegate.qml @@ -273,14 +273,46 @@ ItemDelegate { popup: Popup { id: itemPopup - y: isVertical ? -(implicitHeight - root.height) / 2 - 18 : -implicitHeight - 12 + y: { + // Determine the y position based on the orientation. + if (isVertical) { + // For a vertical layout, adjust the y position to center the item vertically + // relative to the root's height, with an additional upward offset of 18 pixels. + y = -(implicitHeight - root.height) / 2 - 18; + } else { + // For non-vertical layouts, position the item fully above its normal position + // with an upward offset of 12 pixels from its implicit height. + y = -implicitHeight - 12; + } + } + x: { - if (isVertical) - return -implicitWidth - 12; - var xValue = -(implicitWidth - root.width) / 2 - 18; - var mainPoint = mapToItem(viewCoordinator.rootView, xValue, y); - var diff = mainPoint.x + itemListView.implicitWidth - viewCoordinator.rootView.width; - return diff > 0 ? xValue - diff - 24 : xValue; + // Initialize the x position based on the orientation. + if (isVertical) { + // If the layout is vertical, position the item to the left of its implicit width + // with an additional offset of 12 pixels. + x = -implicitWidth - 12; + } else { + // Note: isn't some of this logic built into the Popup? + + // Calculate an initial x value aiming to center the item horizontally + // relative to the root's width, with an additional offset. + var xValue = -(implicitWidth - root.width) / 2 - 18; + + // Map the adjusted x value to the coordinate space of the callOverlay to + // determine the actual position of the item within the overlay. + var pointMappedContainer = mapToItem(callOverlay, xValue, y); + + // Calculate the difference between the right edge of the itemListView + // (considering its position within callOverlay) and the right edge of the callOverlay. + // This checks if the item extends outside the overlay. + var diff = pointMappedContainer.x + itemListView.implicitWidth - callOverlay.width; + + // If the item extends beyond the overlay, adjust x value to the left to ensure + // it fits within the overlay, with an extra leftward margin of 24 pixels. + x = diff > 0 ? xValue - diff - 24 : xValue; + } + } implicitWidth: contentItem.implicitWidth diff --git a/src/app/mainview/components/OngoingCallPage.qml b/src/app/mainview/components/OngoingCallPage.qml index b233c95fa398362ebccd07a5fbba8149a2d00256..39cebf278642672fb4c36d088cb99fdb087dbfcc 100644 --- a/src/app/mainview/components/OngoingCallPage.qml +++ b/src/app/mainview/components/OngoingCallPage.qml @@ -190,6 +190,7 @@ Rectangle { opacity: hidden ? callOverlay.mainOverlayOpacity : 1 // Allow hiding the preview (available when anchored) + readonly property bool hovered: hoverHandler.hovered readonly property bool anchored: state !== "unanchored" property bool hidden: false readonly property real hiddenHandleSize: 32 @@ -226,7 +227,7 @@ Rectangle { ] anchors.top: parent.top anchors.bottom: parent.bottom - opacity: (localPreview.anchored && hoverHandler.hovered) || localPreview.hidden + opacity: (localPreview.anchored && localPreview.hovered) || localPreview.hidden Behavior on opacity { NumberAnimation { duration: 250; easing.type: Easing.OutExpo }} visible: opacity > 0 background: Rectangle { diff --git a/tests/qml/main.cpp b/tests/qml/main.cpp index ef1617ddac6f20cf9b93e46cc1594dcc4097b392..c3b3072e69459584e40534213bab80ffcf335b9d 100644 --- a/tests/qml/main.cpp +++ b/tests/qml/main.cpp @@ -74,6 +74,11 @@ public Q_SLOTS: */ void applicationAvailable() { + QLoggingCategory::setFilterRules("\n" + "*.debug=false\n" + "libclient.debug=false\n" + "\n"); + connectivityMonitor_.reset(new ConnectivityMonitor(this)); settingsManager_.reset(new AppSettingsManager(this)); systemTray_.reset(new SystemTray(settingsManager_.get(), this)); diff --git a/tests/qml/src/TestWrapper.qml b/tests/qml/src/TestWrapper.qml index 80dffc31d63be01df2f0f7be162d082673984451..02a33db15e95c32ea26517d8a275706c796550ac 100644 --- a/tests/qml/src/TestWrapper.qml +++ b/tests/qml/src/TestWrapper.qml @@ -39,7 +39,8 @@ Item { spy.target = signalObject; spy.signalName = signalName; // Perform the action that should emit the signal. - action(); + if (action) + action(); // Wait a maximum of 1 second for the signal to be emitted. spy.wait(1000); // Check the signal count and the provided expression. @@ -52,8 +53,6 @@ Item { when: QTestRootObject.windowShown } - Component.onCompleted: viewCoordinator.init(this) - property int visibility: 0 Binding { tw.visibility: uut.Window.window.visibility diff --git a/tests/qml/src/tst_OngoingCallPage.qml b/tests/qml/src/tst_OngoingCallPage.qml index 6ff04036cd0c5cfbf12fcd83fe0633856e87d0db..473d3af873bd58d018bab205378022d920e7dde2 100644 --- a/tests/qml/src/tst_OngoingCallPage.qml +++ b/tests/qml/src/tst_OngoingCallPage.qml @@ -106,6 +106,9 @@ TestWrapper { "visibleChanged", () => localPreview.stop(), () => !localPreview.visible)); + + // Move the mouse to the center of the call screen. + mouseMove(uut); } function test_localPreviewAnchoring() { @@ -113,7 +116,7 @@ TestWrapper { const container = localPreview.parent; // First check that the preview is anchored. - verify(localPreview.state.indexOf("unanchored") === -1); + verify(localPreview.anchored); const containerCenter = Qt.point(container.width / 2, container.height / 2); function moveAndVerifyState(dx, dy, expectedState) { @@ -139,7 +142,7 @@ TestWrapper { // Verify that during a drag process, the preview is unanchored. mousePress(localPreview); mouseMove(localPreview, 100, 100); - verify(localPreview.state.indexOf("unanchored") !== -1); + verify(!localPreview.anchored); mouseRelease(localPreview); }); } @@ -147,23 +150,33 @@ TestWrapper { function test_localPreviewHiding() { localPreviewTestWrapper(function(localPreview) { // Make sure the preview is anchored. - verify(localPreview.state.indexOf("unanchored") === -1); + verify(localPreview.anchored); // It should also not be hidden. compare(localPreview.hidden, false); // We presume that the preview is anchored and that once we hover over the // local preview, that the hide button will become visible. - // Note: There is currently an issue where the CallOverlay is detecting hover - // events, but child controls are not. This should be addressed as it seems - // to affect MouseArea, HoverHandler, Buttons, and other controls that rely - // on hover events. For now, we'll manually trigger the onClicked event. const hidePreviewButton = findChild(localPreview, "hidePreviewButton"); - hidePreviewButton.onClicked(); + // This is required when the opacity has an animation. + if (hidePreviewButton.visible) { + verify(waitForSignalAndCheck(hidePreviewButton, + "visibleChanged", + undefined, + () => !hidePreviewButton.visible)); + } + compare(hidePreviewButton.visible, false); + verify(waitForSignalAndCheck(hidePreviewButton, + "visibleChanged", + () => mouseMove(localPreview), + () => hidePreviewButton.visible)); + + // Click the hide button to hide the preview. + mouseClick(hidePreviewButton); compare(localPreview.hidden, true); - // "Click" the hide button again to unhide the preview. - hidePreviewButton.onClicked(); + // Click the hide button again to show the preview. + mouseClick(hidePreviewButton); compare(localPreview.hidden, false); }); }