diff options
| author | Felix Ernst <[email protected]> | 2021-09-12 15:33:39 +0200 |
|---|---|---|
| committer | Felix Ernst <[email protected]> | 2022-08-14 14:42:40 +0000 |
| commit | 3b7c05b385dc56fbc0b9ffdd332f8d30e7624d0c (patch) | |
| tree | a54c8338e3dc7d420fd2223bbcfb5af0a186348e /src/views/dolphinview.cpp | |
| parent | 9dbe48137748c6197363236b67f6302e20b72167 (diff) | |
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
Diffstat (limited to 'src/views/dolphinview.cpp')
| -rw-r--r-- | src/views/dolphinview.cpp | 25 |
1 files changed, 23 insertions, 2 deletions
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<SingleClickSelectionProxyStyle>(); + 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) { |
