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

List:       kde-panel-devel
Subject:    Re: [Panel-devel] [PATCH] Smaller toolbox with icons
From:       "Craig Duquette" <cduquette () gmail ! com>
Date:       2007-12-31 19:52:02
Message-ID: f5fcb8a90712311152s1f763997o869faeeced0e2e5d () mail ! gmail ! com
[Download RAW message or body]

Well I included it because I was getting a 1px icon instead of the
actual image by not using setMinimum, not sure if it's a bug with
Plasma::Icon, but the way I see it's better to limit the icon from
being a size other than we intended :).

Here's my latest patch that plays with the gradient. And some screenshot love :D

Closed: http://img185.imageshack.us/my.php?image=tool1uj5.png
Expanded: http://img185.imageshack.us/my.php?image=tool2rr7.png

And this is my current desktop shot of kde4.
http://home.cfl.rr.com/gamma/images/ss.png

Great work Oxygen folks! :D

On 12/28/07, Alex Merry <alexander.merry@ccc.ox.ac.uk> wrote:
> On Fri, Dec 28, 2007 at 05:32:23PM +0900, Jason Stubbs wrote:
> > One tiny nit-picky thing so no need to repost a patch, but:
> >
> > +    tool->setMinimumSize(iconSize);
> > +    tool->setMaximumSize(iconSize);
> > +    tool->resize(tool->sizeHint());
> >
> > Is there any reason to not use iconSize rather than tool->sizeHint() ? I'm
> > guessing that it returns the same value anyway, but looks out of place and
> > begs the eternal question "why is it so?" ;)
>
> Actually, tool->sizeHint() for Plasma::Icon returns the last value
> passed to tool->resize().  My approach was to do
> tool->resize(tool->sizeFromIconSize(iconSize));
>
> That should work as a replacement for the above three lines.  I think
> setMinimumSize and setMaximumSize can be discarded, as there's no
> layouts doing anything.
>
> Alex
>
> --
> KDE: http://www.kde.org
> OpenSUSE: http://www.opensuse.org
>

["icons-123007.patch" (text/x-patch)]

Index: desktoptoolbox.cpp
===================================================================
--- desktoptoolbox.cpp	(revision 754756)
+++ desktoptoolbox.cpp	(working copy)
@@ -35,7 +35,7 @@
 
 DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
     : QGraphicsItem(parent),
-      m_icon("configure"),
+      m_icon("plasma"),
       m_size(50),
       m_showing(false),
       m_animId(0),
@@ -67,8 +67,9 @@
     QPainterPath p = shape();
     QRadialGradient gradient(QPoint(m_size*2, 0), m_size*3);
     gradient.setFocalPoint(QPointF(m_size*2, 0));
-    gradient.setColorAt(0, QColor(255, 255, 255, 128));
-    gradient.setColorAt(.9, QColor(128, 128, 128, 128));
+    gradient.setColorAt(0, QColor(255, 255, 255, 96));
+    gradient.setColorAt(.33, QColor(128, 128, 128, 96));
+    gradient.setColorAt(.66, QColor(128, 128, 128, 0));
     painter->save();
     painter->setPen(Qt::NoPen);
     painter->setRenderHint(QPainter::Antialiasing, true);
Index: containment.h
===================================================================
--- containment.h	(revision 754756)
+++ containment.h	(working copy)
@@ -30,6 +30,8 @@
 #include <plasma/applet.h>
 #include <plasma/phase.h>
 
+#include "widgets/icon.h"
+
 namespace Plasma
 {
 
@@ -214,9 +216,15 @@
         void emitLaunchActivated();
 
         /**
-         * Adds an item to the toolbox. The toolbox takes over ownership of the \
item. +         * Constructs a toolbox item and adds it to the toolbox. The toolbox \
takes over ownership of the item. Returns the constructed tool. +         * 
+         * @arg name of the tool
+         * @arg name of the icon
+         * @arg text to be displayed on the icon
+         *
+         * @return the constructed tool
          */
-        void addToolBoxTool(QGraphicsItem *tool, const QString &toolname = \
QString()); +        Plasma::Icon * addToolBoxTool(const QString &toolName = \
QString(), const QString &iconName = QString(), const QString &iconText = QString()); \
  /**
          * Enables or disables a toolbox tool by name
Index: containment.cpp
===================================================================
--- containment.cpp	(revision 754756)
+++ containment.cpp	(working copy)
@@ -45,7 +45,6 @@
 
 #include "layouts/freelayout.h"
 #include "layouts/boxlayout.h"
-#include "widgets/pushbutton.h"
 
 namespace Plasma
 {
@@ -182,20 +181,14 @@
 
     if (isContainment() && type == DesktopContainment) {
         if (!d->toolbox) {
-            Plasma::PushButton *tool = new Plasma::PushButton(i18n("Add Widgets"));
-            tool->resize(tool->sizeHint());
-            addToolBoxTool(tool, "addwidgets");
-            connect(tool, SIGNAL(clicked()), this, SIGNAL(showAddWidgets()));
+            Plasma::Icon *addWidgetTool = addToolBoxTool("addwidgets", "edit-add", \
i18n("Add Widgets")); +            connect(addWidgetTool, SIGNAL(clicked()), this, \
SIGNAL(showAddWidgets()));  
-            tool = new Plasma::PushButton(i18n("Zoom In"));
-            connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
-            tool->resize(tool->sizeHint());
-            addToolBoxTool(tool, "zoomIn");
+            Plasma::Icon *zoomInTool = addToolBoxTool("zoomIn", "zoom-in", \
i18n("Zoom In")); +            connect(zoomInTool, SIGNAL(clicked()), this, \
SIGNAL(zoomIn()));  
-            tool = new Plasma::PushButton(i18n("Zoom Out"));
-            connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
-            tool->resize(tool->sizeHint());
-            addToolBoxTool(tool, "zoomOut");
+            Plasma::Icon *zoomOutTool = addToolBoxTool("zoomOut", "zoom-out", \
i18n("Zoom Out")); +            connect(zoomOutTool, SIGNAL(clicked()), this, \
SIGNAL(zoomOut()));  }
     } else {
         delete d->toolbox;
@@ -814,9 +807,21 @@
     emit launchActivated();
 }
 
-void Containment::addToolBoxTool(QGraphicsItem *tool, const QString& toolName)
+Plasma::Icon * Containment::addToolBoxTool(const QString& toolName, const QString& \
iconName, const QString& iconText)  {
+    Plasma::Icon *tool = new Plasma::Icon(this);
+
+    tool->setIcon(KIcon(iconName));
+    tool->setText(iconText);
+    tool->setOrientation(Qt::Horizontal);
+    QSizeF iconSize = tool->sizeFromIconSize(22);
+    tool->setMinimumSize(iconSize);
+    tool->setMaximumSize(iconSize);
+    tool->resize(tool->sizeHint());
+
     d->createToolbox()->addTool(tool, toolName);
+
+    return tool;
 }
 
 void Containment::enableToolBoxTool(const QString &toolname, bool enable)



_______________________________________________
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