]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinview.cpp
Configurable Show hidden files and folders last toggle
[dolphin.git] / src / views / dolphinview.cpp
index 987066419528eed6e5cd59c5d49c120ef5b76ec9..57ed73a3a6488ab5032599722a1fc19ac76514e6 100644 (file)
@@ -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
@@ -179,6 +185,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
     connect(m_model, &KFileItemModel::errorMessage,           this, &DolphinView::errorMessage);
     connect(m_model, &KFileItemModel::directoryRedirection, this, &DolphinView::slotDirectoryRedirection);
     connect(m_model, &KFileItemModel::urlIsFileError,            this, &DolphinView::urlIsFileError);
+    connect(m_model, &KFileItemModel::fileItemsChanged,            this, &DolphinView::fileItemsChanged);
 
     connect(this, &DolphinView::itemCountChanged,
             this, &DolphinView::updatePlaceholderLabel);
@@ -456,6 +463,18 @@ bool DolphinView::sortFoldersFirst() const
     return m_model->sortDirectoriesFirst();
 }
 
+void DolphinView::setSortHiddenLast(bool hiddenLast)
+{
+    if (sortHiddenLast() != hiddenLast) {
+        updateSortHiddenLast(hiddenLast);
+    }
+}
+
+bool DolphinView::sortHiddenLast() const
+{
+    return m_model->sortHiddenLast();
+}
+
 void DolphinView::setVisibleRoles(const QList<QByteArray>& roles)
 {
     const QList<QByteArray> previousRoles = roles;
@@ -1366,6 +1385,17 @@ void DolphinView::updateSortFoldersFirst(bool foldersFirst)
     Q_EMIT sortFoldersFirstChanged(foldersFirst);
 }
 
+void DolphinView::updateSortHiddenLast(bool hiddenLast)
+{
+    ViewProperties props(viewPropertiesUrl());
+    props.setSortHiddenLast(hiddenLast);
+
+    m_model->setSortHiddenLast(hiddenLast);
+
+    Q_EMIT sortHiddenLastChanged(hiddenLast);
+}
+
+
 QPair<bool, QString> DolphinView::pasteInfo() const
 {
     const QMimeData *mimeData = QApplication::clipboard()->mimeData();
@@ -1896,6 +1926,12 @@ void DolphinView::applyViewProperties(const ViewProperties& props)
         Q_EMIT sortFoldersFirstChanged(sortFoldersFirst);
     }
 
+    const bool sortHiddenLast = props.sortHiddenLast();
+    if (sortHiddenLast != m_model->sortHiddenLast()) {
+        m_model->setSortHiddenLast(sortHiddenLast);
+        Q_EMIT sortHiddenLastChanged(sortHiddenLast);
+    }
+
     const QList<QByteArray> visibleRoles = props.visibleRoles();
     if (visibleRoles != m_visibleRoles) {
         const QList<QByteArray> previousVisibleRoles = m_visibleRoles;
@@ -2063,10 +2099,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;
     }
 
@@ -2074,7 +2123,7 @@ void DolphinView::updatePlaceholderLabel()
         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"));
-    } else if (m_url.scheme() == QLatin1String("trash")) {
+    } else if (m_url.scheme() == QLatin1String("trash") && m_url.path() == QLatin1String("/")) {
         m_placeholderLabel->setText(i18n("Trash is empty"));
     } else if (m_url.scheme() == QLatin1String("tags")) {
         m_placeholderLabel->setText(i18n("No tags"));
@@ -2084,7 +2133,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"));