[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 18:32:57
Message-ID: 200806202032.57915.notmart () gmail ! com
[Download RAW message or body]
On Friday 20 June 2008, Marco Martin wrote:
> 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 :)
>
well, this version it's a bit more polished :)
cheers,
Marco Martin
["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,23 @@
}
-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);
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,13 +197,11 @@
} 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);
}
}
_______________________________________________
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