[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-25 0:13:40
Message-ID: f5fcb8a90712241613u12e99336n10ce96fab1d14241 () mail ! gmail ! com
[Download RAW message or body]

That's pretty cool, I was thinking of moving the icons to the arc of
the toolbox also. What about this? I've moved the + to the right and
the two zoom buttons appear on the bottom of the toolbox. Someone from
IRC had a similar idea of moving icons to the two different sides.

This patch also contains the non-resizing toolbox code in it. Now the
toolbox will be displayed against a white background when zoomed out
so I semi-reverted the gradient back to the original. The edge fades
to fully invisible when fully expanded. I think it'd be cool to have
it fade to invisible on the default view like the original patch..

Also any idea on how to do tooltips? There is a function
setToolTip(ToolTipData), but I'm really not sure how to construct a
'ToolTipData' thingy..

Craig AKA gamma


On 12/24/07, Alex Merry <huntedhacker@tiscali.co.uk> wrote:
> On Monday 24 Dec 2007, Alex Merry wrote:
> > On Sunday 23 Dec 2007, Craig Duquette wrote:
> > > This patch replaces the buttons that appear when you hover over the
> > > toolbox with nice pretty oxygen icons :D.
>
> > I think my preference would be to have the text written to the left
> > of the icons, and ideally to have the icons in a quarter-circle
> > following the circumference of the toolbox.
>
> A quarter-circle wouldn't work with text on the left, actually, now I
> think about it.  The attachedd patch is the prettier toolbox plus a
> diagonal line of icons.
>
> There's no text yet, so that either needs adding in or some tooltips are
> required.
>
> And if we go with tooltips, we can have a quarter-circle (although I
> think text is probably better...)
>
> Alex
>
>
>
> --
> KDE: http://www.kde.org
> OpenSUSE: http://www.opensuse.org
>

["toolbox.patch" (text/x-patch)]

Index: libs/plasma/desktoptoolbox.cpp
===================================================================
--- libs/plasma/desktoptoolbox.cpp	(revision 752325)
+++ libs/plasma/desktoptoolbox.cpp	(working copy)
@@ -36,7 +36,7 @@
 DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
     : QGraphicsItem(parent),
       m_icon("configure"),
-      m_size(50),
+      m_size(40),
       m_showing(false),
       m_animId(0),
       m_animFrame(0)
@@ -45,6 +45,7 @@
     setZValue(10000);
     setFlag(ItemClipsToShape, true);
     setFlag(ItemClipsChildrenToShape, false);
+    setFlag(ItemIgnoresTransformations, true);
 
     connect(Plasma::Phase::self(), SIGNAL(movementComplete(QGraphicsItem*)), this, \
SLOT(toolMoved(QGraphicsItem*)));  }
@@ -67,15 +68,16 @@
     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);
     painter->setBrush(gradient);
     painter->drawPath(p);
     painter->restore();
-    m_icon.paint(painter, QRect(m_size*2 - 34, 2, 32, 32));
+    m_icon.paint(painter, QRect(m_size*2 - 24, 2, 22, 22));
 }
 
 QPainterPath DesktopToolbox::shape() const
@@ -90,7 +92,7 @@
 void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
 {
 //    Plasma::Phase::self()->moveItem(this, Phase::SlideIn, QPoint(-25, -25));
-    int x = -25; // pos().x();
+    int x = 25; // pos().x();
     int y = 0; // pos().y();
     Plasma::Phase* phase = Plasma::Phase::self();
     foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
@@ -98,6 +100,11 @@
             continue;
         }
 
+	if (tool->data(ToolName).toString() == "addwidgets")
+	  x = 25;
+	else
+	  x = m_size*2 - 25;
+
         //kDebug() << "let's show and move" << tool << tool->boundingRect();
         tool->show();
         phase->moveItem(tool, Plasma::Phase::SlideIn, QPoint(x, y));
@@ -117,7 +124,7 @@
 void DesktopToolbox::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
 {
 //    Plasma::Phase::self->moveItem(this, Phase::SlideOut, boundingRect()QPoint(-50, \
                -50));
-    int x = 0; // pos().x() + geometry().width();
+    int x = 50; // pos().x() + geometry().width();
     int y = 0;
     Plasma::Phase* phase = Plasma::Phase::self();
     foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
@@ -171,7 +178,7 @@
     }
 
     tool->hide();
-    tool->setPos(QPoint(0,0));
+    tool->setPos(QPoint(50,0));
     tool->setZValue(zValue() + 1);
     tool->setParentItem(this);
     tool->setData(ToolName, name);
Index: libs/plasma/containment.h
===================================================================
--- libs/plasma/containment.h	(revision 752325)
+++ libs/plasma/containment.h	(working copy)
@@ -30,6 +30,8 @@
 #include <plasma/applet.h>
 #include <plasma/phase.h>
 
+#include "desktoptoolbox_p.h"
+
 namespace Plasma
 {
 
@@ -231,6 +233,11 @@
          */
         bool isToolboxToolEnabled(const QString &toolname) const;
 
+	/**
+         * Moves the toolbox
+         */
+        DesktopToolbox* getToolbox() const;
+
         /**
          * @internal
          * Called when constraints have been updated on this containment to provide
Index: libs/plasma/containment.cpp
===================================================================
--- libs/plasma/containment.cpp	(revision 752325)
+++ libs/plasma/containment.cpp	(working copy)
@@ -44,7 +44,7 @@
 
 #include "layouts/freelayout.h"
 #include "layouts/boxlayout.h"
-#include "widgets/pushbutton.h"
+#include "widgets/icon.h"
 
 namespace Plasma
 {
@@ -181,17 +181,23 @@
 
     if (isContainment() && type == DesktopContainment) {
         if (!d->toolbox) {
-            Plasma::PushButton *tool = new Plasma::PushButton(i18n("Add Widgets"));
+	    Plasma::Icon *tool = new Plasma::Icon(this);
+	    tool->setIcon( KIcon( "edit-add" ) );
+	    tool->setIconSize( 22, 22 );
             tool->resize(tool->sizeHint());
             addToolBoxTool(tool, "addwidgets");
             connect(tool, SIGNAL(clicked()), this, SIGNAL(showAddWidgets()));
 
-            tool = new Plasma::PushButton(i18n("Zoom In"));
+	    tool = new Plasma::Icon(this);
+	    tool->setIcon( KIcon( "zoom-in" ) );
+	    tool->setIconSize( 22, 22 );
             connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomIn()));
             tool->resize(tool->sizeHint());
             addToolBoxTool(tool, "zoomIn");
 
-            tool = new Plasma::PushButton(i18n("Zoom Out"));
+	    tool = new Plasma::Icon(this);
+	    tool->setIcon( KIcon( "zoom-out" ) );
+	    tool->setIconSize( 22, 22 );
             connect(tool, SIGNAL(clicked()), this, SIGNAL(zoomOut()));
             tool->resize(tool->sizeHint());
             addToolBoxTool(tool, "zoomOut");
@@ -763,6 +769,11 @@
     return d->createToolbox()->isToolEnabled(toolname);
 }
 
+DesktopToolbox* Containment::getToolbox() const
+{
+  return d->createToolbox();
+}
+
 } // Plasma namespace
 
 #include "containment.moc"
Index: plasma/plasma/desktopview.cpp
===================================================================
--- plasma/plasma/desktopview.cpp	(revision 752325)
+++ plasma/plasma/desktopview.cpp	(working copy)
@@ -89,15 +89,22 @@
         containment()->enableToolBoxTool("zoomIn", false);
         m_zoomLevel = Plasma::DesktopZoom;
         s = Plasma::scalingFactor(m_zoomLevel) / matrix().m11();
+
+	containment()->getToolbox()->setPos(width() - \
containment()->getToolbox()->boundingRect().width(), 0);  setSceneRect(geometry());
     } else if (m_zoomLevel == Plasma::OverviewZoom) {
         containment()->enableToolBoxTool("zoomIn", true);
         m_zoomLevel = Plasma::GroupZoom;
         qreal factor = Plasma::scalingFactor(m_zoomLevel);
         s = factor / matrix().m11();
+
+	containment()->getToolbox()->setPos(width()/factor - \
containment()->getToolbox()->boundingRect().width()/factor, 0); +
         setSceneRect(QRectF(0, 0, width() * 1.0/factor, height() * 1.0/factor));
     } else {
         containment()->enableToolBoxTool("zoomIn", false);
+	
+	containment()->getToolbox()->setPos(width() - \
containment()->getToolbox()->boundingRect().width(), 0);  return;
     }
 
@@ -120,6 +127,9 @@
 
     qreal factor = Plasma::scalingFactor(m_zoomLevel);
     qreal s = factor / matrix().m11();
+
+    containment()->getToolbox()->setPos(width()/factor - \
containment()->getToolbox()->boundingRect().width()/factor, 0); +
     setSceneRect(QRectF(0, 0, width() * 1.0/factor, height() * 1.0/factor));
     scale(s, s);
 }


["toolbox.png" (image/png)]

_______________________________________________
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