[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-panel-devel
Subject:    Re: understanding minimum/maximum/preferredSize in plasma context
From:       Marcos Dione <mdione () grulic ! org ! ar>
Date:       2008-12-27 20:19:20
Message-ID: 20081227201829.GA7785 () mustang ! grulicueva ! net
[Download RAW message or body]

On Fri, Dec 26, 2008 at 11:31:22PM -0700, Aaron J. Seigo wrote:
> On Friday 26 December 2008, Marcos Dione wrote:
> >     hi all. I'm set to get the panel spacer to its previous behaviour
> > when set to auto stretch, that is, to use as much space as possible.
> 
> this applet is the right code in the wrong place. the panel ought to have an 
> expander in its layout by default; the item should not be an applet at all 
> imho but an item in the panel containment itself.

    I think that leaving it as an applet makes it similar to toolbar
editing, where you add separtors (maybe a name change?). it's not clear
for me how would one add a separator to a panel otherwise (i.e., how the
feature should work)...

> >     with this code and in my config the spacer takes some 130px, while
> > the systray takes 490px having only 190px of icons inside, and the 3
> > digital clocks arte wider that needed[2]. if I turn off that auto
> > stretching, it goes down to the original 16px, but if I use the slider
> > to effectively increase the minSize, it goes up to 710px.
> 
> this is probably because all these applets stretch to whatever the max size is 
> if there is nothing else there. try checking their preferredSize()s

    actually that's the plasma Applet's default. in
flushPendingConstrainstEvents(), except for square aspect ratios, it
doesn't set the sizePolicy. setting it to Preferred makes it expand when
no auto expanding spacer is present (original behaviour) and to use as
few space as possible when one ins present (my intended behaviour).
while I was at this, I found some duped code, so I compacted it. 

    here are a couple of patches, one against kdelibs/plasma and the
other for playground/base. what's insteresting about the last one is
that as the policy is always the same, I tried to set it in the
constructor, but it gave a wrong behaviour. I had to move it back to
constrainsEvent().

> if you read the code, you'll see that that's not the case.

    yeah, I should have. it was rather late in the night then...

-- 
(Not so) Random fortune:
- The human psyche is an odd and contradictory thing, isn't it Bob...
- Well... being a lawyer, I pretty much bunk on it.
	    -- http://www.ucomics.com/nonsequitur/viewnq.htm

["panel_spacer-set_size_policy.diff" (text/x-diff)]

Index: playground/base/plasma/applets/panelspacer/panelspacer.cpp
===================================================================
--- playground/base/plasma/applets/panelspacer/panelspacer.cpp	(revision 901975)
+++ playground/base/plasma/applets/panelspacer/panelspacer.cpp	(working copy)
@@ -56,6 +56,7 @@
         m_separatorElementId=cg.readEntry("separatorElementId", "1");
         initSvgSeparator(m_separatorElementId);
     }
+    // setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
 }
 
  void PanelSpacer::initSvgSeparator(const QString &separatorId)
@@ -162,8 +163,9 @@
             // Final size
             m_separatorRect.setRect(0, seppos, contentSize.width(), m_separatorWidth);
         }
-        calculateBlankSpace();
-     }
+    }
+    setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+    calculateBlankSpace();
 }
 
 void PanelSpacer::paintInterface(QPainter *p,

["plasma_applet-set_size-policy.diff" (text/x-diff)]

Index: kdelibs/plasma/applet.cpp
===================================================================
--- kdelibs/plasma/applet.cpp	(revision 901975)
+++ kdelibs/plasma/applet.cpp	(working copy)
@@ -947,27 +947,22 @@
             }
         }
     }
-
     if (c & Plasma::SizeConstraint || c & Plasma::FormFactorConstraint) {
-        if (aspectRatioMode() == Plasma::Square) {
+        if (aspectRatioMode() == Plasma::Square || aspectRatioMode() == Plasma::ConstrainedSquare) {
             // enforce square size in panels
             if (formFactor() == Horizontal) {
                 setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
             } else if (formFactor() == Vertical) {
                 setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
             }
-
-            updateGeometry();
-        } else if (aspectRatioMode() == Plasma::ConstrainedSquare) {
-            // enforce a constrained square size in panels
+        } else {
             if (formFactor() == Horizontal) {
-                setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
+                setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
             } else if (formFactor() == Vertical) {
-                setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+                setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred));
             }
-
-            updateGeometry();
         }
+        updateGeometry();
     }
 
     // now take care of constraints in special subclasses: Contaiment and PopupApplet


_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic