┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/views
diff options
context:
space:
mode:
authorFelix Ernst <[email protected]>2022-04-24 13:18:30 +0200
committerFelix Ernst <[email protected]>2022-08-14 14:42:40 +0000
commit8e55f2c2409fd6ca9ebc66a6568f4d3bcbef7576 (patch)
treeabc2aa68ceb8f79addf0f74615e91efa08a44172 /src/views
parent402b4a5698f3d12d1848b298c38828d509abfd0d (diff)
Better separation of classes
Make obvious when actions trigger selection mode.
Diffstat (limited to 'src/views')
-rw-r--r--src/views/dolphinview.cpp2
-rw-r--r--src/views/dolphinviewactionhandler.cpp24
-rw-r--r--src/views/dolphinviewactionhandler.h11
3 files changed, 24 insertions, 13 deletions
diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp
index 56867dd13..f235efffe 100644
--- a/src/views/dolphinview.cpp
+++ b/src/views/dolphinview.cpp
@@ -286,7 +286,7 @@ DolphinView::Mode DolphinView::viewMode() const
void DolphinView::setSelectionMode(const bool enabled)
{
if (enabled) {
- m_proxyStyle = std::make_unique<SingleClickSelectionProxyStyle>();
+ m_proxyStyle = std::make_unique<SelectionMode::SingleClickSelectionProxyStyle>();
setStyle(m_proxyStyle.get());
m_view->setStyle(m_proxyStyle.get());
} else {
diff --git a/src/views/dolphinviewactionhandler.cpp b/src/views/dolphinviewactionhandler.cpp
index b2e45a5f6..ef30e91c9 100644
--- a/src/views/dolphinviewactionhandler.cpp
+++ b/src/views/dolphinviewactionhandler.cpp
@@ -10,6 +10,7 @@
#include "dolphindebug.h"
#include "kitemviews/kfileitemlisttostring.h"
#include "kitemviews/kfileitemmodel.h"
+#include "selectionmode/actiontexthelper.h"
#include "settings/viewpropertiesdialog.h"
#include "views/zoomlevelinfo.h"
#include "kconfig_version.h"
@@ -29,7 +30,7 @@
#include <QMenu>
#include <QPointer>
-DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, QObject* parent) :
+DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection, SelectionMode::ActionTextHelper* actionTextHelper, QObject* parent) :
QObject(parent),
m_actionCollection(collection),
m_currentView(nullptr),
@@ -37,7 +38,7 @@ DolphinViewActionHandler::DolphinViewActionHandler(KActionCollection* collection
m_visibleRoles()
{
Q_ASSERT(m_actionCollection);
- createActions();
+ createActions(actionTextHelper);
}
void DolphinViewActionHandler::setCurrentView(DolphinView* view)
@@ -84,7 +85,7 @@ DolphinView* DolphinViewActionHandler::currentView()
return m_currentView;
}
-void DolphinViewActionHandler::createActions()
+void DolphinViewActionHandler::createActions(SelectionMode::ActionTextHelper *actionTextHelper)
{
// This action doesn't appear in the GUI, it's for the shortcut only.
// KNewFileMenu takes care of the GUI stuff.
@@ -164,6 +165,13 @@ void DolphinViewActionHandler::createActions()
m_actionCollection->setDefaultShortcuts(copyPathAction, {Qt::CTRL | Qt::ALT | Qt::Key_C});
connect(copyPathAction, &QAction::triggered, this, &DolphinViewActionHandler::slotCopyPath);
+ if (actionTextHelper) {
+ actionTextHelper->registerTextWhenNothingIsSelected(trashAction, i18nc("@action:inmenu File", "Move to Trash…"));
+ actionTextHelper->registerTextWhenNothingIsSelected(deleteAction, i18nc("@action:inmenu File", "Delete…"));
+ actionTextHelper->registerTextWhenNothingIsSelected(duplicateAction, i18nc("@action:inmenu File", "Duplicate Here…"));
+ actionTextHelper->registerTextWhenNothingIsSelected(copyPathAction, i18nc("@action:incontextmenu", "Copy Location…"));
+ }
+
// This menu makes sure that users who don't know how to open a context menu and haven't
// figured out how to enable the menu bar can still perform basic file manipulation.
// This only works if they know how to select a file.
@@ -426,7 +434,7 @@ void DolphinViewActionHandler::slotViewModeActionTriggered(QAction* action)
void DolphinViewActionHandler::slotRename()
{
if (m_currentView->selectedItemsCount() == 0) {
- Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::RenameContents);
+ Q_EMIT setSelectionMode(true, SelectionMode::BottomBar::Contents::RenameContents);
} else {
Q_EMIT actionBeingHandled();
m_currentView->renameSelectedItems();
@@ -436,7 +444,7 @@ void DolphinViewActionHandler::slotRename()
void DolphinViewActionHandler::slotTrashActivated()
{
if (m_currentView->selectedItemsCount() == 0) {
- Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::MoveToTrashContents);
+ Q_EMIT setSelectionMode(true, SelectionMode::BottomBar::Contents::MoveToTrashContents);
} else {
Q_EMIT actionBeingHandled();
m_currentView->trashSelectedItems();
@@ -447,7 +455,7 @@ void DolphinViewActionHandler::slotTrashActivated()
void DolphinViewActionHandler::slotDeleteItems()
{
if (m_currentView->selectedItemsCount() == 0) {
- Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::DeleteContents);
+ Q_EMIT setSelectionMode(true, SelectionMode::BottomBar::Contents::DeleteContents);
} else {
Q_EMIT actionBeingHandled();
m_currentView->deleteSelectedItems();
@@ -752,7 +760,7 @@ void DolphinViewActionHandler::slotAdjustViewProperties()
void DolphinViewActionHandler::slotDuplicate()
{
if (m_currentView->selectedItemsCount() == 0) {
- Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::DuplicateContents);
+ Q_EMIT setSelectionMode(true, SelectionMode::BottomBar::Contents::DuplicateContents);
} else {
Q_EMIT actionBeingHandled();
m_currentView->duplicateSelectedItems();
@@ -780,7 +788,7 @@ void DolphinViewActionHandler::slotProperties()
void DolphinViewActionHandler::slotCopyPath()
{
if (m_currentView->selectedItemsCount() == 0) {
- Q_EMIT setSelectionMode(true, SelectionModeBottomBar::Contents::CopyLocationContents);
+ Q_EMIT setSelectionMode(true, SelectionMode::BottomBar::Contents::CopyLocationContents);
} else {
m_currentView->copyPathToClipboard();
Q_EMIT setSelectionMode(false);
diff --git a/src/views/dolphinviewactionhandler.h b/src/views/dolphinviewactionhandler.h
index f35512a5f..5c7475fdb 100644
--- a/src/views/dolphinviewactionhandler.h
+++ b/src/views/dolphinviewactionhandler.h
@@ -10,7 +10,7 @@
#define DOLPHINVIEWACTIONHANDLER_H
#include "dolphin_export.h"
-#include "selectionmode/selectionmodebottombar.h"
+#include "selectionmode/bottombar.h"
#include "views/dolphinview.h"
#include <QObject>
@@ -21,6 +21,9 @@ class QActionGroup;
class DolphinView;
class KActionCollection;
class KFileItemList;
+namespace SelectionMode {
+ class ActionTextHelper;
+}
/**
* @short Handles all actions for DolphinView
@@ -41,7 +44,7 @@ class DOLPHIN_EXPORT DolphinViewActionHandler : public QObject
Q_OBJECT
public:
- explicit DolphinViewActionHandler(KActionCollection* collection, QObject* parent);
+ explicit DolphinViewActionHandler(KActionCollection* collection, SelectionMode::ActionTextHelper* actionTextHelper, QObject* parent);
/**
* Sets the view that this action handler should work on.
@@ -85,7 +88,7 @@ Q_SIGNALS:
void createDirectoryTriggered();
/** Used to request selection mode */
- void setSelectionMode(bool enabled, SelectionModeBottomBar::Contents bottomBarContents = SelectionModeBottomBar::Contents::GeneralContents);
+ void setSelectionMode(bool enabled, SelectionMode::BottomBar::Contents bottomBarContents = SelectionMode::BottomBar::Contents::GeneralContents);
private Q_SLOTS:
/**
@@ -238,7 +241,7 @@ private:
* Create all the actions.
* This is called only once (by the constructor)
*/
- void createActions();
+ void createActions(SelectionMode::ActionTextHelper *actionTextHelper);
/**
* Creates an action-group out of all roles from KFileItemModel.