[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 6:19:07
Message-ID: f5fcb8a90712242219q453c98a4qdbec810dc379aa88 () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I've updated my patch to clean up some sloppy code.

~Craig

On Dec 24, 2007 7:13 PM, Craig Duquette <cduquette@gmail.com> wrote:

> 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
> >
>

[Attachment #5 (text/html)]

I&#39;ve updated my patch to clean up some sloppy code.<br><br>~Craig<br><br><div \
class="gmail_quote">On Dec 24, 2007 7:13 PM, Craig Duquette &lt;<a \
href="mailto:cduquette@gmail.com">cduquette@gmail.com</a>&gt; wrote:<br><blockquote \
class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt \
0pt 0.8ex; padding-left: 1ex;"> That&#39;s pretty cool, I was thinking of moving the \
icons to the arc of<br>the toolbox also. What about this? I&#39;ve moved the + to the \
right and<br>the two zoom buttons appear on the bottom of the toolbox. Someone from \
<br>IRC had a similar idea of moving icons to the two different sides.<br><br>This \
patch also contains the non-resizing toolbox code in it. Now the<br>toolbox will be \
displayed against a white background when zoomed out<br> so I semi-reverted the \
gradient back to the original. The edge fades<br>to fully invisible when fully \
expanded. I think it&#39;d be cool to have<br>it fade to invisible on the default \
view like the original patch..<br><br> Also any idea on how to do tooltips? There is \
a function<br>setToolTip(ToolTipData), but I&#39;m really not sure how to construct \
a<br>&#39;ToolTipData&#39; thingy..<br><br>Craig AKA gamma<br><div><div></div><div \
class="Wj3C7c"> <br><br>On 12/24/07, Alex Merry &lt;<a \
href="mailto:huntedhacker@tiscali.co.uk">huntedhacker@tiscali.co.uk</a>&gt; \
wrote:<br>&gt; On Monday 24 Dec 2007, Alex Merry wrote:<br>&gt; &gt; On Sunday 23 Dec \
2007, Craig Duquette wrote: <br>&gt; &gt; &gt; This patch replaces the buttons that \
appear when you hover over the<br>&gt; &gt; &gt; toolbox with nice pretty oxygen \
icons :D.<br>&gt;<br>&gt; &gt; I think my preference would be to have the text \
written to the left <br>&gt; &gt; of the icons, and ideally to have the icons in a \
quarter-circle<br>&gt; &gt; following the circumference of the \
toolbox.<br>&gt;<br>&gt; A quarter-circle wouldn&#39;t work with text on the left, \
actually, now I <br>&gt; think about it. &nbsp;The attachedd patch is the prettier \
toolbox plus a<br>&gt; diagonal line of icons.<br>&gt;<br>&gt; There&#39;s no text \
yet, so that either needs adding in or some tooltips are<br>&gt; required.<br> \
&gt;<br>&gt; And if we go with tooltips, we can have a quarter-circle (although \
I<br>&gt; think text is probably better...)<br>&gt;<br>&gt; \
Alex<br>&gt;<br>&gt;<br>&gt;<br>&gt; --<br>&gt; KDE: <a href="http://www.kde.org" \
target="_blank"> http://www.kde.org</a><br>&gt; OpenSUSE: <a \
href="http://www.opensuse.org" \
target="_blank">http://www.opensuse.org</a><br>&gt;<br></div></div></blockquote></div><br>



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

Index: libs/plasma/desktoptoolbox.cpp
===================================================================
--- libs/plasma/desktoptoolbox.cpp	(revision 752605)
+++ 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 752605)
+++ 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,12 @@
          */
         bool isToolboxToolEnabled(const QString &toolname) const;
 
+	/**
+         * Returns the toolbox for the current containment
+	 * @return the toolbox
+         */
+        DesktopToolbox* toolbox() const;
+
         /**
          * @internal
          * Called when constraints have been updated on this containment to provide
Index: libs/plasma/containment.cpp
===================================================================
--- libs/plasma/containment.cpp	(revision 752605)
+++ 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,32 @@
 
     if (isContainment() && type == DesktopContainment) {
         if (!d->toolbox) {
-            Plasma::PushButton *tool = new Plasma::PushButton(i18n("Add Widgets"));
+	    Plasma::Icon *tool = new Plasma::Icon(this);
+
+	    //TODO: Add tooltip support to the icons
+	    /*
+	    Plasma::ToolTipData data;
+	    data.mainText = "Testing";
+	    data.subText = "Test Test 1, 2, 3";
+	    tool->setToolTip(data);
+	    */
+
+	    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");
@@ -812,6 +827,11 @@
     return d->createToolbox()->isToolEnabled(toolname);
 }
 
+DesktopToolbox* Containment::toolbox() const
+{
+  return d->createToolbox();
+}
+
 } // Plasma namespace
 
 #include "containment.moc"
Index: plasma/plasma/desktopview.cpp
===================================================================
--- plasma/plasma/desktopview.cpp	(revision 752605)
+++ plasma/plasma/desktopview.cpp	(working copy)
@@ -83,21 +83,30 @@
 
 void DesktopView::zoomIn()
 {
+    Plasma::DesktopToolbox *toolbox = containment()->toolbox();
+
     containment()->enableToolBoxTool("zoomOut", true);
     qreal s = Plasma::scalingFactor(m_zoomLevel) / matrix().m11();
     if (m_zoomLevel == Plasma::GroupZoom) {
         containment()->enableToolBoxTool("zoomIn", false);
         m_zoomLevel = Plasma::DesktopZoom;
         s = Plasma::scalingFactor(m_zoomLevel) / matrix().m11();
+
+	toolbox->setPos(width() - toolbox->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();
+
+	toolbox->setPos(width()/factor - toolbox->boundingRect().width()/factor, 0);
+
         setSceneRect(QRectF(0, 0, width() * 1.0/factor, height() * 1.0/factor));
     } else {
         containment()->enableToolBoxTool("zoomIn", false);
+	
+	toolbox->setPos(width() - toolbox->boundingRect().width(), 0);
         return;
     }
 
@@ -106,6 +115,8 @@
 
 void DesktopView::zoomOut()
 {
+    Plasma::DesktopToolbox *toolbox = containment()->toolbox();
+
     containment()->enableToolBoxTool("zoomIn", true);
     if (m_zoomLevel == Plasma::DesktopZoom) {
         containment()->enableToolBoxTool("zoomOut", true);
@@ -120,6 +131,9 @@
 
     qreal factor = Plasma::scalingFactor(m_zoomLevel);
     qreal s = factor / matrix().m11();
+
+    toolbox->setPos(width()/factor - toolbox->boundingRect().width()/factor, 0);
+
     setSceneRect(QRectF(0, 0, width() * 1.0/factor, height() * 1.0/factor));
     scale(s, s);
 }



_______________________________________________
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