┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMufeed Ali <[email protected]>2021-06-29 13:52:57 +0000
committerNate Graham <[email protected]>2021-06-29 13:52:57 +0000
commit152a7b4fcbc06ab536083abe0a7f63c1722960fb (patch)
tree58b1d94be9c491c932dd069dc3198b2cf7d38476 /src
parenta3559a19db218e2a320fd81634d14e7cf891662e (diff)
Show a "Loading..." placeholder text
Since a placeholder text is being used when the folder is empty, it also makes sense to show a similar placeholder text when the view is still loading, especially now that the status bar which previously contained a loading indicator now disappears when a folder is loading.
Diffstat (limited to 'src')
-rw-r--r--src/views/dolphinview.cpp25
-rw-r--r--src/views/dolphinview.h2
2 files changed, 24 insertions, 3 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index ce77dd325..9d253c4e0 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -88,7 +88,8 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
m_markFirstNewlySelectedItemAsCurrent(false),
m_versionControlObserver(nullptr),
m_twoClicksRenamingTimer(nullptr),
- m_placeholderLabel(nullptr)
+ m_placeholderLabel(nullptr),
+ m_showLoadingPlaceholderTimer(nullptr)
{
m_topLayout = new QVBoxLayout(this);
m_topLayout->setSpacing(0);
@@ -126,6 +127,11 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
connect(m_container->horizontalScrollBar(), &QScrollBar::valueChanged, this, [=] { hideToolTip(); });
connect(m_container->verticalScrollBar(), &QScrollBar::valueChanged, this, [=] { hideToolTip(); });
+ m_showLoadingPlaceholderTimer = new QTimer(this);
+ m_showLoadingPlaceholderTimer->setInterval(500);
+ m_showLoadingPlaceholderTimer->setSingleShot(true);
+ connect(m_showLoadingPlaceholderTimer, &QTimer::timeout, this, &DolphinView::showLoadingPlaceholder);
+
// Show some placeholder text for empty folders
// This is made using a heavily-modified QLabel rather than a KTitleWidget
// because KTitleWidget can't be told to turn off mouse-selectable text
@@ -2064,10 +2070,23 @@ void DolphinView::slotSwipeUp()
Q_EMIT goUpRequested();
}
+void DolphinView::showLoadingPlaceholder()
+{
+ m_placeholderLabel->setText(i18n("Loading..."));
+ m_placeholderLabel->setVisible(true);
+}
+
void DolphinView::updatePlaceholderLabel()
{
- if (m_loading || itemsCount() > 0) {
+ m_showLoadingPlaceholderTimer->stop();
+ if (itemsCount() > 0) {
+ m_placeholderLabel->setVisible(false);
+ return;
+ }
+
+ if (m_loading) {
m_placeholderLabel->setVisible(false);
+ m_showLoadingPlaceholderTimer->start();
return;
}
@@ -2085,7 +2104,7 @@ void DolphinView::updatePlaceholderLabel()
m_placeholderLabel->setText(i18n("No shared folders found"));
} else if (m_url.scheme() == QLatin1String("network")) {
m_placeholderLabel->setText(i18n("No relevant network resources found"));
- } else if (m_url.scheme() == QLatin1String("mtp")) {
+ } else if (m_url.scheme() == QLatin1String("mtp") && m_url.path() == QLatin1String("/")) {
m_placeholderLabel->setText(i18n("No MTP-compatible devices found"));
} else if (m_url.scheme() == QLatin1String("bluetooth")) {
m_placeholderLabel->setText(i18n("No Bluetooth devices found"));
diff --git a/src/views/dolphinview.h b/src/views/dolphinview.h
index bb093774f..e4d779830 100644
--- a/src/views/dolphinview.h
+++ b/src/views/dolphinview.h
@@ -839,6 +839,7 @@ private:
private:
void updatePalette();
+ void showLoadingPlaceholder();
bool m_active;
bool m_tabsForFiles;
@@ -878,6 +879,7 @@ private:
QTimer* m_twoClicksRenamingTimer;
QUrl m_twoClicksRenamingItemUrl;
QLabel* m_placeholderLabel;
+ QTimer* m_showLoadingPlaceholderTimer;
// For unit tests
friend class TestBase;