Commit ca0d0bb3 authored by Jin Liu's avatar Jin Liu Committed by Felix Ernst
Browse files

Change wording "Leading Column Padding" to "Side Padding"

Since it actually adds padding on both left and right sides,
"Side Padding" might be more accurate.

This change is also propagated to variable and method names.

BUG: 453172
parent ff0a4938
Pipeline #181010 passed with stage
in 5 minutes and 3 seconds
......@@ -349,8 +349,8 @@ as a detailed list which contains the name, size and last modification time of
each item. Additional columns can be added by clicking a column header with the
&RMB;.
</para>
<para>In the context menu of the header line, you can add or remove the padding from the
leading column by checking or unchecking the respective menu item and choose between a custom
<para>In the context menu of the header line, you can add or remove side padding
by checking or unchecking the respective menu item and choose between a custom
or automatic column width. Automatic width adjusts the width of all columns once to display the
longest item in the column completely, except for the <guilabel>Name</guilabel> column where
the extension is replaced by <quote>...</quote>
......
......@@ -434,6 +434,9 @@ install( FILES settings/dolphin_directoryviewpropertysettings.kcfg
settings/dolphin_versioncontrolsettings.kcfg
DESTINATION ${KDE_INSTALL_KCFGDIR} )
install( FILES settings/dolphin_detailsmodesettings.upd
DESTINATION ${KDE_INSTALL_KCONFUPDATEDIR} )
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
......@@ -61,9 +61,9 @@ qreal KItemListHeader::preferredColumnWidth(const QByteArray& role) const
return m_headerWidget->preferredColumnWidth(role);
}
void KItemListHeader::setLeadingPadding(qreal width){
if (m_headerWidget->leadingPadding() != width) {
m_headerWidget->setLeadingPadding(width);
void KItemListHeader::setSidePadding(qreal width){
if (m_headerWidget->sidePadding() != width) {
m_headerWidget->setSidePadding(width);
if (m_headerWidget->automaticColumnResizing()) {
m_view->applyAutomaticColumnWidths();
}
......@@ -71,8 +71,8 @@ void KItemListHeader::setLeadingPadding(qreal width){
}
}
qreal KItemListHeader::leadingPadding() const{
return m_headerWidget->leadingPadding();
qreal KItemListHeader::sidePadding() const{
return m_headerWidget->sidePadding();
}
KItemListHeader::KItemListHeader(KItemListView* listView) :
......@@ -86,7 +86,7 @@ KItemListHeader::KItemListHeader(KItemListView* listView) :
this, &KItemListHeader::columnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChangeFinished,
this, &KItemListHeader::columnWidthChangeFinished);
connect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
this, &KItemListHeader::leadingPaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
this, &KItemListHeader::sidePaddingChanged);
}
......@@ -62,11 +62,11 @@ public:
* Sets the width of the column *before* the first column.
* This is intended to facilitate an empty region for deselection in the main viewport.
*/
void setLeadingPadding(qreal width);
qreal leadingPadding() const;
void setSidePadding(qreal width);
qreal sidePadding() const;
Q_SIGNALS:
void leadingPaddingChanged(qreal width);
void sidePaddingChanged(qreal width);
/**
* Is emitted if the width of a column has been adjusted by the user with the mouse
......
......@@ -601,8 +601,8 @@ void KItemListView::setHeaderVisible(bool visible)
connect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
connect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
this, &KItemListView::slotLeadingPaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
this, &KItemListView::slotSidePaddingChanged);
connect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
connect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
......@@ -615,8 +615,8 @@ void KItemListView::setHeaderVisible(bool visible)
} else if (!visible && m_headerWidget->isVisible()) {
disconnect(m_headerWidget, &KItemListHeaderWidget::columnWidthChanged,
this, &KItemListView::slotHeaderColumnWidthChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::leadingPaddingChanged,
this, &KItemListView::slotLeadingPaddingChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::sidePaddingChanged,
this, &KItemListView::slotSidePaddingChanged);
disconnect(m_headerWidget, &KItemListHeaderWidget::columnMoved,
this, &KItemListView::slotHeaderColumnMoved);
disconnect(m_headerWidget, &KItemListHeaderWidget::sortOrderChanged,
......@@ -1532,7 +1532,7 @@ void KItemListView::slotHeaderColumnWidthChanged(const QByteArray& role,
doLayout(NoAnimation);
}
void KItemListView::slotLeadingPaddingChanged(qreal width)
void KItemListView::slotSidePaddingChanged(qreal width)
{
Q_UNUSED(width)
if (m_headerWidget->automaticColumnResizing()) {
......@@ -2313,7 +2313,7 @@ QHash<QByteArray, qreal> KItemListView::preferredColumnWidths(const KItemRangeLi
void KItemListView::applyColumnWidthsFromHeader()
{
// Apply the new size to the layouter
const qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding();
const qreal requiredWidth = columnWidthsSum() + m_headerWidget->sidePadding();
const QSizeF dynamicItemSize(qMax(size().width(), requiredWidth),
m_itemSize.height());
m_layouter->setItemSize(dynamicItemSize);
......@@ -2331,7 +2331,7 @@ void KItemListView::updateWidgetColumnWidths(KItemListWidget* widget)
for (const QByteArray& role : qAsConst(m_visibleRoles)) {
widget->setColumnWidth(role, m_headerWidget->columnWidth(role));
}
widget->setLeadingPadding(m_headerWidget->leadingPadding());
widget->setSidePadding(m_headerWidget->sidePadding());
}
void KItemListView::updatePreferredColumnWidths(const KItemRangeList& itemRanges)
......@@ -2409,8 +2409,8 @@ void KItemListView::applyAutomaticColumnWidths()
qreal firstColumnWidth = m_headerWidget->columnWidth(firstRole);
QSizeF dynamicItemSize = m_itemSize;
qreal requiredWidth = columnWidthsSum() + m_headerWidget->leadingPadding()
+ m_headerWidget->leadingPadding(); // Adding the padding a second time so we have the same padding symmetrically on both sides of the view.
qreal requiredWidth = columnWidthsSum() + m_headerWidget->sidePadding()
+ m_headerWidget->sidePadding(); // Adding the padding a second time so we have the same padding symmetrically on both sides of the view.
// This improves UX, looks better and increases the chances of users figuring out that the padding area can be used for deselecting and dropping files.
const qreal availableWidth = size().width();
if (requiredWidth < availableWidth) {
......
......@@ -430,7 +430,7 @@ private Q_SLOTS:
qreal currentWidth,
qreal previousWidth);
void slotLeadingPaddingChanged(qreal width);
void slotSidePaddingChanged(qreal width);
/**
* Is invoked if a column has been moved by the user. Applies
......
......@@ -182,14 +182,14 @@ qreal KItemListWidget::columnWidth(const QByteArray& role) const
return m_columnWidths.value(role);
}
qreal KItemListWidget::leadingPadding() const {
return m_leadingPadding;
qreal KItemListWidget::sidePadding() const {
return m_sidePadding;
}
void KItemListWidget::setLeadingPadding(qreal width) {
if (m_leadingPadding != width){
m_leadingPadding = width;
leadingPaddingChanged(width);
void KItemListWidget::setSidePadding(qreal width) {
if (m_sidePadding != width){
m_sidePadding = width;
sidePaddingChanged(width);
update();
}
}
......@@ -458,7 +458,7 @@ void KItemListWidget::columnWidthChanged(const QByteArray& role,
Q_UNUSED(previous)
}
void KItemListWidget::leadingPaddingChanged(qreal width)
void KItemListWidget::sidePaddingChanged(qreal width)
{
Q_UNUSED(width)
}
......
......@@ -82,8 +82,8 @@ public:
void setColumnWidth(const QByteArray& role, qreal width);
qreal columnWidth(const QByteArray& role) const;
void setLeadingPadding(qreal width);
qreal leadingPadding() const;
void setSidePadding(qreal width);
qreal sidePadding() const;
void setStyleOption(const KItemListStyleOption& option);
const KItemListStyleOption& styleOption() const;
......@@ -197,7 +197,7 @@ protected:
virtual void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>());
virtual void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous);
virtual void columnWidthChanged(const QByteArray& role, qreal current, qreal previous);
virtual void leadingPaddingChanged(qreal width);
virtual void sidePaddingChanged(qreal width);
virtual void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous);
virtual void currentChanged(bool current);
virtual void selectedChanged(bool selected);
......@@ -259,7 +259,7 @@ private:
QHash<QByteArray, QVariant> m_data;
QList<QByteArray> m_visibleRoles;
QHash<QByteArray, qreal> m_columnWidths;
qreal m_leadingPadding;
qreal m_sidePadding;
KItemListStyleOption m_styleOption;
QBitArray m_siblingsInfo;
......
......@@ -509,7 +509,7 @@ QRectF KStandardItemListWidget::selectionRect() const
QRectF adjustedIconRect = iconRect().adjusted(-padding, -padding, padding, padding);
QRectF result = adjustedIconRect | m_textRect;
if (m_highlightEntireRow) {
result.setRight(m_columnWidthSum + leadingPadding());
result.setRight(m_columnWidthSum + sidePadding());
}
return result;
}
......@@ -727,7 +727,7 @@ void KStandardItemListWidget::columnWidthChanged(const QByteArray& role,
m_dirtyLayout = true;
}
void KStandardItemListWidget::leadingPaddingChanged(qreal padding) {
void KStandardItemListWidget::sidePaddingChanged(qreal padding) {
Q_UNUSED(padding)
m_dirtyLayout = true;
}
......@@ -957,7 +957,7 @@ void KStandardItemListWidget::updateExpansionArea()
const qreal inc = (widgetHeight - widgetIconSize) / 2;
const qreal x = expandedParentsCount * widgetHeight + inc;
const qreal y = inc;
const qreal xPadding = m_highlightEntireRow ? leadingPadding() : 0;
const qreal xPadding = m_highlightEntireRow ? sidePadding() : 0;
m_expansionArea = QRectF(xPadding + x, y, widgetIconSize, widgetIconSize);
return;
}
......@@ -1397,7 +1397,7 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
if (m_supportsItemExpanding) {
firstColumnInc += (m_expansionArea.left() + m_expansionArea.right() + widgetHeight) / 2;
} else {
firstColumnInc += option.padding + leadingPadding();
firstColumnInc += option.padding + sidePadding();
}
qreal x = firstColumnInc;
......@@ -1413,7 +1413,7 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
const bool isTextRole = (role == "text");
if (isTextRole) {
availableTextWidth -= firstColumnInc - leadingPadding();
availableTextWidth -= firstColumnInc - sidePadding();
}
if (requiredWidth > availableTextWidth) {
......@@ -1435,7 +1435,7 @@ void KStandardItemListWidget::updateDetailsLayoutTextCache()
// The column after the name should always be aligned on the same x-position independent
// from the expansion-level shown in the name column
x -= firstColumnInc - leadingPadding();
x -= firstColumnInc - sidePadding();
} else if (isRoleRightAligned(role)) {
textInfo->pos.rx() += roleWidth - requiredWidth - columnWidthInc;
}
......
......@@ -171,7 +171,7 @@ protected:
void dataChanged(const QHash<QByteArray, QVariant>& current, const QSet<QByteArray>& roles = QSet<QByteArray>()) override;
void visibleRolesChanged(const QList<QByteArray>& current, const QList<QByteArray>& previous) override;
void columnWidthChanged(const QByteArray& role, qreal current, qreal previous) override;
void leadingPaddingChanged(qreal width) override;
void sidePaddingChanged(qreal width) override;
void styleOptionChanged(const KItemListStyleOption& current, const KItemListStyleOption& previous) override;
void hoveredChanged(bool hovered) override;
void selectedChanged(bool selected) override;
......
......@@ -18,7 +18,7 @@ KItemListHeaderWidget::KItemListHeaderWidget(QGraphicsWidget* parent) :
m_automaticColumnResizing(true),
m_model(nullptr),
m_offset(0),
m_leadingPadding(0),
m_sidePadding(0),
m_columns(),
m_columnWidths(),
m_preferredColumnWidths(),
......@@ -135,18 +135,18 @@ qreal KItemListHeaderWidget::offset() const
return m_offset;
}
void KItemListHeaderWidget::setLeadingPadding(qreal width)
void KItemListHeaderWidget::setSidePadding(qreal width)
{
if (m_leadingPadding != width) {
m_leadingPadding = width;
leadingPaddingChanged(width);
if (m_sidePadding != width) {
m_sidePadding = width;
sidePaddingChanged(width);
update();
}
}
qreal KItemListHeaderWidget::leadingPadding() const
qreal KItemListHeaderWidget::sidePadding() const
{
return m_leadingPadding;
return m_sidePadding;
}
qreal KItemListHeaderWidget::minimumColumnWidth() const
......@@ -168,7 +168,7 @@ void KItemListHeaderWidget::paint(QPainter* painter, const QStyleOptionGraphicsI
painter->setFont(font());
painter->setPen(palette().text().color());
qreal x = -m_offset + m_leadingPadding;
qreal x = -m_offset + m_sidePadding;
int orderIndex = 0;
for (const QByteArray& role : qAsConst(m_columns)) {
const qreal roleWidth = m_columnWidths.value(role);
......@@ -189,7 +189,7 @@ void KItemListHeaderWidget::mousePressEvent(QGraphicsSceneMouseEvent* event)
if (event->button() & Qt::LeftButton) {
m_pressedMousePos = event->pos();
if (isAbovePaddingGrip(m_pressedMousePos, PaddingGrip::Leading)) {
m_roleOperation = ResizeLeadingColumnOperation;
m_roleOperation = ResizePaddingColumnOperation;
} else {
updatePressedRoleIndex(event->pos());
m_roleOperation = isAboveRoleGrip(m_pressedMousePos, m_pressedRoleIndex) ?
......@@ -282,7 +282,7 @@ void KItemListHeaderWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
} else {
m_movingRole.pixmap = createRolePixmap(roleIndex);
qreal roleX = -m_offset + m_leadingPadding;
qreal roleX = -m_offset + m_sidePadding;
for (int i = 0; i < roleIndex; ++i) {
const QByteArray role = m_columns[i];
roleX += m_columnWidths.value(role);
......@@ -310,16 +310,16 @@ void KItemListHeaderWidget::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
break;
}
case ResizeLeadingColumnOperation: {
qreal currentWidth = m_leadingPadding;
case ResizePaddingColumnOperation: {
qreal currentWidth = m_sidePadding;
currentWidth += event->pos().x() - event->lastPos().x();
currentWidth = qMax(0.0, currentWidth);
m_leadingPadding = currentWidth;
m_sidePadding = currentWidth;
update();
Q_EMIT leadingPaddingChanged(currentWidth);
Q_EMIT sidePaddingChanged(currentWidth);
break;
}
......@@ -512,7 +512,7 @@ int KItemListHeaderWidget::roleIndexAt(const QPointF& pos) const
{
int index = -1;
qreal x = -m_offset + m_leadingPadding;
qreal x = -m_offset + m_sidePadding;
for (const QByteArray& role : qAsConst(m_columns)) {
++index;
x += m_columnWidths.value(role);
......@@ -526,7 +526,7 @@ int KItemListHeaderWidget::roleIndexAt(const QPointF& pos) const
bool KItemListHeaderWidget::isAboveRoleGrip(const QPointF& pos, int roleIndex) const
{
qreal x = -m_offset + m_leadingPadding;
qreal x = -m_offset + m_sidePadding;
for (int i = 0; i <= roleIndex; ++i) {
const QByteArray role = m_columns[i];
x += m_columnWidths.value(role);
......@@ -538,7 +538,7 @@ bool KItemListHeaderWidget::isAboveRoleGrip(const QPointF& pos, int roleIndex) c
bool KItemListHeaderWidget::isAbovePaddingGrip(const QPointF& pos, PaddingGrip paddingGrip) const
{
const qreal lx = -m_offset + m_leadingPadding;
const qreal lx = -m_offset + m_sidePadding;
const int grip = style()->pixelMetric(QStyle::PM_HeaderGripMargin);
switch (paddingGrip) {
......@@ -588,7 +588,7 @@ int KItemListHeaderWidget::targetOfMovingRole() const
const int movingRight = movingLeft + movingWidth - 1;
int targetIndex = 0;
qreal targetLeft = -m_offset + m_leadingPadding;
qreal targetLeft = -m_offset + m_sidePadding;
while (targetIndex < m_columns.count()) {
const QByteArray role = m_columns[targetIndex];
const qreal targetWidth = m_columnWidths.value(role);
......@@ -614,7 +614,7 @@ int KItemListHeaderWidget::targetOfMovingRole() const
qreal KItemListHeaderWidget::roleXPosition(const QByteArray& role) const
{
qreal x = -m_offset + m_leadingPadding;
qreal x = -m_offset + m_sidePadding;
for (const QByteArray& visibleRole : qAsConst(m_columns)) {
if (visibleRole == role) {
return x;
......
......@@ -50,8 +50,8 @@ public:
void setOffset(qreal offset);
qreal offset() const;
void setLeadingPadding(qreal width);
qreal leadingPadding() const;
void setSidePadding(qreal width);
qreal sidePadding() const;
qreal minimumColumnWidth() const;
......@@ -66,7 +66,7 @@ Q_SIGNALS:
qreal currentWidth,
qreal previousWidth);
void leadingPaddingChanged(qreal width);
void sidePaddingChanged(qreal width);
/**
* Is emitted if the user has released the mouse button after adjusting the
......@@ -151,14 +151,14 @@ private:
{
NoRoleOperation,
ResizeRoleOperation,
ResizeLeadingColumnOperation,
ResizePaddingColumnOperation,
MoveRoleOperation
};
bool m_automaticColumnResizing;
KItemModelBase* m_model;
qreal m_offset;
qreal m_leadingPadding;
qreal m_sidePadding;
QList<QByteArray> m_columns;
QHash<QByteArray, qreal> m_columnWidths;
QHash<QByteArray, qreal> m_preferredColumnWidths;
......
......@@ -40,8 +40,8 @@
<label>Position of columns</label>
<default>0,1,2,3,4,5,6,7,8</default>
</entry>
<entry name="LeadingPadding" type="UInt">
<label>Leading Column Padding</label>
<entry name="SidePadding" type="UInt">
<label>Side Padding</label>
<default>20</default>
</entry>
<entry name="ExpandableFolders" type="Bool">
......
#Configuration update for Dolphin
Version=5
#Rename LeadingPadding to SidePadding
Id=rename-leading-padding
File=dolphinrc
Group=DetailsMode
Key=LeadingPadding,SidePadding
\ No newline at end of file
......@@ -73,7 +73,7 @@ void DolphinItemListView::readSettings()
beginTransaction();
setEnabledSelectionToggles(GeneralSettings::showSelectionToggle());
setHighlightEntireRow(DetailsModeSettings::leadingPadding());
setHighlightEntireRow(DetailsModeSettings::sidePadding());
setSupportsItemExpanding(itemLayoutSupportsItemExpanding(itemLayout()));
updateFont();
......
......@@ -202,8 +202,8 @@ DolphinView::DolphinView(const QUrl& url, QWidget* parent) :
this, &DolphinView::slotRoleEditingCanceled);
connect(m_view->header(), &KItemListHeader::columnWidthChangeFinished,
this, &DolphinView::slotHeaderColumnWidthChangeFinished);
connect(m_view->header(), &KItemListHeader::leadingPaddingChanged,
this, &DolphinView::slotLeadingPaddingWidthChanged);
connect(m_view->header(), &KItemListHeader::sidePaddingChanged,
this, &DolphinView::slotSidePaddingWidthChanged);
KItemListSelectionManager* selectionManager = controller->selectionManager();
connect(selectionManager, &KItemListSelectionManager::selectionChanged,
......@@ -1120,9 +1120,9 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
QActionGroup* widthsGroup = new QActionGroup(menu);
const bool autoColumnWidths = props.headerColumnWidths().isEmpty();
QAction* toggleLeadingPaddingAction = menu->addAction(i18nc("@action:inmenu", "Leading Column Padding"));
toggleLeadingPaddingAction->setCheckable(true);
toggleLeadingPaddingAction->setChecked(view->header()->leadingPadding() > 0);
QAction* toggleSidePaddingAction = menu->addAction(i18nc("@action:inmenu", "Side Padding"));
toggleSidePaddingAction->setCheckable(true);
toggleSidePaddingAction->setChecked(view->header()->sidePadding() > 0);
QAction* autoAdjustWidthsAction = menu->addAction(i18nc("@action:inmenu", "Automatic Column Widths"));
autoAdjustWidthsAction->setCheckable(true);
......@@ -1154,8 +1154,8 @@ void DolphinView::slotHeaderContextMenuRequested(const QPointF& pos)
}
props.setHeaderColumnWidths(columnWidths);
header->setAutomaticColumnResizing(false);
} else if (action == toggleLeadingPaddingAction) {
header->setLeadingPadding(toggleLeadingPaddingAction->isChecked() ? 20 : 0);
} else if (action == toggleSidePaddingAction) {
header->setSidePadding(toggleSidePaddingAction->isChecked() ? 20 : 0);
} else {
// Show or hide the selected role
const QByteArray selectedRole = action->data().toByteArray();
......@@ -1208,10 +1208,10 @@ void DolphinView::slotHeaderColumnWidthChangeFinished(const QByteArray& role, qr
props.setHeaderColumnWidths(columnWidths);
}
void DolphinView::slotLeadingPaddingWidthChanged(qreal width)
void DolphinView::slotSidePaddingWidthChanged(qreal width)
{
ViewProperties props(viewPropertiesUrl());
DetailsModeSettings::setLeadingPadding(int(width));
DetailsModeSettings::setSidePadding(int(width));
m_view->writeSettings();
}
......@@ -2011,7 +2011,7 @@ void DolphinView::applyViewProperties(const ViewProperties& props)
} else {
header->setAutomaticColumnResizing(true);
}
header->setLeadingPadding(DetailsModeSettings::leadingPadding());
header->setSidePadding(DetailsModeSettings::sidePadding());
}
m_view->endTransaction();
......
......@@ -634,7 +634,7 @@ private Q_SLOTS:
void slotViewContextMenuRequested(const QPointF& pos);
void slotHeaderContextMenuRequested(const QPointF& pos);
void slotHeaderColumnWidthChangeFinished(const QByteArray& role, qreal current);
void slotLeadingPaddingWidthChanged(qreal width);
void slotSidePaddingWidthChanged(qreal width);
void slotItemHovered(int index);
void slotItemUnhovered(int index);
void slotItemDropEvent(int index, QGraphicsSceneDragDropEvent* event);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment