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

List:       kde-panel-devel
Subject:    Re: [Panel-devel] trashcan applet
From:       Marco Martin <martkive () gmail ! com>
Date:       2007-11-29 21:12:10
Message-ID: 200711292212.10259.martkive () gmail ! com
[Download RAW message or body]

On Thursday 29 November 2007, Aaron J. Seigo wrote:
> i think it might just be easier to completely rewrite the Icon class at
> this point rather than try and untangle it. it should be a quick job as it
> just needs to show, well, an icon and some text below it given a certain
> amount of space.


with these patch now the icon widgets are more or less working.
probably everything it's still broken in many ways but yeah...

apart that, the text has a butt ugly drop shadow, only for trying out...
the trashcan in this patch is in really bad shape, it's only for testing the 
icon widget, it's full of commented out code that i still didn't understood 
if it's really useless and i can remove it.

Cheers,
Marco Martin

["4_trash-patch.diff" (text/x-diff)]

Only in /opt/svn/trash/: Messages.sh
Only in /opt/svn/trash/: .svn
diff -Eb -U 3 -d /opt/svn/trash/trash.cpp trash/trash.cpp
--- /opt/svn/trash/trash.cpp	2007-11-26 16:28:54.000000000 +0100
+++ trash/trash.cpp	2007-11-29 22:01:57.000000000 +0100
@@ -32,7 +32,6 @@
 
 
 #include <konq_operations.h>
-#include <plasma/layouts/boxlayout.h>
 #include <plasma/widgets/icon.h>
 #include <plasma/containment.h>
 
@@ -51,19 +50,24 @@
 void Trash::init()
 {
     KConfigGroup cg = config();
-    int size = globalConfig().readEntry("IconSize", IconSize(KIconLoader::Desktop));
-    size = cg.readEntry("IconSize", size);
+    //int size = globalConfig().readEntry("IconSize", IconSize(KIconLoader::Desktop));
+    //size = cg.readEntry("IconSize", size);
 
     createMenu();
 
-    new Plasma::HBoxLayout(this);
+    /*m_layout = new Plasma::HBoxLayout(this);
+    m_layout->setMargin(0);
+    m_layout->setSpacing(0);*/
 
     m_icon = new Plasma::Icon(KIcon("user-trash"),QString(),this);
 
     connect(m_icon, SIGNAL(pressed(bool, QGraphicsSceneMouseEvent*)),
             this, SLOT(popup(bool,QGraphicsSceneMouseEvent*)));
-    m_icon->setIconSize(size, size);
-    resize(m_icon->sizeHint());
+    //m_icon->setIconSize(size, size);
+    //resize(m_icon->sizeHint());
+    setMinimumSize(QSize(84,84));
+    setMaximumSize(QSize(400,400));
+    //m_layout->addItem(m_icon);
 
     setAcceptDrops(true);
 
@@ -80,7 +84,7 @@
 
 void Trash::saveState(KConfigGroup *cg) const
 {
-    cg->writeEntry("IconSize", m_icon->iconSize().toSize());
+    //cg->writeEntry("IconSize", m_icon->iconSize().toSize());
 }
 
 
@@ -137,9 +141,15 @@
             m_icon->setInfoText(0);
             m_showText = false;
         }
-        updateGeometry();
         setIcon();
     }
+    if (constraints & Plasma::SizeConstraint && m_icon) {
+        //m_icon->setIconSize(contentSize().toSize().width()-4, contentSize().toSize().width()-4);
+        m_icon->resize(size());
+        update();
+    }
+
+    updateGeometry();
 }
 
 void Trash::slotOpen()
@@ -148,6 +158,7 @@
         containment()->emitLaunchActivated();
     }
     KRun::runUrl(m_trashUrl, "inode/directory", 0);
+    //KRun::KRun(m_trashUrl, &m_menu);
 }
 
 void Trash::slotEmpty()
diff -Eb -U 3 -d /opt/svn/trash/trash.h trash/trash.h
--- /opt/svn/trash/trash.h	2007-11-26 16:28:54.000000000 +0100
+++ trash/trash.h	2007-11-29 22:01:57.000000000 +0100
@@ -29,6 +29,7 @@
 #include <KDirLister>
 
 #include <plasma/applet.h>
+//#include <plasma/layouts/boxlayout.h>
 
 class KPropertiesDialog;
 
@@ -73,6 +74,7 @@
         KPropertiesDialog *m_dialog;
         KDirLister *m_dirLister;
         KUrl m_trashUrl;
+        //Plasma::HBoxLayout *m_layout;
         KMenu m_menu;
         int m_count;
         bool m_showText;

["icon_1.diff" (text/x-diff)]

--- icon_1.cpp	2007-11-20 18:50:46.000000000 +0100
+++ icon.cpp	2007-11-29 21:57:30.000000000 +0100
@@ -753,6 +753,9 @@
 void Icon::Private::drawTextItems(QPainter *painter, const QStyleOptionGraphicsItem *option,
                                   const QTextLayout &labelLayout, const QTextLayout &infoLayout) const
 {
+    painter->setPen(option->palette.color(QPalette::Background));
+    labelLayout.draw(painter, QPointF(1,1));
+
     QPen pen(foregroundBrush(option), 0);
     painter->setPen(pen);
     labelLayout.draw(painter, QPointF());
@@ -906,6 +909,18 @@
     calculateSize();
 }
 
+void Icon::resize(const QSizeF& s)
+{
+  QStyleOptionGraphicsItem option;
+  option.state = QStyle::State_None;
+  option.rect = boundingRect().toRect();
+
+  int focusHMargin = QApplication::style()->pixelMetric(QStyle::PM_FocusFrameHMargin);
+  int iconWidth = s.width()-focusHMargin*2;
+  iconWidth -= d->displaySizeHint(&option).height();
+  Icon::setIconSize(iconWidth, iconWidth);
+}
+
 void Icon::setIconSize(int w, int h)
 {
     setIconSize(QSizeF(w, h));


_______________________________________________
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