┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKai Uwe Broulik <[email protected]>2021-01-15 17:51:33 +0100
committerKai Uwe Broulik <[email protected]>2021-01-17 13:32:56 +0000
commit2e79e21c3f4da5183b516e0088f2137c4f27ceff (patch)
tree5e59eefdfbc9e470b2cd6fcff4a1081408b328c1 /src
parent6945a540046cbe5497bdd08790942ebd0d82d483 (diff)
[DolphinView] Fix "Folder is empty" label showing prematurely
Don't show the label while still loading. Since there is no property in `KDirLister` a dedicated `m_loading` is added for this purpose. Also, I removed the explicit update on `urlChanged` as the view probably won't change until the lister starts loading. BUG: 430085
Diffstat (limited to 'src')
-rw-r--r--src/views/dolphinview.cpp22
-rw-r--r--src/views/dolphinview.h7
2 files changed, 23 insertions, 6 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 5ceed9c3e..d03b75ddd 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -67,6 +67,7 @@ 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),
@@ -165,7 +166,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted);
connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted);
- connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::directoryLoadingCanceled);
+ connect(m_model, &KFileItemModel::directoryLoadingCanceled, this, &DolphinView::slotDirectoryLoadingCanceled);
connect(m_model, &KFileItemModel::directoryLoadingProgress, this, &DolphinView::directoryLoadingProgress);
connect(m_model, &KFileItemModel::directorySortingProgress, this, &DolphinView::directorySortingProgress);
connect(m_model, &KFileItemModel::itemsChanged,
@@ -179,8 +180,6 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
connect(this, &DolphinView::itemCountChanged,
this, &DolphinView::updatePlaceholderLabel);
- connect(this, &DolphinView::urlChanged,
- this, &DolphinView::updatePlaceholderLabel);
m_view->installEventFilter(this);
connect(m_view, &DolphinItemListView::sortOrderChanged,
@@ -1624,8 +1623,8 @@ void DolphinView::slotRenamingResult(KJob* job)
void DolphinView::slotDirectoryLoadingStarted()
{
- // We don't want the placeholder label to flicker while the folder is loading
- m_placeholderLabel->setVisible(false);
+ m_loading = true;
+ updatePlaceholderLabel();
// Disable the writestate temporary until it can be determined in a fast way
// in DolphinView::slotDirectoryLoadingCompleted()
@@ -1639,6 +1638,8 @@ void DolphinView::slotDirectoryLoadingStarted()
void DolphinView::slotDirectoryLoadingCompleted()
{
+ m_loading = false;
+
// Update the view-state. This has to be done asynchronously
// because the view might not be in its final state yet.
QTimer::singleShot(0, this, &DolphinView::updateViewState);
@@ -1652,6 +1653,15 @@ void DolphinView::slotDirectoryLoadingCompleted()
updateWritableState();
}
+void DolphinView::slotDirectoryLoadingCanceled()
+{
+ m_loading = false;
+
+ updatePlaceholderLabel();
+
+ Q_EMIT directoryLoadingCanceled();
+}
+
void DolphinView::slotItemsChanged()
{
m_assureVisibleCurrentIndex = false;
@@ -2016,7 +2026,7 @@ void DolphinView::slotSwipeUp()
void DolphinView::updatePlaceholderLabel()
{
- if (itemsCount() > 0) {
+ if (m_loading || itemsCount() > 0) {
m_placeholderLabel->setVisible(false);
return;
}
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index 5dd65eb54..d0285da85 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -690,6 +690,12 @@ private slots:
void slotDirectoryLoadingCompleted();
/**
+ * Invoked when the file item model indicates that the loading of a directory has
+ * been canceled.
+ */
+ void slotDirectoryLoadingCanceled();
+
+ /**
* Is invoked when items of KFileItemModel have been changed.
*/
void slotItemsChanged();
@@ -816,6 +822,7 @@ 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;
QUrl m_url;
QString m_viewPropertiesContext;