From 3f269475257ddad7839e29715212e652d89ef39a Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 13:37:20 +0800 Subject: [PATCH 1/8] Make the unified search input being focused a valid active reason Signed-off-by: Claudio Cambra --- src/gui/tray/MainWindow.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/tray/MainWindow.qml b/src/gui/tray/MainWindow.qml index e01729ed3da68..b15a76e2cb6e2 100644 --- a/src/gui/tray/MainWindow.qml +++ b/src/gui/tray/MainWindow.qml @@ -229,6 +229,7 @@ ApplicationWindow { || unifiedSearchResultNothingFound.visible || unifiedSearchResultsErrorLabel.visible || unifiedSearchResultsListView.visible + || trayWindowUnifiedSearchInputContainer.activeFocus anchors.fill: parent anchors.margins: Style.trayWindowBorderWidth From 02372d9237f10904d88e004308011e1817dee182 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 13:37:47 +0800 Subject: [PATCH 2/8] Add a mouse area to allow de-focusing the unified search text field on click elsewhere Signed-off-by: Claudio Cambra --- src/gui/tray/MainWindow.qml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/gui/tray/MainWindow.qml b/src/gui/tray/MainWindow.qml index b15a76e2cb6e2..5d9da51b81fc8 100644 --- a/src/gui/tray/MainWindow.qml +++ b/src/gui/tray/MainWindow.qml @@ -238,6 +238,11 @@ ApplicationWindow { Accessible.role: Accessible.Grouping Accessible.name: qsTr("Nextcloud desktop main dialog") + MouseArea { + anchors.fill: parent + onClicked: forceActiveFocus() + } + TrayWindowHeader { id: trayWindowHeader From e8eb8adf5f7375cf0b675aba473ac921ba438d03 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 13:43:59 +0800 Subject: [PATCH 3/8] Fix keyboard tab behaviour when focus reaches unified search bar Do not activate search if the focus reason is tab as otherwise the user will never be able to access elements that depend on search being inactive via the keyboard Signed-off-by: Claudio Cambra --- src/gui/tray/MainWindow.qml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/gui/tray/MainWindow.qml b/src/gui/tray/MainWindow.qml index 5d9da51b81fc8..df558f0d17423 100644 --- a/src/gui/tray/MainWindow.qml +++ b/src/gui/tray/MainWindow.qml @@ -229,7 +229,7 @@ ApplicationWindow { || unifiedSearchResultNothingFound.visible || unifiedSearchResultsErrorLabel.visible || unifiedSearchResultsListView.visible - || trayWindowUnifiedSearchInputContainer.activeFocus + || trayWindowUnifiedSearchInputContainer.activateSearchFocus anchors.fill: parent anchors.margins: Style.trayWindowBorderWidth @@ -255,6 +255,8 @@ ApplicationWindow { UnifiedSearchInputContainer { id: trayWindowUnifiedSearchInputContainer + property bool activateSearchFocus: activeFocus + anchors.top: trayWindowHeader.bottom anchors.left: trayWindowMainItem.left anchors.right: trayWindowMainItem.right @@ -267,6 +269,7 @@ ApplicationWindow { isSearchInProgress: UserModel.currentUser.unifiedSearchResultsListModel.isSearchInProgress onTextEdited: { UserModel.currentUser.unifiedSearchResultsListModel.searchTerm = trayWindowUnifiedSearchInputContainer.text } onClearText: { UserModel.currentUser.unifiedSearchResultsListModel.searchTerm = "" } + onActiveFocusChanged: activateSearchFocus = activeFocus && focusReason !== Qt.TabFocusReason && focusReason !== Qt.BacktabFocusReason } Rectangle { From baedf1502e08bce579b5d01f679cc42599066287 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 14:02:00 +0800 Subject: [PATCH 4/8] On escape pressed of unified search placeholder view, diable activeSearchFocus Signed-off-by: Claudio Cambra --- src/gui/tray/MainWindow.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/tray/MainWindow.qml b/src/gui/tray/MainWindow.qml index df558f0d17423..d3d096038138f 100644 --- a/src/gui/tray/MainWindow.qml +++ b/src/gui/tray/MainWindow.qml @@ -270,6 +270,7 @@ ApplicationWindow { onTextEdited: { UserModel.currentUser.unifiedSearchResultsListModel.searchTerm = trayWindowUnifiedSearchInputContainer.text } onClearText: { UserModel.currentUser.unifiedSearchResultsListModel.searchTerm = "" } onActiveFocusChanged: activateSearchFocus = activeFocus && focusReason !== Qt.TabFocusReason && focusReason !== Qt.BacktabFocusReason + Keys.onEscapePressed: activateSearchFocus = false } Rectangle { From 5fdc8a236fd328791d25799c3067373703e8a3e1 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 14:02:58 +0800 Subject: [PATCH 5/8] Add a UnifiedSearchPlaceholderView Signed-off-by: Claudio Cambra --- resources.qrc | 1 + src/gui/tray/UnifiedSearchPlaceholderView.qml | 52 +++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/gui/tray/UnifiedSearchPlaceholderView.qml diff --git a/resources.qrc b/resources.qrc index 3733a5a73a710..9d1da12609314 100644 --- a/resources.qrc +++ b/resources.qrc @@ -38,6 +38,7 @@ src/gui/tray/UnifiedSearchResultItemSkeletonGradientRectangle.qml src/gui/tray/UnifiedSearchResultListItem.qml src/gui/tray/UnifiedSearchResultNothingFound.qml + src/gui/tray/UnifiedSearchPlaceholderView.qml src/gui/tray/UnifiedSearchResultSectionItem.qml src/gui/tray/ActivityItemContextMenu.qml src/gui/tray/ActivityItemActions.qml diff --git a/src/gui/tray/UnifiedSearchPlaceholderView.qml b/src/gui/tray/UnifiedSearchPlaceholderView.qml new file mode 100644 index 0000000000000..2653223e19344 --- /dev/null +++ b/src/gui/tray/UnifiedSearchPlaceholderView.qml @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2024 by Claudio Cambra + * + * 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 2 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. + */ + +import QtQml +import QtQuick +import QtQuick.Controls +import QtQuick.Layouts +import Style + +ColumnLayout { + id: unifiedSearchResultNothingFoundContainer + + spacing: Style.standardSpacing + + Item { + Layout.fillWidth: true + Layout.fillHeight: true + } + + Image { + id: unifiedSearchResultsNoResultsLabelIcon + source: "image://svgimage-custom-color/magnifying-glass.svg" + sourceSize.width: Style.trayWindowHeaderHeight / 2 + sourceSize.height: Style.trayWindowHeaderHeight / 2 + Layout.alignment: Qt.AlignHCenter + } + + EnforcedPlainTextLabel { + id: unifiedSearchResultsNoResultsLabel + text: qsTr("Start typing to search") + font.pixelSize: Style.subLinePixelSize * 1.25 + wrapMode: Text.Wrap + Layout.fillWidth: true + horizontalAlignment: Text.AlignHCenter + } + + Item { + Layout.fillWidth: true + Layout.fillHeight: true + } +} From a50074362eeb6e1fdb8fa68556d410e2ed2280d2 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 14:03:20 +0800 Subject: [PATCH 6/8] Place unified search placeholder view in main tray window view when in focus and no text is entered Signed-off-by: Claudio Cambra --- src/gui/tray/MainWindow.qml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/gui/tray/MainWindow.qml b/src/gui/tray/MainWindow.qml index d3d096038138f..3f80f58c6d1cb 100644 --- a/src/gui/tray/MainWindow.qml +++ b/src/gui/tray/MainWindow.qml @@ -296,6 +296,18 @@ ApplicationWindow { anchors.margins: Style.trayHorizontalMargin } + UnifiedSearchPlaceholderView { + id: unifiedSearchPlaceholderView + + anchors.top: bottomUnifiedSearchInputSeparator.bottom + anchors.left: trayWindowMainItem.left + anchors.right: trayWindowMainItem.right + anchors.bottom: trayWindowMainItem.bottom + anchors.topMargin: Style.trayHorizontalMargin + + visible: trayWindowUnifiedSearchInputContainer.activateSearchFocus && !UserModel.currentUser.unifiedSearchResultsListModel.searchTerm + } + UnifiedSearchResultNothingFound { id: unifiedSearchResultNothingFound From 1a052a42f2558dfa0ddcb4d854210d0924c6be16 Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 14:53:23 +0800 Subject: [PATCH 7/8] Clean up ids of internal components of placeholder views Signed-off-by: Claudio Cambra --- src/gui/tray/UnifiedSearchPlaceholderView.qml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/gui/tray/UnifiedSearchPlaceholderView.qml b/src/gui/tray/UnifiedSearchPlaceholderView.qml index 2653223e19344..10eb94af0489d 100644 --- a/src/gui/tray/UnifiedSearchPlaceholderView.qml +++ b/src/gui/tray/UnifiedSearchPlaceholderView.qml @@ -19,7 +19,7 @@ import QtQuick.Layouts import Style ColumnLayout { - id: unifiedSearchResultNothingFoundContainer + id: root spacing: Style.standardSpacing @@ -29,7 +29,6 @@ ColumnLayout { } Image { - id: unifiedSearchResultsNoResultsLabelIcon source: "image://svgimage-custom-color/magnifying-glass.svg" sourceSize.width: Style.trayWindowHeaderHeight / 2 sourceSize.height: Style.trayWindowHeaderHeight / 2 @@ -37,7 +36,6 @@ ColumnLayout { } EnforcedPlainTextLabel { - id: unifiedSearchResultsNoResultsLabel text: qsTr("Start typing to search") font.pixelSize: Style.subLinePixelSize * 1.25 wrapMode: Text.Wrap From f7ae0254fcb480bd4106973a075e997f313bcb3e Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Tue, 19 Nov 2024 14:53:51 +0800 Subject: [PATCH 8/8] Unify definition of unified seach placeholder views fonts Signed-off-by: Claudio Cambra --- src/gui/tray/UnifiedSearchPlaceholderView.qml | 2 +- src/gui/tray/UnifiedSearchResultNothingFound.qml | 4 ++-- theme/Style/Style.qml | 2 ++ 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gui/tray/UnifiedSearchPlaceholderView.qml b/src/gui/tray/UnifiedSearchPlaceholderView.qml index 10eb94af0489d..692f32c97e07d 100644 --- a/src/gui/tray/UnifiedSearchPlaceholderView.qml +++ b/src/gui/tray/UnifiedSearchPlaceholderView.qml @@ -37,7 +37,7 @@ ColumnLayout { EnforcedPlainTextLabel { text: qsTr("Start typing to search") - font.pixelSize: Style.subLinePixelSize * 1.25 + font.pixelSize: Style.unifiedSearchPlaceholderViewSublineFontPixelSize wrapMode: Text.Wrap Layout.fillWidth: true horizontalAlignment: Text.AlignHCenter diff --git a/src/gui/tray/UnifiedSearchResultNothingFound.qml b/src/gui/tray/UnifiedSearchResultNothingFound.qml index 175874e57aa39..1cab7fa5d1730 100644 --- a/src/gui/tray/UnifiedSearchResultNothingFound.qml +++ b/src/gui/tray/UnifiedSearchResultNothingFound.qml @@ -38,7 +38,7 @@ ColumnLayout { EnforcedPlainTextLabel { id: unifiedSearchResultsNoResultsLabel text: qsTr("No results for") - font.pixelSize: Style.subLinePixelSize * 1.25 + font.pixelSize: Style.unifiedSearchPlaceholderViewSublineFontPixelSize wrapMode: Text.Wrap Layout.fillWidth: true Layout.preferredHeight: Style.trayWindowHeaderHeight / 2 @@ -48,7 +48,7 @@ ColumnLayout { EnforcedPlainTextLabel { id: unifiedSearchResultsNoResultsLabelDetails text: unifiedSearchResultNothingFoundContainer.text - font.pixelSize: Style.topLinePixelSize * 1.25 + font.pixelSize: Style.unifiedSearchPlaceholderViewTitleFontPixelSize wrapMode: Text.Wrap maximumLineCount: 2 elide: Text.ElideRight diff --git a/theme/Style/Style.qml b/theme/Style/Style.qml index 6d63d2898a705..014fa5a07690f 100644 --- a/theme/Style/Style.qml +++ b/theme/Style/Style.qml @@ -141,6 +141,8 @@ QtObject { readonly property int unifiedSearchResultSectionItemVerticalPadding: 8 readonly property int unifiedSearchResultNothingFoundHorizontalMargin: 10 readonly property int unifiedSearchInputContainerHeight: 40 + readonly property int unifiedSearchPlaceholderViewTitleFontPixelSize: pixelSize * 1.25 + readonly property int unifiedSearchPlaceholderViewSublineFontPixelSize: subLinePixelSize * 1.25 readonly property int radioButtonCustomMarginLeftInner: 4 readonly property int radioButtonCustomMarginLeftOuter: 5