Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/keepassxreboot/keepassxc.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorJonathan White <support@dmapps.us>2021-02-27 00:51:03 +0300
committerJonathan White <support@dmapps.us>2021-02-27 06:10:04 +0300
commitb9ea6fd2e717ffe558c37f4a446e8a90dd9fafb4 (patch)
tree7f73b5829e06f1f74ad0f0e21614ee95e273a53c /src/gui
parent022154462e24551cb8a674ab5cc25b84599f3613 (diff)
Show sort indicators on fixed width columns
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/entry/EntryView.cpp18
-rw-r--r--src/gui/styles/base/BaseStyle.cpp35
2 files changed, 40 insertions, 13 deletions
diff --git a/src/gui/entry/EntryView.cpp b/src/gui/entry/EntryView.cpp
index 9dd021453..d6130b809 100644
--- a/src/gui/entry/EntryView.cpp
+++ b/src/gui/entry/EntryView.cpp
@@ -109,11 +109,6 @@ EntryView::EntryView(QWidget* parent)
m_columnActions->addAction(action);
}
connect(m_columnActions, SIGNAL(triggered(QAction*)), this, SLOT(toggleColumnVisibility(QAction*)));
- connect(header(), &QHeaderView::sortIndicatorChanged, [this](int index, Qt::SortOrder order) {
- Q_UNUSED(order)
- header()->setSortIndicatorShown(index != EntryModel::Paperclip && index != EntryModel::Totp
- && index != EntryModel::PasswordStrength);
- });
m_headerMenu->addSeparator();
m_headerMenu->addAction(tr("Fit to window"), this, SLOT(fitColumnsToWindow()));
@@ -121,7 +116,6 @@ EntryView::EntryView(QWidget* parent)
m_headerMenu->addSeparator();
m_headerMenu->addAction(tr("Reset to defaults"), this, SLOT(resetViewToDefaults()));
- header()->setMinimumSectionSize(24);
header()->setDefaultSectionSize(100);
header()->setStretchLastSection(false);
header()->setContextMenuPolicy(Qt::CustomContextMenu);
@@ -164,6 +158,9 @@ void EntryView::sortIndicatorChanged(int logicalIndex, Qt::SortOrder order)
emit entrySelectionChanged(currentEntry());
emit viewStateChanged();
}
+
+ header()->setSortIndicatorShown(true);
+ resetFixedColumns();
}
void EntryView::keyPressEvent(QKeyEvent* event)
@@ -421,7 +418,14 @@ void EntryView::resetFixedColumns()
for (const auto& col : {EntryModel::Paperclip, EntryModel::Totp, EntryModel::PasswordStrength}) {
if (!isColumnHidden(col)) {
header()->setSectionResizeMode(col, QHeaderView::Fixed);
- header()->resizeSection(col, ICON_ONLY_SECTION_SIZE);
+
+ // Increase column width, if sorting, to accommodate icon and arrow
+ auto width = ICON_ONLY_SECTION_SIZE;
+ if (header()->sortIndicatorSection() == col
+ && config()->get(Config::GUI_ApplicationTheme).toString() != "classic") {
+ width += 18;
+ }
+ header()->resizeSection(col, width);
}
}
}
diff --git a/src/gui/styles/base/BaseStyle.cpp b/src/gui/styles/base/BaseStyle.cpp
index e53ebf9d0..504126552 100644
--- a/src/gui/styles/base/BaseStyle.cpp
+++ b/src/gui/styles/base/BaseStyle.cpp
@@ -86,9 +86,10 @@ namespace Phantom
// These two are currently not based on font, but could be
constexpr qint16 LineEdit_ContentsHPad = 5;
constexpr qint16 ComboBox_NonEditable_ContentsHPad = 7;
- constexpr qint16 HeaderSortIndicator_HOffset = 1;
- constexpr qint16 HeaderSortIndicator_VOffset = 2;
- constexpr qint16 TabBar_InctiveVShift = 0;
+ constexpr qint16 HeaderSortIndicator_HOffset = 6;
+ constexpr qint16 HeaderSortIndicator_VOffset = 4;
+ constexpr qint16 HeaderSortIndicator_Width = 12;
+ constexpr qint16 TabBar_InactiveVShift = 0;
constexpr qreal TabBarTab_Rounding = 1.0;
constexpr qreal SpinBox_Rounding = 1.0;
@@ -3928,7 +3929,7 @@ int BaseStyle::pixelMetric(PixelMetric metric, const QStyleOption* option, const
return widget->fontMetrics().height();
}
case PM_TabBarTabShiftVertical: {
- val = Phantom::TabBar_InctiveVShift;
+ val = Phantom::TabBar_InactiveVShift;
break;
}
case PM_SubMenuOverlap:
@@ -4164,9 +4165,9 @@ QSize BaseStyle::sizeFromContents(ContentsType type,
sz.setWidth((nullIcon ? 0 : margin) + iconSize + (hdr->text.isNull() ? 0 : margin) + txt.width() + margin);
if (hdr->sortIndicator != QStyleOptionHeader::None) {
if (hdr->orientation == Qt::Horizontal)
- sz.rwidth() += sz.height() + margin;
+ sz.rwidth() += Phantom::dpiScaled(Phantom::HeaderSortIndicator_Width);
else
- sz.rheight() += sz.width() + margin;
+ sz.rheight() += Phantom::dpiScaled(Phantom::HeaderSortIndicator_Width);
}
return sz;
}
@@ -4773,6 +4774,28 @@ QRect BaseStyle::subElementRect(SubElement sr, const QStyleOption* opt, const QW
pad = Phantom::dpiScaled(pad);
return r.adjusted(pad, 0, -pad, 0);
}
+ case SE_HeaderLabel: {
+ int margin = proxy()->pixelMetric(QStyle::PM_HeaderMargin, opt, w);
+ QRect r(opt->rect.x() + margin,
+ opt->rect.y() + margin,
+ opt->rect.width() - margin * 2,
+ opt->rect.height() - margin * 2);
+ if (auto header = qstyleoption_cast<const QStyleOptionHeader*>(opt)) {
+ // Subtract width needed for arrow, if there is one
+ if (header->sortIndicator != QStyleOptionHeader::None) {
+ if (opt->state & State_Horizontal)
+ r.setWidth(r.width() - Phantom::dpiScaled(Phantom::HeaderSortIndicator_Width));
+ else
+ r.setHeight(r.height() - Phantom::dpiScaled(Phantom::HeaderSortIndicator_Width));
+ }
+ }
+ return visualRect(opt->direction, opt->rect, r);
+ }
+ case SE_HeaderArrow: {
+ QRect r = QCommonStyle::subElementRect(sr, opt, w);
+ r.setWidth(Phantom::dpiScaled(Phantom::HeaderSortIndicator_Width));
+ return r;
+ }
default:
break;
}