]> cloud.milkyroute.net Git - dolphin.git/blobdiff - src/views/dolphinitemlistcontainer.cpp
Don't show tooltips when dragging to another Dolphin window
[dolphin.git] / src / views / dolphinitemlistcontainer.cpp
index c687ede4d4a4702393ee542bcc483800806c2547..ec1af9549a68b901df7e46801a08cf1975076697 100644 (file)
@@ -206,30 +206,46 @@ void DolphinItemListContainer::updateGridSize()
     m_zoomLevel = ZoomLevelInfo::zoomLevelForIconSize(QSize(iconSize, iconSize));
     KItemListStyleOption styleOption = m_fileItemListView->styleOption();
 
-    const int innerMargin = (iconSize >= KIconLoader::SizeSmallMedium) ? 4 : 2;
+    const int padding = 2;
+    int horizontalMargin = 0;
+    int verticalMargin = 0;
 
     // Calculate the item-width and item-height
     int itemWidth;
     int itemHeight;
     switch (itemLayout()) {
     case KFileItemListView::IconsLayout: {
-        const int minItemWidth = 64;
+        const int minItemWidth = 48;
         itemWidth = minItemWidth + IconsModeSettings::textWidthIndex() * 64;
-        if (itemWidth < iconSize + innerMargin * 2) {
-            itemWidth = iconSize + innerMargin * 2;
+        
+        if (previewsShown()) {
+            // Optimize the width for previews with a 3:2 aspect ratio instead
+            // of a 1:1 ratio to avoid wasting too much vertical space when
+            // photos.
+            const int minWidth = iconSize * 3 / 2;
+            itemWidth = qMax(itemWidth, minWidth);
         }
-        itemHeight = innerMargin * 2 + iconSize + styleOption.fontMetrics.height();
+        
+        if (itemWidth < iconSize + padding * 2) {
+            itemWidth = iconSize + padding * 2;
+        }
+        itemHeight = padding * 3 + iconSize + styleOption.fontMetrics.height();
+        
+        horizontalMargin = 4;
+        verticalMargin = 8;
         break;
     }
     case KFileItemListView::CompactLayout: {
-        itemWidth = innerMargin * 4 + iconSize + styleOption.fontMetrics.height() * 5;
+        itemWidth = padding * 4 + iconSize + styleOption.fontMetrics.height() * 5;
         const int textLinesCount = m_fileItemListView->visibleRoles().count();
-        itemHeight = innerMargin * 2 + qMax(iconSize, textLinesCount * styleOption.fontMetrics.height());
+        itemHeight = padding * 2 + qMax(iconSize, textLinesCount * styleOption.fontMetrics.height());
+        
+        horizontalMargin = 8;
         break;
     }
     case KFileItemListView::DetailsLayout: {
         itemWidth = -1;
-        itemHeight = innerMargin * 2 + qMax(iconSize, styleOption.fontMetrics.height());
+        itemHeight = padding * 2 + qMax(iconSize, styleOption.fontMetrics.height());
         break;
     }
     default:
@@ -240,10 +256,14 @@ void DolphinItemListContainer::updateGridSize()
     }
 
     // Apply the calculated values
-    styleOption.margin = innerMargin;
+    styleOption.padding = padding;
+    styleOption.horizontalMargin = horizontalMargin;
+    styleOption.verticalMargin = verticalMargin;
     styleOption.iconSize = iconSize;
+    m_fileItemListView->beginTransaction();
     m_fileItemListView->setStyleOption(styleOption);
     m_fileItemListView->setItemSize(QSizeF(itemWidth, itemHeight));
+    m_fileItemListView->endTransaction();
 }
 
 void DolphinItemListContainer::updateFont()