The Pager applet in the kde 4.3 branch doesn't work with a Panel
aligned vertically. The attached patch fixes the bug.

The code before the fix was trying to have only one calculation for
setting either the row or the column in the config dialog and then
deriving the other dimension, and  afterwards swapping the row and
column for the vertical case. The patch duplicates the calculation
instead, and so is longer. Which is the best approach? I don't know -
I think it would be possible to spend a whole morning discussing
different ways of doing this sort of thing. Maybe it shouldn't have
'row' and 'column' variables, but 'constrained_dimension' and
'derived_dimension'..

-- Richard
Index: pager.cpp
===================================================================
--- pager.cpp	(revision 1002894)
+++ pager.cpp	(working copy)
@@ -254,15 +254,17 @@
 
     int padding = 2; // Space between miniatures of desktops
     int textMargin = 3; // Space between name of desktop and border
-    int rows = qMax(qMin(m_rows, m_desktopCount), 1);
-    int columns = m_desktopCount / rows + m_desktopCount % rows;
+    int rows = 0;
+    int columns = 0;
 
     //inverse rows and columns in vertical panel
     if (formFactor() == Plasma::Vertical) {
-        int temp = rows;
-        rows = columns;
-        columns = temp;
-    }
+        columns = qMax(qMin(m_columns, m_desktopCount), 1);
+        rows = (m_desktopCount / columns) + (m_desktopCount % columns);
+    } else {
+        rows = qMax(qMin(m_rows, m_desktopCount), 1);
+        columns = (m_desktopCount / rows) + (m_desktopCount % rows);
+	}
 
     qreal leftMargin = 0;
     qreal topMargin = 0;
@@ -479,27 +481,35 @@
     // we need to keep all pager applets consistent since this affects
     // the layout of the desktops as used by the window manager,
     // so we store the row count in the applet global configuration
-    int rows = 0;
     if (formFactor() == Plasma::Vertical) {
-        rows = m_desktopCount / ui.spinRows->value() + m_desktopCount % ui.spinRows->value();
+        int columns = ui.spinRows->value();
+        m_rows = (m_desktopCount / columns) + (m_desktopCount % columns);
+        if (m_columns != columns) {
+            KConfigGroup globalcg = globalConfig();
+            m_columns = columns;
+            if (m_columns > m_desktopCount) {
+                m_columns = m_desktopCount;
+            }
+            globalcg.writeEntry("rows", m_columns);
+            changed = true;
+        }
     } else {
-        rows = ui.spinRows->value();
-    }
-
-    if (m_rows != rows) {
-        KConfigGroup globalcg = globalConfig();
-        m_rows = rows;
-        if (m_rows > m_desktopCount) {
-            m_rows = m_desktopCount;
+        int rows = ui.spinRows->value();
+        m_columns = (m_desktopCount / rows) + (m_desktopCount % rows);
+        if (m_rows != rows) {
+            KConfigGroup globalcg = globalConfig();
+            m_rows = rows;
+            if (m_rows > m_desktopCount) {
+                m_rows = m_desktopCount;
+            }
+            globalcg.writeEntry("rows", m_rows);
+            changed = true;
         }
-        globalcg.writeEntry("rows", m_rows);
-        changed = true;
     }
 
     if (changed) {
         configNeedsSaving();
         // force an update
-        m_columns = 0;
         m_size = QSizeF(-1, -1);
         recalculateGeometry();
         recalculateWindowRects();
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to