X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/fc2d181291fbbb76e4f62fdb1b9bb51a9f4d05dc..f0749ee42ccb2e0a7caee165b9934de8e61bfcbc:/src/views/dolphinview.cpp diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 4f5b0e83a..0e97b8561 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -25,7 +25,7 @@ #include "views/tooltips/tooltipmanager.h" #include "zoomlevelinfo.h" -#ifdef HAVE_BALOO +#if HAVE_BALOO #include #endif #include @@ -45,6 +45,7 @@ #include #include #include +#include #include #include @@ -70,7 +71,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), @@ -209,7 +209,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) : connect(selectionManager, &KItemListSelectionManager::selectionChanged, this, &DolphinView::slotSelectionChanged); -#ifdef HAVE_BALOO +#if HAVE_BALOO m_toolTipManager = new ToolTipManager(this); connect(m_toolTipManager, &ToolTipManager::urlActivated, this, &DolphinView::urlActivated); #endif @@ -758,12 +758,14 @@ void DolphinView::cutSelectedItemsToClipboard() { QMimeData* mimeData = selectionMimeData(); KIO::setClipboardDataCut(mimeData, true); + KUrlMimeData::exportUrlsToPortal(mimeData); QApplication::clipboard()->setMimeData(mimeData); } void DolphinView::copySelectedItemsToClipboard() { - QMimeData* mimeData = selectionMimeData(); + QMimeData *mimeData = selectionMimeData(); + KUrlMimeData::exportUrlsToPortal(mimeData); QApplication::clipboard()->setMimeData(mimeData); } @@ -925,7 +927,7 @@ bool DolphinView::eventFilter(QObject* watched, QEvent* event) break; case QEvent::ToolTip: - tryShowNameToolTip(event); + tryShowNameToolTip(static_cast(event)); default: break; @@ -993,7 +995,10 @@ void DolphinView::slotItemsActivated(const KItemSet &indexes) if (indexes.count() > 5) { QString question = i18np("Are you sure you want to open 1 item?", "Are you sure you want to open %1 items?", indexes.count()); - const int answer = KMessageBox::warningYesNo(this, question); + const int answer = KMessageBox::warningYesNo(this, question, {}, + KGuiItem(i18ncp("@action:button", "Open %1 Item", "Open %1 Items", indexes.count()), + QStringLiteral("document-open")), + KStandardGuiItem::cancel()); if (answer != KMessageBox::Yes) { return; } @@ -1076,7 +1081,7 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos) const QList visibleRolesSet = view->visibleRoles(); bool indexingEnabled = false; -#ifdef HAVE_BALOO +#if HAVE_BALOO Baloo::IndexerConfig config; indexingEnabled = config.fileIndexingEnabled(); #endif @@ -1224,7 +1229,7 @@ void DolphinView::slotItemHovered(int index) const QPoint pos = m_container->mapToGlobal(itemRect.topLeft().toPoint()); itemRect.moveTo(pos); -#ifdef HAVE_BALOO +#if HAVE_BALOO auto nativeParent = nativeParentWidget(); if (nativeParent) { m_toolTipManager->showToolTip(item, itemRect, nativeParent->windowHandle()); @@ -1666,7 +1671,7 @@ void DolphinView::updateViewState() void DolphinView::hideToolTip(const ToolTipManager::HideBehavior behavior) { if (GeneralSettings::showToolTips()) { -#ifdef HAVE_BALOO +#if HAVE_BALOO m_toolTipManager->hideToolTip(behavior); #else Q_UNUSED(behavior) @@ -1728,7 +1733,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 +1748,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 +1765,7 @@ void DolphinView::slotDirectoryLoadingCompleted() void DolphinView::slotDirectoryLoadingCanceled() { - m_loading = false; + m_loadingState = LoadingState::Canceled; updatePlaceholderLabel(); @@ -2159,13 +2164,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")); @@ -2196,11 +2203,10 @@ void DolphinView::updatePlaceholderLabel() m_placeholderLabel->setVisible(true); } -void DolphinView::tryShowNameToolTip(QEvent* event) +void DolphinView::tryShowNameToolTip(QHelpEvent* event) { if (!GeneralSettings::showToolTips() && m_mode == DolphinView::IconsView) { - QHelpEvent *hoverEvent = reinterpret_cast(event); - const std::optional index = m_view->itemAt(hoverEvent->pos()); + const std::optional index = m_view->itemAt(event->pos()); if (!index.has_value()) { return; @@ -2212,7 +2218,7 @@ void DolphinView::tryShowNameToolTip(QEvent* event) if(isElided) { const KFileItem item = m_model->fileItem(index.value()); const QString text = item.text(); - const QPoint pos = mapToGlobal(hoverEvent->pos()); + const QPoint pos = mapToGlobal(event->pos()); QToolTip::showText(pos, text); } }