From 3b7c05b385dc56fbc0b9ffdd332f8d30e7624d0c Mon Sep 17 00:00:00 2001 From: Felix Ernst Date: Sun, 12 Sep 2021 15:33:39 +0200 Subject: Add Selection Mode The selection mode action is a checkable toggle action named "Select Files and Folders" which has "Space" as the default shortcut. In selection mode a bottom bar with contextual actions is shown. These should mostly mirror the actions which are available through the right-click context menu aka DolphinContextMenu. Resizing of the window might make a overflow button appear in the bottom selection mode bar. This commit makes press and hold in the view activate selection mode. This behaviour is not triggered if the press and hold is used to either start a rubberband selection or a drag operation within a short time. The length of the short timeframe is defined by a QStyleHint. This is currently not implemented in touch because I can't test it. Mix the selection mode bars' background colors using a nice combination of colors from the current color scheme BUG: 427202 --- src/views/dolphinview.cpp | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) (limited to 'src/views/dolphinview.cpp') diff --git a/src/views/dolphinview.cpp b/src/views/dolphinview.cpp index 0e97b8561..56867dd13 100644 --- a/src/views/dolphinview.cpp +++ b/src/views/dolphinview.cpp @@ -20,6 +20,7 @@ #include "kitemviews/kitemlistselectionmanager.h" #include "kitemviews/private/kitemlistroleeditor.h" #include "settings/viewmodes/viewmodesettings.h" +#include "selectionmode/singleclickselectionproxystyle.h" #include "versioncontrol/versioncontrolobserver.h" #include "viewproperties.h" #include "views/tooltips/tooltipmanager.h" @@ -172,6 +173,7 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) : connect(controller, &KItemListController::increaseZoom, this, &DolphinView::slotIncreaseZoom); connect(controller, &KItemListController::decreaseZoom, this, &DolphinView::slotDecreaseZoom); connect(controller, &KItemListController::swipeUp, this, &DolphinView::slotSwipeUp); + connect(controller, &KItemListController::selectionModeRequested, this, &DolphinView::selectionModeRequested); connect(m_model, &KFileItemModel::directoryLoadingStarted, this, &DolphinView::slotDirectoryLoadingStarted); connect(m_model, &KFileItemModel::directoryLoadingCompleted, this, &DolphinView::slotDirectoryLoadingCompleted); @@ -262,7 +264,7 @@ bool DolphinView::isActive() const return m_active; } -void DolphinView::setMode(Mode mode) +void DolphinView::setViewMode(Mode mode) { if (mode != m_mode) { ViewProperties props(viewPropertiesUrl()); @@ -276,11 +278,30 @@ void DolphinView::setMode(Mode mode) } } -DolphinView::Mode DolphinView::mode() const +DolphinView::Mode DolphinView::viewMode() const { return m_mode; } +void DolphinView::setSelectionMode(const bool enabled) +{ + if (enabled) { + m_proxyStyle = std::make_unique(); + setStyle(m_proxyStyle.get()); + m_view->setStyle(m_proxyStyle.get()); + } else { + setStyle(QApplication::style()); + m_view->setStyle(QApplication::style()); + } + m_container->controller()->setSelectionMode(enabled); +} + +bool DolphinView::selectionMode() const +{ + return m_container->controller()->selectionMode(); +} + + void DolphinView::setPreviewsShown(bool show) { if (previewsShown() == show) { -- cgit v1.3