X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/blobdiff_plain/45af4bc0e09ebacca4d7f8177dd5dc0a5fd109cd..3b7c05b385dc56fbc0b9ffdd332f8d30e7624d0c:/src/views/dolphinviewactionhandler.cpp diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp index c02d7856b..a66d1f6dd 100644 --- a/src/views/dolphinviewactionhandler.cpp +++ b/src/views/dolphinviewactionhandler.cpp @@ -14,7 +14,7 @@ #include "views/zoomlevelinfo.h" #include "kconfig_version.h" -#ifdef HAVE_BALOO +#if HAVE_BALOO #include #endif #include @@ -29,6 +29,8 @@ #include #include +#include + DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) : QObject(parent), m_actionCollection(collection), @@ -72,6 +74,8 @@ void DolphinViewActionHandler::setCurrentView(DolphinView* view) this, &DolphinViewActionHandler::slotZoomLevelChanged); connect(view, &DolphinView::writeStateChanged, this, &DolphinViewActionHandler::slotWriteStateChanged); + connect(view, &DolphinView::selectionModeRequested, + this, [this]() { Q_EMIT setSelectionMode(true); }); connect(view, &DolphinView::selectionChanged, this, &DolphinViewActionHandler::slotSelectionChanged); slotSelectionChanged(m_currentView->selectedItems()); @@ -355,7 +359,7 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt QActionGroup* groupMenuGroup = nullptr; bool indexingEnabled = false; -#ifdef HAVE_BALOO +#if HAVE_BALOO Baloo::IndexerConfig config; indexingEnabled = config.fileIndexingEnabled(); #endif @@ -415,7 +419,7 @@ QActionGroup* DolphinViewActionHandler::createFileItemRolesActionGroup(const QSt void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action) { const DolphinView::Mode mode = action->data().value(); - m_currentView->setMode(mode); + m_currentView->setViewMode(mode); QAction* viewModeMenu = m_actionCollection->action(QStringLiteral("view_mode")); viewModeMenu->setIcon(action->icon()); @@ -423,20 +427,34 @@ void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action) void DolphinViewActionHandler::slotRename() { - Q_EMIT actionBeingHandled(); - m_currentView->renameSelectedItems(); + if (m_currentView->selectedItemsCount() == 0) { + Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::RenameContents); + } else { + Q_EMIT actionBeingHandled(); + m_currentView->renameSelectedItems(); + } } void DolphinViewActionHandler::slotTrashActivated() { - Q_EMIT actionBeingHandled(); - m_currentView->trashSelectedItems(); + if (m_currentView->selectedItemsCount() == 0) { + Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::MoveToTrashContents); + } else { + Q_EMIT actionBeingHandled(); + m_currentView->trashSelectedItems(); + Q_EMIT setSelectionMode(false); + } } void DolphinViewActionHandler::slotDeleteItems() { - Q_EMIT actionBeingHandled(); - m_currentView->deleteSelectedItems(); + if (m_currentView->selectedItemsCount() == 0) { + Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::DeleteContents); + } else { + Q_EMIT actionBeingHandled(); + m_currentView->deleteSelectedItems(); + Q_EMIT setSelectionMode(false); + } } void DolphinViewActionHandler::togglePreview(bool show) @@ -455,7 +473,7 @@ void DolphinViewActionHandler::slotPreviewsShownChanged(bool shown) QString DolphinViewActionHandler::currentViewModeActionName() const { - switch (m_currentView->mode()) { + switch (m_currentView->viewMode()) { case DolphinView::IconsView: return QStringLiteral("icons"); case DolphinView::DetailsView: @@ -664,7 +682,7 @@ void DolphinViewActionHandler::slotSortRoleChanged(const QByteArray& role) QAction* descending = m_actionCollection->action(QStringLiteral("descending")); QAction* ascending = m_actionCollection->action(QStringLiteral("ascending")); - if (role == "text" || role == "type" || role == "tags" || role == "comment") { + if (role == "text" || role == "type" || role == "extension" || role == "tags" || role == "comment") { descending->setText(i18nc("Sort descending", "Z-A")); ascending->setText(i18nc("Sort ascending", "A-Z")); } else if (role == "size") { @@ -735,8 +753,13 @@ void DolphinViewActionHandler::slotAdjustViewProperties() void DolphinViewActionHandler::slotDuplicate() { - Q_EMIT actionBeingHandled(); - m_currentView->duplicateSelectedItems(); + if (m_currentView->selectedItemsCount() == 0) { + Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::DuplicateContents); + } else { + Q_EMIT actionBeingHandled(); + m_currentView->duplicateSelectedItems(); + Q_EMIT setSelectionMode(false); + } } void DolphinViewActionHandler::slotProperties() @@ -758,7 +781,12 @@ void DolphinViewActionHandler::slotProperties() void DolphinViewActionHandler::slotCopyPath() { - m_currentView->copyPathToClipboard(); + if (m_currentView->selectedItemsCount() == 0) { + Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::CopyLocationContents); + } else { + m_currentView->copyPathToClipboard(); + Q_EMIT setSelectionMode(false); + } } void DolphinViewActionHandler::slotSelectionChanged(const KFileItemList& selection)