Skip to content

Commit

Permalink
Merge pull request #7512 from nextcloud/bugfix/search-view-on-focus
Browse files Browse the repository at this point in the history
Pull up the unified search view immediately on unified search field focus
  • Loading branch information
mgallien authored Nov 21, 2024
2 parents b421b35 + f7ae025 commit 0208ec6
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 2 deletions.
1 change: 1 addition & 0 deletions resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<file>src/gui/tray/UnifiedSearchResultItemSkeletonGradientRectangle.qml</file>
<file>src/gui/tray/UnifiedSearchResultListItem.qml</file>
<file>src/gui/tray/UnifiedSearchResultNothingFound.qml</file>
<file>src/gui/tray/UnifiedSearchPlaceholderView.qml</file>
<file>src/gui/tray/UnifiedSearchResultSectionItem.qml</file>
<file>src/gui/tray/ActivityItemContextMenu.qml</file>
<file>src/gui/tray/ActivityItemActions.qml</file>
Expand Down
22 changes: 22 additions & 0 deletions src/gui/tray/MainWindow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,7 @@ ApplicationWindow {
|| unifiedSearchResultNothingFound.visible
|| unifiedSearchResultsErrorLabel.visible
|| unifiedSearchResultsListView.visible
|| trayWindowUnifiedSearchInputContainer.activateSearchFocus

anchors.fill: parent
anchors.margins: Style.trayWindowBorderWidth
Expand All @@ -237,6 +238,11 @@ ApplicationWindow {
Accessible.role: Accessible.Grouping
Accessible.name: qsTr("Nextcloud desktop main dialog")

MouseArea {
anchors.fill: parent
onClicked: forceActiveFocus()
}

TrayWindowHeader {
id: trayWindowHeader

Expand All @@ -249,6 +255,8 @@ ApplicationWindow {
UnifiedSearchInputContainer {
id: trayWindowUnifiedSearchInputContainer

property bool activateSearchFocus: activeFocus

anchors.top: trayWindowHeader.bottom
anchors.left: trayWindowMainItem.left
anchors.right: trayWindowMainItem.right
Expand All @@ -261,6 +269,8 @@ 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
Keys.onEscapePressed: activateSearchFocus = false
}

Rectangle {
Expand All @@ -286,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

Expand Down
50 changes: 50 additions & 0 deletions src/gui/tray/UnifiedSearchPlaceholderView.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Copyright (C) 2024 by Claudio Cambra <[email protected]>
*
* 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: root

spacing: Style.standardSpacing

Item {
Layout.fillWidth: true
Layout.fillHeight: true
}

Image {
source: "image://svgimage-custom-color/magnifying-glass.svg"
sourceSize.width: Style.trayWindowHeaderHeight / 2
sourceSize.height: Style.trayWindowHeaderHeight / 2
Layout.alignment: Qt.AlignHCenter
}

EnforcedPlainTextLabel {
text: qsTr("Start typing to search")
font.pixelSize: Style.unifiedSearchPlaceholderViewSublineFontPixelSize
wrapMode: Text.Wrap
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
}

Item {
Layout.fillWidth: true
Layout.fillHeight: true
}
}
4 changes: 2 additions & 2 deletions src/gui/tray/UnifiedSearchResultNothingFound.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions theme/Style/Style.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0208ec6

Please sign in to comment.