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

List:       kde-panel-devel
Subject:    Re: [Panel-devel] AppletHandle and dynamic size
From:       Percy Leonhardt <mailings () eris23 ! de>
Date:       2007-11-22 16:06:15
Message-ID: 200711221706.15631.mailings () eris23 ! de
[Download RAW message or body]

On Tuesday 20 November 2007, Aaron J. Seigo wrote:
> i think we'll need to support this, yes. patches anyone? =)

I could offer the attached patch. It works but I am not sure if this is the 
most elegant solution...

	Percy :-)

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

Index: applethandle_p.h
===================================================================
--- applethandle_p.h	(revision 739993)
+++ applethandle_p.h	(working copy)
@@ -59,6 +59,7 @@
     private Q_SLOTS:
         void fadeAnimation(qreal progress);
         void appletDestroyed();
+        void appletResized();
 
     private:
         static const int HANDLE_WIDTH = 5;
@@ -67,6 +68,7 @@
 
         void startFading(FadeType anim);
         void forceDisappear();
+        void calculateSize();
         ButtonType mapToButton(const QPointF &point) const;
 
         QRectF m_rect;
Index: applethandle.cpp
===================================================================
--- applethandle.cpp	(revision 739993)
+++ applethandle.cpp	(working copy)
@@ -50,32 +50,9 @@
 {
     KColorScheme colors(QPalette::Active, KColorScheme::View, \
                Theme::self()->colors());
     m_gradientColor = colors.background(KColorScheme::NormalBackground).color();
-
     m_originalMatrix = m_applet->transform();
-    m_rect = m_applet->boundingRect();
-    m_rect = m_applet->mapToParent(m_rect).boundingRect();
 
-    const int requiredHeight = (HANDLE_WIDTH * 2) + \
                m_applet->hasConfigurationInterface() 
-                                                    ? ((ICON_SIZE + ICON_MARGIN) * \
                4)
-                                                    : ((ICON_SIZE + ICON_MARGIN) * \
                3)
-                                                  + ICON_MARGIN; // that last margin \
                is blank space before the close button
-    if (m_rect.height() < requiredHeight) {
-        float delta = requiredHeight - m_rect.height();
-        delta = delta/2.0;
-        if (delta > 0.0) {
-            m_rect.adjust(0.0, -delta, 0.0, delta);
-        }
-    }
-
-    m_rect.adjust(-HANDLE_WIDTH, -HANDLE_WIDTH, HANDLE_WIDTH, HANDLE_WIDTH);
-
-    if (m_applet->pos().x() <= ((HANDLE_WIDTH * 2) + ICON_SIZE)) {
-        m_rect.adjust(0.0, 0.0, ICON_SIZE, 0.0);
-        m_buttonsOnRight = true;
-    } else {
-        m_rect.adjust(- ICON_SIZE, 0.0, 0.0, 0.0);
-    }
-
+    calculateSize();
     m_applet->setParentItem(this);
     connect(m_applet, SIGNAL(destroyed(QObject*)), this, SLOT(appletDestroyed()));
     setAcceptsHoverEvents(true);
@@ -332,6 +309,13 @@
     deleteLater();
 }
 
+void AppletHandle::appletResized()
+{
+    prepareGeometryChange();
+    calculateSize();
+    update();
+}
+
 void AppletHandle::startFading(FadeType anim)
 {
     if (m_animId!=0) {
@@ -358,6 +342,33 @@
     startFading(FadeOut);
 }
 
+void AppletHandle::calculateSize()
+{
+    m_rect = m_applet->boundingRect();
+    m_rect = m_applet->mapToParent(m_rect).boundingRect();
+
+    const int requiredHeight = (HANDLE_WIDTH * 2) + \
m_applet->hasConfigurationInterface() +                                               \
? ((ICON_SIZE + ICON_MARGIN) * 4) +                                                   \
: ((ICON_SIZE + ICON_MARGIN) * 3) +                                                  \
+ ICON_MARGIN; // that last margin is blank space before the close button +    if \
(m_rect.height() < requiredHeight) { +        float delta = requiredHeight - \
m_rect.height(); +        delta = delta/2.0;
+        if (delta > 0.0) {
+            m_rect.adjust(0.0, -delta, 0.0, delta);
+        }
+    }
+
+    m_rect.adjust(-HANDLE_WIDTH, -HANDLE_WIDTH, HANDLE_WIDTH, HANDLE_WIDTH);
+
+    if (m_applet->pos().x() <= ((HANDLE_WIDTH * 2) + ICON_SIZE)) {
+        m_rect.adjust(0.0, 0.0, ICON_SIZE, 0.0);
+        m_buttonsOnRight = true;
+    } else {
+        m_rect.adjust(- ICON_SIZE, 0.0, 0.0, 0.0);
+    }
 }
 
+}
+
 #include "applethandle_p.moc"
Index: containment.cpp
===================================================================
--- containment.cpp	(revision 739993)
+++ containment.cpp	(working copy)
@@ -613,6 +613,8 @@
             d->handles[applet] = handle;
             connect(handle, SIGNAL(disappearDone(AppletHandle*)),
                     this, SLOT(handleDisappeared(AppletHandle*)));
+            connect(applet, SIGNAL(geometryChanged()),
+                    handle, SLOT(appletResized()));
         }
         break;
     default:



_______________________________________________
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