]> cloud.milkyroute.net Git - dolphin.git/commitdiff
Make details view mode's full row activation optional
authorFelix Ernst <fe.a.ernst@gmail.com>
Wed, 19 Oct 2022 16:03:12 +0000 (18:03 +0200)
committerFelix Ernst <felixernst@kde.org>
Thu, 27 Oct 2022 09:40:03 +0000 (09:40 +0000)
In d3839617193e92463806580699caa595c892b8a6 the details view mode
was changed in a way that made the full row of an item the click
target instead of only having the item's icon and text be the
representative clickable area of an item.

This commit makes this new behaviour optional through a setting
which can be changed in Dolphin's settings dialog.

The explanation for introducing yet another setting in this case is
as follows:

While the introduced change is an improvement for many typical
workflows, there are some workflows for which this new behaviour
is problematic. Quite prominently a usage of Dolphin that tries
to maximise information density is made worse by the change because
now side padding is necessary to click the view's background. While
the side padding is and was optional, disabling it made switching
the active view in split view mode more difficult among other
things. For a more complete discussion about the issues, please
check out the bug report(s) and the discussion in Dolphin's gitlab
issue with number 34.

Co-authored-by: Ivan Čukić <ivan.cukic@kde.org>
BUG: 453700
FIXED-IN: 22.12

src/kitemviews/kstandarditemlistview.cpp
src/kitemviews/kstandarditemlistview.h
src/kitemviews/kstandarditemlistwidget.cpp
src/settings/dolphin_detailsmodesettings.kcfg
src/settings/viewmodes/viewsettingstab.cpp
src/settings/viewmodes/viewsettingstab.h
src/views/dolphinitemlistview.cpp
src/views/dolphinitemlistview.h

index 4b7c2d9a42ac84224fd23d55e47aa448fa8faae9..0ba23e654d2231f510118c33935b5634bd695935 100644 (file)
@@ -36,7 +36,7 @@ void KStandardItemListView::setItemLayout(ItemLayout layout)
     m_itemLayout = layout;
 
     // keep the leading padding option unchanged here
-    setHighlightEntireRow(layout == DetailsLayout);
+    setHighlightEntireRow(itemLayoutHighlightEntireRow(layout));
     setSupportsItemExpanding(itemLayoutSupportsItemExpanding(layout));
     setScrollOrientation(layout == CompactLayout ? Qt::Horizontal : Qt::Vertical);
 
@@ -93,6 +93,11 @@ bool KStandardItemListView::itemSizeHintUpdateRequired(const QSet<QByteArray>& c
     return false;
 }
 
+bool KStandardItemListView::itemLayoutHighlightEntireRow(ItemLayout layout) const
+{
+    return layout == DetailsLayout;
+}
+
 bool KStandardItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const
 {
     return layout == DetailsLayout;
index 7f0550ec36133b399f6645394b299717bd10bc65..527d14b9d1ef332d28c5f51ff877bfe03ef23157 100644 (file)
@@ -50,6 +50,8 @@ protected:
     void initializeItemListWidget(KItemListWidget* item) override;
     bool itemSizeHintUpdateRequired(const QSet<QByteArray>& changedRoles) const override;
     virtual bool itemLayoutSupportsItemExpanding(ItemLayout layout) const;
+    /** To be overriden by sub-classes to specify when full row highlighting should be enabled. */
+    virtual bool itemLayoutHighlightEntireRow(ItemLayout layout) const;
     virtual void onItemLayoutChanged(ItemLayout current, ItemLayout previous);
     void onScrollOrientationChanged(Qt::Orientation current, Qt::Orientation previous) override;
     void onSupportsItemExpandingChanged(bool supportsExpanding) override;
index 9a2939b23d422b1a23175fca3984d470350d8310..67afbb248f7d9c26ef4e87d162227a9b01a6e74c 100644 (file)
@@ -241,6 +241,7 @@ KStandardItemListWidget::KStandardItemListWidget(KItemListWidgetInformant* infor
     m_customizedFont(),
     m_customizedFontMetrics(m_customizedFont),
     m_isExpandable(false),
+    m_highlightEntireRow(false),
     m_supportsItemExpanding(false),
     m_dirtyLayout(true),
     m_dirtyContent(true),
index a58a8d00b093a7f3ff8d6a72b1ba04fc065d36d6..aad59743c7001b249c05a5df03b95ad49bf24c3c 100644 (file)
             <label>Side Padding</label>
             <default>20</default>
         </entry>
+        <entry name="HighlightEntireRow" type="Bool">
+            <label>Highlight entire row</label>
+            <default>true</default>
+        </entry>
         <entry name="ExpandableFolders" type="Bool">
             <label>Expandable folders</label>
             <default>true</default>
index cc6818a301f2d8815b0f6df42f8d032afbbf7350..850004c6f3fd982f9c8b8ec97d95f394c5dbb9dd 100644 (file)
@@ -101,6 +101,10 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
         m_expandableFolders = new QCheckBox(i18nc("@option:check", "Expandable"));
         topLayout->addRow(i18nc("@label:checkbox", "Folders:"), m_expandableFolders);
 
+        m_highlightEntireRow = new QCheckBox(i18nc("@option:check", "Highlight entire row"));
+        topLayout->addRow(i18nc("@label:checkbox", "Selection effect:"), m_highlightEntireRow);
+
+
 #ifndef Q_OS_WIN
         // Sorting properties
         m_numberOfItems = new QRadioButton(i18nc("option:radio", "Number of items"));
@@ -161,6 +165,7 @@ ViewSettingsTab::ViewSettingsTab(Mode mode, QWidget* parent) :
         connect(m_widthBox, &QComboBox::currentIndexChanged, this, &ViewSettingsTab::changed);
         break;
     case DetailsMode:
+        connect(m_highlightEntireRow, &QCheckBox::toggled, this, &ViewSettingsTab::changed);
         connect(m_expandableFolders, &QCheckBox::toggled, this, &ViewSettingsTab::changed);
 #ifndef Q_OS_WIN
         connect(m_recursiveDirectorySizeLimit, &QSpinBox::valueChanged, this, &ViewSettingsTab::changed);
@@ -195,6 +200,22 @@ void ViewSettingsTab::applySettings()
         CompactModeSettings::setMaximumTextWidthIndex(m_widthBox->currentIndex());
         break;
     case DetailsMode:
+        // We need side-padding when the full row is a click target to still be able to not click items.
+        // So here the default padding is enabled when the full row highlight is enabled.
+        if (m_highlightEntireRow->isChecked() && !DetailsModeSettings::highlightEntireRow()) {
+            auto detailsModeSettings = DetailsModeSettings::self();
+            const bool usedDefaults = detailsModeSettings->useDefaults(true);
+            const int defaultSidePadding = detailsModeSettings->sidePadding();
+            detailsModeSettings->useDefaults(usedDefaults);
+            if (DetailsModeSettings::sidePadding() < defaultSidePadding) {
+                DetailsModeSettings::setSidePadding(defaultSidePadding);
+            }
+        } else if (!m_highlightEntireRow->isChecked() && DetailsModeSettings::highlightEntireRow()) {
+            // The full row click target is disabled so now most of the view area can be used to interact
+            // with the view background. Having an extra side padding has no usability benefit in this case.
+            DetailsModeSettings::setSidePadding(0);
+        }
+        DetailsModeSettings::setHighlightEntireRow(m_highlightEntireRow->isChecked());
         DetailsModeSettings::setExpandableFolders(m_expandableFolders->isChecked());
 #ifndef Q_OS_WIN
         DetailsModeSettings::setDirectorySizeCount(m_numberOfItems->isChecked());
@@ -238,6 +259,7 @@ void ViewSettingsTab::loadSettings()
         m_widthBox->setCurrentIndex(CompactModeSettings::maximumTextWidthIndex());
         break;
     case DetailsMode:
+        m_highlightEntireRow->setChecked(DetailsModeSettings::highlightEntireRow());
         m_expandableFolders->setChecked(DetailsModeSettings::expandableFolders());
         #ifndef Q_OS_WIN
             if (DetailsModeSettings::directorySizeCount()) {
index 36dde0583f30a9438c16669426439147a5cfd801..2cc133b524f72a5083f70170b53253dcf38d9ca9 100644 (file)
@@ -56,6 +56,7 @@ private:
     DolphinFontRequester* m_fontRequester;
     QComboBox* m_widthBox;
     QComboBox* m_maxLinesBox;
+    QCheckBox* m_highlightEntireRow;
     QCheckBox* m_expandableFolders;
     QRadioButton* m_numberOfItems;
     QRadioButton* m_sizeOfContents;
index cd6dbd0a737671a5f9411a05af80ad7491d80cd4..60d5577b83237b927dbca4b7ffd85b6e09ee702a 100644 (file)
@@ -83,7 +83,7 @@ void DolphinItemListView::readSettings()
     beginTransaction();
 
     setEnabledSelectionToggles(m_selectionTogglesEnabled);
-    setHighlightEntireRow(DetailsModeSettings::sidePadding());
+    setHighlightEntireRow(itemLayoutHighlightEntireRow(itemLayout()));
     setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout()));
 
     updateFont();
@@ -107,6 +107,11 @@ KItemListWidgetCreatorBase* DolphinItemListView::defaultWidgetCreator() const
     return new KItemListWidgetCreator<DolphinFileItemListWidget>();
 }
 
+bool DolphinItemListView::itemLayoutHighlightEntireRow(ItemLayout layout) const
+{
+    return layout == DetailsLayout && DetailsModeSettings::highlightEntireRow();
+}
+
 bool DolphinItemListView::itemLayoutSupportsItemExpanding(ItemLayout layout) const
 {
     return layout == DetailsLayout && DetailsModeSettings::expandableFolders();
index 464aec1b4c833148189e62968e382a7351f112bc..25476290f60ff2c2e39302ff9b84e12c36f5a8aa 100644 (file)
@@ -47,6 +47,9 @@ public:
 
 protected:
     KItemListWidgetCreatorBase* defaultWidgetCreator() const override;
+    /** Overwriting in the Dolphin-specific class because we want this to be user-configurable.
+     * @see KStandardItemListView::itemLayoutHighlightEntireRow */
+    bool itemLayoutHighlightEntireRow(ItemLayout layout) const override;
     bool itemLayoutSupportsItemExpanding(ItemLayout layout) const override;
     void onItemLayoutChanged(ItemLayout current, ItemLayout previous) override;
     void onPreviewsShownChanged(bool shown) override;