[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:       Alex Merry <huntedhacker () tiscali ! co ! uk>
Date:       2007-12-24 22:57:27
Message-ID: 200712242257.56249.huntedhacker () tiscali ! co ! uk
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


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.png" (image/png)]
["toolbox.diff" (text/x-diff)]

Index: desktoptoolbox.cpp
===================================================================
--- desktoptoolbox.cpp	(revision 752470)
+++ desktoptoolbox.cpp	(working copy)
@@ -36,7 +36,7 @@ static const int ToolName = 7001;
 DesktopToolbox::DesktopToolbox(QGraphicsItem *parent)
     : QGraphicsItem(parent),
       m_icon("configure"),
-      m_size(50),
+      m_size(40),
       m_showing(false),
       m_animId(0),
       m_animFrame(0)
@@ -67,15 +67,15 @@ void DesktopToolbox::paint(QPainter *pai
     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(0.333, 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,8 +90,15 @@ QPainterPath DesktopToolbox::shape() con
 void DesktopToolbox::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
 {
 //    Plasma::Phase::self()->moveItem(this, Phase::SlideIn, QPoint(-25, -25));
-    int x = -25; // pos().x();
-    int y = 0; // pos().y();
+    int count = 0;
+    foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
+        if (!tool->isEnabled()) {
+            continue;
+        }
+        ++count;
+    }
+    int x = m_size*2 - 30*count; // pos().x(); - based on 25x25px children + 5px padding
+    int y = 5; // pos().y();
     Plasma::Phase* phase = Plasma::Phase::self();
     foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
         if (!tool->isEnabled()) {
@@ -101,8 +108,9 @@ void DesktopToolbox::hoverEnterEvent(QGr
         //kDebug() << "let's show and move" << tool << tool->boundingRect();
         tool->show();
         phase->moveItem(tool, Plasma::Phase::SlideIn, QPoint(x, y));
-        //x += 0;
-        y += static_cast<int>(tool->boundingRect().height()) + 5;
+        QRectF rect = tool->boundingRect();
+        x += static_cast<int>(rect.width()) + 5;
+        y += static_cast<int>(rect.height()) + 5;
     }
 
     if (m_animId) {
@@ -117,7 +125,7 @@ void DesktopToolbox::hoverEnterEvent(QGr
 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 = m_size*2; // pos().x() + geometry().width();
     int y = 0;
     Plasma::Phase* phase = Plasma::Phase::self();
     foreach (QGraphicsItem* tool, QGraphicsItem::children()) {
@@ -126,7 +134,9 @@ void DesktopToolbox::hoverLeaveEvent(QGr
             continue;
         }
 
-        phase->moveItem(tool, Plasma::Phase::SlideOut, QPoint(x, y));
+        QRectF rect = tool->boundingRect();
+        int height = static_cast<int>(rect.height());
+        phase->moveItem(tool, Plasma::Phase::SlideOut, QPoint(x, y-height));
     }
 
     if (m_animId) {
@@ -171,7 +181,8 @@ void DesktopToolbox::addTool(QGraphicsIt
     }
 
     tool->hide();
-    tool->setPos(QPoint(0,0));
+    const int height = static_cast<int>(tool->boundingRect().height());
+    tool->setPos(QPoint(m_size*2,-height));
     tool->setZValue(zValue() + 1);
     tool->setParentItem(this);
     tool->setData(ToolName, name);
Index: containment.cpp
===================================================================
--- containment.cpp	(revision 752470)
+++ 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 @@ void Containment::setContainmentType(Con
 
     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");

["signature.asc" (application/pgp-signature)]

_______________________________________________
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