Make details view mode's full row activation optional

In d383961719 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
This commit is contained in:
Felix Ernst 2022-10-19 18:03:12 +02:00 committed by Felix Ernst
parent 3590619391
commit 9478f14730
8 changed files with 45 additions and 2 deletions

View 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;

View 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;

View 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),

View file

@ -31,6 +31,10 @@
<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>

View 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()) {

View 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;

View 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();

View 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;