]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinitemlistview.cpp
Add "Sort By" to the hamburger menu
[dolphin.git] / src / views / dolphinitemlistview.cpp
index 6397a48b70e60fdc2f583fb6efd741afaac7fc38..9fa91a674c41a31ec7f624e0b91d02de1276f442 100644 (file)
@@ -1,21 +1,8 @@
-/***************************************************************************
- *   Copyright (C) 2011 by Peter Penz <peter.penz19@gmail.com>             *
- *                                                                         *
- *   This program is free software; you can redistribute it and/or modify  *
- *   it under the terms of the GNU General Public License as published by  *
- *   the Free Software Foundation; either version 2 of the License, or     *
- *   (at your option) any later version.                                   *
- *                                                                         *
- *   This program is distributed in the hope that it will be useful,       *
- *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
- *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
- *   GNU General Public License for more details.                          *
- *                                                                         *
- *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA            *
- ***************************************************************************/
+/*
+ * SPDX-FileCopyrightText: 2011 Peter Penz <peter.penz19@gmail.com>
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
 
 #include "dolphinitemlistview.h"
 
@@ -30,6 +17,7 @@
 #include "zoomlevelinfo.h"
 
 #include <KIO/PreviewJob>
+#include <QtMath>
 
 
 DolphinItemListView::DolphinItemListView(QGraphicsWidget* parent) :
@@ -91,7 +79,7 @@ void DolphinItemListView::readSettings()
 
     const KConfigGroup globalConfig(KSharedConfig::openConfig(), "PreviewSettings");
     setEnabledPlugins(globalConfig.readEntry("Plugins", KIO::PreviewJob::defaultPlugins()));
-
+    setLocalFileSizePreviewLimit(globalConfig.readEntry("MaximumSize", 0));
     endTransaction();
 }
 
@@ -176,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();