diff options
| author | Méven Car <[email protected]> | 2020-11-03 10:03:45 +0000 |
|---|---|---|
| committer | Méven Car <[email protected]> | 2020-11-03 10:03:45 +0000 |
| commit | c7d4c37534fd4c7107497a3bb67e8ffe96ce775c (patch) | |
| tree | c72cb2262d06cb261008630aa736b9260935aab6 /src/views/dolphinitemlistview.cpp | |
| parent | af1e13f9fa86c6a7f9bf397269559eda38e7aec6 (diff) | |
Compute text width taking into account the zoom level
This makes the icon view less crowded.
Diffstat (limited to 'src/views/dolphinitemlistview.cpp')
| -rw-r--r-- | src/views/dolphinitemlistview.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/views/dolphinitemlistview.cpp b/src/views/dolphinitemlistview.cpp index df28a0858..9fa91a674 100644 --- a/src/views/dolphinitemlistview.cpp +++ b/src/views/dolphinitemlistview.cpp @@ -17,6 +17,7 @@ #include "zoomlevelinfo.h" #include <KIO/PreviewJob> +#include <QtMath> DolphinItemListView::DolphinItemListView(QGraphicsWidget* parent) : @@ -163,11 +164,16 @@ void DolphinItemListView::updateGridSize() switch (itemLayout()) { case KFileItemListView::IconsLayout: { - const int minItemWidth = 48; - itemWidth = minItemWidth + IconsModeSettings::textWidthIndex() * 64; - if (itemWidth < iconSize + padding * 2) { - itemWidth = iconSize + padding * 2; + // an exponential factor based on zoom, 0 -> 1, 4 -> 1.36 8 -> ~1.85, 16 -> 3.4 + auto zoomFactor = qExp(m_zoomLevel / 13.0); + // 9 is the average char width for 10pt Noto Sans, making fontFactor =1 + // by each pixel the font gets larger the factor increases by 1/9 + auto fontFactor = option.fontMetrics.averageCharWidth() / 9.0; + itemWidth = 48 + IconsModeSettings::textWidthIndex() * 64 * fontFactor * zoomFactor; + + if (itemWidth < iconSize + padding * 2 * zoomFactor) { + itemWidth = iconSize + padding * 2 * zoomFactor; } itemHeight = padding * 3 + iconSize + option.fontMetrics.lineSpacing(); |
