┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEugene Popov <[email protected]>2021-07-12 00:31:06 +0300
committerElvis Angelaccio <[email protected]>2021-07-18 16:59:47 +0000
commit7908aff3b5ebe4484d391c1fc4797e9dae2300b2 (patch)
tree0130ab165bddddf90533112d4196dde9a4008030
parentdeaf5916f2f87d78825f33f2ba11475a24c9380f (diff)
[DetailsView] Improve zooming
Under some conditions, when zooming, only the size of the icon is changed, but not the entire item, which visually doesn't look good. The main idea of this MR is that when scaling the whole element should be resized, not just the icon, so I came up with some zoom levels for the main icon sizes. With this commit, zooming will resize the entire element, even if the resizing of the icon doesn't affect the size of the entire element.
-rw-r--r--src/kitemviews/kstandarditemlistwidget.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp
index 9c527fa17..175181271 100644
--- a/src/kitemviews/kstandarditemlistwidget.cpp
+++ b/src/kitemviews/kstandarditemlistwidget.cpp
@@ -226,8 +226,22 @@ void KStandardItemListWidgetInformant::calculateCompactLayoutItemSizeHints(QVect
void KStandardItemListWidgetInformant::calculateDetailsLayoutItemSizeHints(QVector<qreal>& logicalHeightHints, qreal& logicalWidthHint, const KItemListView* view) const
{
const KItemListStyleOption& option = view->styleOption();
- const qreal height = option.padding * 2 + qMax(option.iconSize, option.fontMetrics.height());
- logicalHeightHints.fill(height);
+
+ float zoomLevel = 1;
+ if (option.iconSize >= KIconLoader::SizeEnormous) {
+ zoomLevel = 2;
+ } else if (option.iconSize >= KIconLoader::SizeHuge) {
+ zoomLevel = 1.8;
+ } else if (option.iconSize >= KIconLoader::SizeLarge) {
+ zoomLevel = 1.6;
+ } else if (option.iconSize >= KIconLoader::SizeMedium) {
+ zoomLevel = 1.4;
+ } else if (option.iconSize >= KIconLoader::SizeSmallMedium) {
+ zoomLevel = 1.2;
+ }
+
+ const qreal contentHeight = qMax<qreal>(option.iconSize, zoomLevel * option.fontMetrics.height());
+ logicalHeightHints.fill(contentHeight + 2 * option.padding);
logicalWidthHint = -1.0;
}