diff --git a/src/gui/tray/Window.qml b/src/gui/tray/Window.qml index 1061a3c84598..f7f88fb878e4 100644 --- a/src/gui/tray/Window.qml +++ b/src/gui/tray/Window.qml @@ -706,7 +706,7 @@ ApplicationWindow { UnifiedSearchResultNothingFound { id: unifiedSearchResultNothingFound - visible: false + anchors.top: trayWindowUnifiedSearchInputContainer.bottom anchors.left: trayWindowMainItem.left anchors.right: trayWindowMainItem.right @@ -715,28 +715,11 @@ ApplicationWindow { text: UserModel.currentUser.unifiedSearchResultsListModel.searchTerm property bool isSearchRunning: UserModel.currentUser.unifiedSearchResultsListModel.isSearchInProgress + property bool waitingForSearchTermEditEnd: UserModel.currentUser.unifiedSearchResultsListModel.waitingForSearchTermEditEnd property bool isSearchResultsEmpty: unifiedSearchResultsListView.count === 0 property bool nothingFound: text && isSearchResultsEmpty && !UserModel.currentUser.unifiedSearchResultsListModel.errorString - onIsSearchRunningChanged: { - if (unifiedSearchResultNothingFound.isSearchRunning) { - visible = false; - } else { - if (nothingFound) { - visible = true; - } - } - } - - onTextChanged: { - visible = false; - } - - onIsSearchResultsEmptyChanged: { - if (!unifiedSearchResultNothingFound.isSearchResultsEmpty) { - visible = false; - } - } + visible: !isSearchRunning && !waitingForSearchTermEditEnd && nothingFound } Loader { diff --git a/src/gui/tray/unifiedsearchresultslistmodel.cpp b/src/gui/tray/unifiedsearchresultslistmodel.cpp index 0e9a44fe0afa..805af8ea4b6b 100644 --- a/src/gui/tray/unifiedsearchresultslistmodel.cpp +++ b/src/gui/tray/unifiedsearchresultslistmodel.cpp @@ -194,6 +194,7 @@ Q_LOGGING_CATEGORY(lcUnifiedSearch, "nextcloud.gui.unifiedsearch", QtInfoMsg) UnifiedSearchResultsListModel::UnifiedSearchResultsListModel(AccountState *accountState, QObject *parent) : QAbstractListModel(parent) + , _waitingForSearchTermEditEnd(false) , _accountState(accountState) { } @@ -280,6 +281,11 @@ QString UnifiedSearchResultsListModel::currentFetchMoreInProgressProviderId() co return _currentFetchMoreInProgressProviderId; } +bool UnifiedSearchResultsListModel::waitingForSearchTermEditEnd() const +{ + return _waitingForSearchTermEditEnd; +} + void UnifiedSearchResultsListModel::setSearchTerm(const QString &term) { if (term == _searchTerm) { @@ -303,6 +309,8 @@ void UnifiedSearchResultsListModel::setSearchTerm(const QString &term) if (_unifiedSearchTextEditingFinishedTimer.isActive()) { _unifiedSearchTextEditingFinishedTimer.stop(); + _waitingForSearchTermEditEnd = false; + emit waitingForSearchTermEditEndChanged(); } if (!_searchTerm.isEmpty()) { @@ -310,6 +318,8 @@ void UnifiedSearchResultsListModel::setSearchTerm(const QString &term) connect(&_unifiedSearchTextEditingFinishedTimer, &QTimer::timeout, this, &UnifiedSearchResultsListModel::slotSearchTermEditingFinished); _unifiedSearchTextEditingFinishedTimer.start(); + _waitingForSearchTermEditEnd = true; + emit waitingForSearchTermEditEndChanged(); } if (!_results.isEmpty()) { @@ -367,6 +377,9 @@ void UnifiedSearchResultsListModel::fetchMoreTriggerClicked(const QString &provi void UnifiedSearchResultsListModel::slotSearchTermEditingFinished() { + _waitingForSearchTermEditEnd = false; + emit waitingForSearchTermEditEndChanged(); + disconnect(&_unifiedSearchTextEditingFinishedTimer, &QTimer::timeout, this, &UnifiedSearchResultsListModel::slotSearchTermEditingFinished); diff --git a/src/gui/tray/unifiedsearchresultslistmodel.h b/src/gui/tray/unifiedsearchresultslistmodel.h index 7403b2ce9a95..c69a4ee8adfd 100644 --- a/src/gui/tray/unifiedsearchresultslistmodel.h +++ b/src/gui/tray/unifiedsearchresultslistmodel.h @@ -38,6 +38,7 @@ class UnifiedSearchResultsListModel : public QAbstractListModel currentFetchMoreInProgressProviderIdChanged) Q_PROPERTY(QString errorString READ errorString NOTIFY errorStringChanged) Q_PROPERTY(QString searchTerm READ searchTerm WRITE setSearchTerm NOTIFY searchTermChanged) + Q_PROPERTY(bool waitingForSearchTermEditEnd READ waitingForSearchTermEditEnd NOTIFY waitingForSearchTermEditEndChanged) struct UnifiedSearchProvider { @@ -77,6 +78,7 @@ class UnifiedSearchResultsListModel : public QAbstractListModel QString currentFetchMoreInProgressProviderId() const; QString searchTerm() const; QString errorString() const; + bool waitingForSearchTermEditEnd() const; Q_INVOKABLE void resultClicked(const QString &providerId, const QUrl &resourceUrl) const; Q_INVOKABLE void fetchMoreTriggerClicked(const QString &providerId); @@ -106,6 +108,7 @@ class UnifiedSearchResultsListModel : public QAbstractListModel void isSearchInProgressChanged(); void errorStringChanged(); void searchTermChanged(); + void waitingForSearchTermEditEndChanged(); public slots: void setSearchTerm(const QString &term); @@ -121,6 +124,7 @@ private slots: QString _searchTerm; QString _errorString; + bool _waitingForSearchTermEditEnd; QString _currentFetchMoreInProgressProviderId;