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

List:       kde-panel-devel
Subject:    Re: KColorPicker and other plasmoids
From:       Marco Martin <notmart () gmail ! com>
Date:       2008-06-20 17:17:39
Message-ID: 200806201917.39867.notmart () gmail ! com
[Download RAW message or body]

On Thursday 19 June 2008, Pino Toscano wrote:
> Hi,
>
> (please CC me for replies)
>
> > Is it ok to commit ?
>
> No, it is not ok. And the reason is *exactly* what you wrote on the review
>
> board:
> > Perhaps we have to put this line of code directly in Plasma::PushButton
> > to avoid problems with other applets ?
>
> You are solving the problem in the wrong place; fixing kolourpicker will
> *not* fix any plasmoid using Plasma::PushButton in situation like this.
>
> The fact that setMinimumSize() "is needed" to not make the buttons be drawn
> outside the applet (in case it is too small), smells like a Qt bug.
if i have an horizontal layout tall say 10 px i really must have a very tiny 
minimum size for the items in it or i won't be abe to shrink the layout more.

plasma widgets to look good almost everywhere i think they would all need to 
have a minimum size of zero and an infinite maximum size, and would put it in 
the widget. (and this different behaviour is another point because 
proxywidgets are sooo bad i think :D)
in this patch i use it in the plasma::pushbutton and it seems to work good.
the patch on kolourpicker is based on the one by Loic, i put it here just as a 
way to test the patch on pushbutton :)

cheers,
Marco Martin

>
> Oh, and am I also against the maximum 50px threshold, setting proper size
> policies should work.
>
> Furthermore, please leave back the 4px layout margin, otherwise the button
> will be too tight.



["pushbutton.diff" (text/x-diff)]

Index: pushbutton.cpp
===================================================================
--- pushbutton.cpp	(revision 822301)
+++ pushbutton.cpp	(working copy)
@@ -74,6 +74,13 @@
       d(new Private)
 {
     KPushButton* native = new KPushButton;
+    native->setMinimumSize(QSize(0,0));
+    native->setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
+    setMinimumSize(QSize(0,0));
+    setMaximumSize(QSize(QWIDGETSIZE_MAX, QWIDGETSIZE_MAX));
+    native->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+    setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+
     connect(native, SIGNAL(clicked()), this, SIGNAL(clicked()));
     setWidget(native);
     native->setAttribute(Qt::WA_NoSystemBackground);

["kolourpicker_pushbuttons.diff" (text/x-diff)]

Index: kolourpicker.h
===================================================================
--- kolourpicker.h	(revision 822323)
+++ kolourpicker.h	(working copy)
@@ -11,6 +11,7 @@
 #define KOLOURPICKER_H
 
 #include <plasma/applet.h>
+#include <plasma/widgets/pushbutton.h>
 
 #include <qcolor.h>
 #include <qhash.h>
@@ -18,8 +19,6 @@
 class QMenu;
 class QWidget;
 
-class PickerButton;
-
 class Kolourpicker : public Plasma::Applet
 {
     Q_OBJECT
@@ -47,8 +46,8 @@
         void addColor(const QColor &color, bool save = true);
         void saveData(KConfigGroup &cg);
 
-        PickerButton *m_grabButton;
-        PickerButton *m_historyButton;
+        Plasma::PushButton *m_grabButton;
+        Plasma::PushButton *m_historyButton;
         QMenu *m_historyMenu;
         QHash<QColor, QAction *> m_menus;
         QStringList m_colors;
Index: kolourpicker.cpp
===================================================================
--- kolourpicker.cpp	(revision 822323)
+++ kolourpicker.cpp	(working copy)
@@ -142,54 +142,24 @@
 }
 
 
-class PickerButton : public Plasma::PushButton
-{
-    public:
-        PickerButton(QGraphicsWidget *parent = 0);
-
-        void adaptToFormFactor(Plasma::FormFactor formFactor);
-};
-
-PickerButton::PickerButton(QGraphicsWidget *parent)
-    : Plasma::PushButton(parent)
-{
-}
-
-void PickerButton::adaptToFormFactor(Plasma::FormFactor formFactor)
-{
-    switch (formFactor)
-    {
-    case Plasma::Planar:
-    case Plasma::MediaCenter:
-        setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
-        break;
-    case Plasma::Horizontal:
-        setSizePolicy(QSizePolicy::Minimum, QSizePolicy::MinimumExpanding);
-        break;
-    case Plasma::Vertical:
-        setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum);
-        break;
-    }
-}
-
-
 Kolourpicker::Kolourpicker(QObject *parent, const QVariantList &args)
     : Plasma::Applet(parent, args), m_grabWidget(0)
 {
-    resize(40, 80);
+    resize(80, 80);
+    //setPreferredSize(60,60);
     setAspectRatioMode(Plasma::IgnoreAspectRatio);
 
     QGraphicsLinearLayout *mainlay = new QGraphicsLinearLayout(Qt::Vertical);
     setLayout(mainlay);
-    mainlay->setSpacing(4);
+    mainlay->setSpacing(0);
     mainlay->setContentsMargins(0.0, 0.0, 0.0, 0.0);
 
-    m_grabButton = new PickerButton(this);
+    m_grabButton = new Plasma::PushButton(this);
     mainlay->addItem(m_grabButton);
     m_grabButton->nativeWidget()->setIcon(KIcon("color-picker"));
     connect(m_grabButton, SIGNAL(clicked()), this, SLOT(grabClicked()));
 
-    m_historyButton = new PickerButton(this);
+    m_historyButton = new Plasma::PushButton(this);
     mainlay->addItem(m_historyButton);
     m_historyButton->setEnabled(false);
     m_historyButton->nativeWidget()->setIcon(ColorIcon(Qt::gray));
@@ -228,14 +198,14 @@
         } else {
             setBackgroundHints(Plasma::Applet::NoBackground);
         }
-        m_grabButton->adaptToFormFactor(formFactor());
-        m_historyButton->adaptToFormFactor(formFactor());
 
         QGraphicsLinearLayout *l = dynamic_cast<QGraphicsLinearLayout *>(layout());
         if (formFactor() == Plasma::Horizontal) {
             l->setOrientation(Qt::Horizontal);
-        } else {
+        } else if (formFactor() == Plasma::Vertical) {
             l->setOrientation(Qt::Vertical);
+        } else {
+            (formFactor() == Plasma::Vertical);
         }
     }
 }


_______________________________________________
Panel-devel mailing list
Panel-devel@kde.org
https://mail.kde.org/mailman/listinfo/panel-devel


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

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