]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Show "Loading canceled" placeholder when loading was canceled
authorKai Uwe Broulik <kde@privat.broulik.de>
Tue, 5 Jul 2022 11:00:34 +0000 (13:00 +0200)
committerKai Uwe Broulik <kde@privat.broulik.de>
Thu, 7 Jul 2022 06:03:12 +0000 (06:03 +0000)
Rather than "Folder empty", which is misleading as we didn't
actually load anything.

src/views/dolphinview.cpp
src/views/dolphinview.h

index a6c90e990772b8784a5437c76d62589a8394544a..ccff1256aef11190b1d3c88808edb519d2f8ea6a 100644 (file)
@@ -70,7 +70,6 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
     m_assureVisibleCurrentIndex(false),
     m_isFolderWritable(true),
     m_dragging(false),
-    m_loading(false),
     m_url(url),
     m_viewPropertiesContext(),
     m_mode(DolphinView::IconsView),
@@ -1728,7 +1727,7 @@ void DolphinView::slotRenamingResult(KJob* job)
 
 void DolphinView::slotDirectoryLoadingStarted()
 {
-    m_loading = true;
+    m_loadingState = LoadingState::Loading;
     updatePlaceholderLabel();
 
     // Disable the writestate temporary until it can be determined in a fast way
@@ -1743,7 +1742,7 @@ void DolphinView::slotDirectoryLoadingStarted()
 
 void DolphinView::slotDirectoryLoadingCompleted()
 {
-    m_loading = false;
+    m_loadingState = LoadingState::Completed;
 
     // Update the view-state. This has to be done asynchronously
     // because the view might not be in its final state yet.
@@ -1760,7 +1759,7 @@ void DolphinView::slotDirectoryLoadingCompleted()
 
 void DolphinView::slotDirectoryLoadingCanceled()
 {
-    m_loading = false;
+    m_loadingState = LoadingState::Canceled;
 
     updatePlaceholderLabel();
 
@@ -2159,13 +2158,15 @@ void DolphinView::updatePlaceholderLabel()
         return;
     }
 
-    if (m_loading) {
+    if (m_loadingState == LoadingState::Loading) {
         m_placeholderLabel->setVisible(false);
         m_showLoadingPlaceholderTimer->start();
         return;
     }
 
-    if (!nameFilter().isEmpty()) {
+    if (m_loadingState == LoadingState::Canceled) {
+        m_placeholderLabel->setText(i18n("Loading canceled"));
+    } else if (!nameFilter().isEmpty()) {
         m_placeholderLabel->setText(i18n("No items matching the filter"));
     } else if (m_url.scheme() == QLatin1String("baloosearch") || m_url.scheme() == QLatin1String("filenamesearch")) {
         m_placeholderLabel->setText(i18n("No items matching the search"));
index 62ced31acd15b20a8ba7f910b68ea71b87889fdb..f3ba9445f2cc0958b416ec5a06cd1df361ee170e 100644 (file)
@@ -875,7 +875,14 @@ private:
     bool m_isFolderWritable;
     bool m_dragging; // True if a dragging is done. Required to be able to decide whether a
                      // tooltip may be shown when hovering an item.
-    bool m_loading;
+
+    enum class LoadingState {
+        Idle,
+        Loading,
+        Canceled,
+        Completed
+    };
+    LoadingState m_loadingState = LoadingState::Idle;
 
     QUrl m_url;
     QString m_viewPropertiesContext;