X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/480b3067d25e4b49ea55285313a7c10e93f98ffd..8b4d3624ad1be3de678cc5fcaa5a6baa43767914:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index ce77dd325..9c85303fd 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -7,7 +7,9 @@ #include "dolphinview.h" +#include "dolphin_compactmodesettings.h" #include "dolphin_detailsmodesettings.h" +#include "dolphin_iconsmodesettings.h" #include "dolphin_generalsettings.h" #include "dolphinitemlistview.h" #include "dolphinnewfilemenuobserver.h" @@ -88,7 +90,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 +129,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 @@ -1502,16 +1510,30 @@ QUrl DolphinView::openItemAsFolderUrl(const KFileItem& item, const bool browseTh void DolphinView::resetZoomLevel() { - ViewModeSettings::ViewMode mode; - + // TODO : Switch to using ViewModeSettings after MR #256 is merged + int defaultIconSize = KIconLoader::SizeSmall; switch (m_mode) { - case IconsView: mode = ViewModeSettings::IconsMode; break; - case CompactView: mode = ViewModeSettings::CompactMode; break; - case DetailsView: mode = ViewModeSettings::DetailsMode; break; + case IconsView: + IconsModeSettings::self()->useDefaults(true); + defaultIconSize = IconsModeSettings::iconSize(); + IconsModeSettings::self()->useDefaults(false); + break; + case DetailsView: + DetailsModeSettings::self()->useDefaults(true); + defaultIconSize = DetailsModeSettings::iconSize(); + DetailsModeSettings::self()->useDefaults(false); + break; + case CompactView: + CompactModeSettings::self()->useDefaults(true); + defaultIconSize = CompactModeSettings::iconSize(); + CompactModeSettings::self()->useDefaults(false); + break; + default: + Q_ASSERT(false); + break; } - const ViewModeSettings settings(mode); - const QSize iconSize = QSize(settings.iconSize(), settings.iconSize()); - setZoomLevel(ZoomLevelInfo::zoomLevelForIconSize(iconSize)); + + setZoomLevel(ZoomLevelInfo::zoomLevelForIconSize(QSize(defaultIconSize, defaultIconSize))); } void DolphinView::observeCreatedItem(const QUrl& url) @@ -2064,10 +2086,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; } @@ -2075,7 +2110,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")); @@ -2085,7 +2120,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"));