On Tue, May 25, 2010 at 12:38:44PM -0700, Aaron J. Seigo wrote:

> > Is there a chance this will make it into 4.4.4?  If not, I might want to
> 
> i highly doubt it, sorry :(

Thanks for your effors in getting this into trunk.  The latest revisions
(with MenuLauncherApplet::sizeHint defined const) work great!

I've gone through SVN and cherry-picked the patches for each applet and
backported them to the KDE 4.4 SVN branch--keeping just the changes
relevant to iconSizeChanged/sizeHint as well as setting of the Panel icon
size in kcm_icons.  Attached is a single, backported, tested patch against
4.4/KDE.

Would it be possible to commit this to the 4.4 branch?  I'd love to see
this in Debian, and KDE 4.4.5 is the path of least resistance on that.

Thanks!
Index: kdebase/runtime/kcontrol/icons/icons.cpp
===================================================================
--- kdebase/runtime/kcontrol/icons/icons.cpp	(revision 1134187)
+++ kdebase/runtime/kcontrol/icons/icons.cpp	(working copy)
@@ -409,10 +409,10 @@
         return;
 
     mUsage = index;
-    if ( mUsage == KIconLoader::Panel || mUsage == KIconLoader::LastGroup )
+    if ( mUsage == KIconLoader::LastGroup )
     {
         mpSizeBox->setEnabled(false);
-	mpAnimatedCheck->setEnabled( mUsage == KIconLoader::Panel );
+        mpAnimatedCheck->setEnabled(false);
     }
     else
     {
Index: kdebase/workspace/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp
===================================================================
--- kdebase/workspace/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp	(revision 1134187)
+++ kdebase/workspace/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.cpp	(working copy)
@@ -371,6 +371,9 @@
     }
 
     constraintsEvent(Plasma::ImmutableConstraint);
+
+    connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)),
+        this, SLOT(iconSizeChanged(int)));
 }
 
 void MenuLauncherApplet::constraintsEvent(Plasma::Constraints constraints)
@@ -787,4 +790,35 @@
     return d->actions;
 }
 
+void MenuLauncherApplet::iconSizeChanged(int group)
+{
+    if (group == KIconLoader::Desktop || group == KIconLoader::Panel) {
+        updateGeometry();
+    }
+}
+
+QSizeF MenuLauncherApplet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
+{
+    if (which == Qt::PreferredSize) {
+        int iconSize;
+
+        switch (formFactor()) {
+            case Plasma::Planar:
+            case Plasma::MediaCenter:
+                iconSize = IconSize(KIconLoader::Desktop);
+                break;
+
+            case Plasma::Horizontal:
+            case Plasma::Vertical:
+                iconSize = IconSize(KIconLoader::Panel);
+                break;
+        }
+
+        return QSizeF(iconSize, iconSize);
+    }
+
+    return Plasma::Applet::sizeHint(which, constraint);
+}
+
+
 #include "simpleapplet.moc"
Index: kdebase/workspace/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.h
===================================================================
--- kdebase/workspace/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.h	(revision 1134187)
+++ kdebase/workspace/plasma/desktop/applets/kickoff/simpleapplet/simpleapplet.h	(working copy)
@@ -126,6 +126,8 @@
      */
     void createConfigurationInterface(KConfigDialog *parent);
 
+    QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
+
 private Q_SLOTS:
 	/// Configuration-dialog accepted.
     void configAccepted();
@@ -133,6 +135,8 @@
     void toggleMenu(bool pressed = true);
     /// An action within the menu got triggered.
     void actionTriggered(QAction *action);
+    /// Icon size setting changed
+    void iconSizeChanged(int group);
 
 private:
     class Private;
Index: kdebase/workspace/plasma/generic/applets/icon/icon.cpp
===================================================================
--- kdebase/workspace/plasma/generic/applets/icon/icon.cpp	(revision 1134187)
+++ kdebase/workspace/plasma/generic/applets/icon/icon.cpp	(working copy)
@@ -27,6 +27,7 @@
 
 #include <KDebug>
 #include <KDesktopFile>
+#include <KGlobalSettings>
 #include <KIconLoader>
 #include <KLocale>
 #include <KMenu>
@@ -84,6 +85,9 @@
     setDisplayLines(2);
     registerAsDragHandle(m_icon);
     setAspectRatioMode(Plasma::ConstrainedSquare);
+
+    connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)),
+        this, SLOT(iconSizeChanged(int)));
 }
 
 IconApplet::~IconApplet()
@@ -110,6 +114,13 @@
     }
 }
 
+void IconApplet::iconSizeChanged(int group)
+{
+    if (group == KIconLoader::Desktop || group == KIconLoader::Panel) {
+        updateGeometry();
+    }
+}
+
 void IconApplet::setUrl(const KUrl& url)
 {
     m_url = KIO::NetAccess::mostLocalUrl(url, 0);
@@ -252,6 +263,29 @@
     }
 }
 
+QSizeF IconApplet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
+{
+    if (which == Qt::PreferredSize) {
+        int iconSize;
+
+        switch (formFactor()) {
+            case Plasma::Planar:
+            case Plasma::MediaCenter:
+                iconSize = IconSize(KIconLoader::Desktop);
+                break;
+
+            case Plasma::Horizontal:
+            case Plasma::Vertical:
+                iconSize = IconSize(KIconLoader::Panel);
+                break;
+        }
+
+        return QSizeF(iconSize, iconSize);
+    }
+
+    return Plasma::Applet::sizeHint(which, constraint);
+}
+
 void IconApplet::setDisplayLines(int displayLines)
 {
     if (m_icon) {
Index: kdebase/workspace/plasma/generic/applets/icon/icon.h
===================================================================
--- kdebase/workspace/plasma/generic/applets/icon/icon.h	(revision 1134187)
+++ kdebase/workspace/plasma/generic/applets/icon/icon.h	(working copy)
@@ -56,12 +56,14 @@
         void dropEvent(QGraphicsSceneDragDropEvent *event);
         void saveState(KConfigGroup &cg) const;
         void showConfigurationInterface();
+        QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
 
     private slots:
         void acceptedPropertiesDialog();
         void propertiesDialogClosed();
         void delayedDestroy();
         void checkExistenceOfUrl();
+        void iconSizeChanged(int group);
 
     private:
         //dropUrls from DolphinDropController
Index: kdelibs/plasma/popupapplet.cpp
===================================================================
--- kdelibs/plasma/popupapplet.cpp	(revision 1134184)
+++ kdelibs/plasma/popupapplet.cpp	(working copy)
@@ -408,6 +408,27 @@
     emit q->sizeHintChanged(Qt::PreferredSize);
 }
 
+QSizeF PopupApplet::sizeHint(Qt::SizeHint which, const QSizeF & constraint) const
+{
+    if (!d->dialogPtr || which != Qt::PreferredSize) {
+        return Applet::sizeHint(which, constraint);
+    }
+
+    switch (formFactor()) {
+        case Vertical:
+        case Horizontal: {
+            const int size = IconSize(KIconLoader::Panel);
+            return QSizeF(size, size);
+            break;
+        }
+        default:
+            break;
+    }
+
+    const int size = IconSize(KIconLoader::Desktop);
+    return QSizeF(size, size);
+}
+
 void PopupApplet::mousePressEvent(QGraphicsSceneMouseEvent *event)
 {
     if (!d->icon && !d->popupLostFocus && event->buttons() == Qt::LeftButton) {
@@ -580,6 +601,7 @@
           popupLostFocus(false),
           passive(false)
 {
+    QObject::connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)), q, SLOT(iconSizeChanged(int)));
 }
 
 PopupAppletPrivate::~PopupAppletPrivate()
@@ -592,6 +614,13 @@
     delete icon;
 }
 
+void PopupAppletPrivate::iconSizeChanged(int group)
+{
+    if (icon && (group == KIconLoader::Desktop || group == KIconLoader::Panel)) {
+        q->updateGeometry();
+    }
+}
+
 void PopupAppletPrivate::internalTogglePopup()
 {
     if (timer) {
Index: kdelibs/plasma/popupapplet.h
===================================================================
--- kdelibs/plasma/popupapplet.h	(revision 1134184)
+++ kdelibs/plasma/popupapplet.h	(working copy)
@@ -144,6 +144,7 @@
      */
     virtual void popupEvent(bool show);
 
+    QSizeF sizeHint(Qt::SizeHint which, const QSizeF & constraint = QSizeF()) const;
     void mousePressEvent(QGraphicsSceneMouseEvent *event);
     void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
     bool eventFilter(QObject *watched, QEvent *event);
@@ -168,6 +169,7 @@
     Q_PRIVATE_SLOT(d, void dialogSizeChanged())
     Q_PRIVATE_SLOT(d, void dialogStatusChanged(bool))
     Q_PRIVATE_SLOT(d, void updateDialogPosition())
+    Q_PRIVATE_SLOT(d, void iconSizeChanged(int))
 
     friend class Applet;
     friend class AppletPrivate;
Index: kdelibs/plasma/private/popupapplet_p.h
===================================================================
--- kdelibs/plasma/private/popupapplet_p.h	(revision 1134184)
+++ kdelibs/plasma/private/popupapplet_p.h	(working copy)
@@ -33,6 +33,7 @@
     PopupAppletPrivate(PopupApplet *applet);
     ~PopupAppletPrivate();
 
+    void iconSizeChanged(int group);
     void internalTogglePopup();
     void hideTimedPopup();
     void clearPopupLostFocus();
Index: kdeplasma-addons/applets/lancelot/app/src/launcher/LancelotApplet.cpp
===================================================================
--- kdeplasma-addons/applets/lancelot/app/src/launcher/LancelotApplet.cpp	(revision 1134190)
+++ kdeplasma-addons/applets/lancelot/app/src/launcher/LancelotApplet.cpp	(working copy)
@@ -19,6 +19,7 @@
 
 #include "LancelotApplet.h"
 #include <KIcon>
+#include <KGlobalSettings>
 #include <climits>
 
 #include <QDBusInterface>
@@ -179,6 +180,9 @@
 
     d->waitClick.setInterval(500); // 1/2 sec
     d->waitClick.setSingleShot(true);
+
+    connect(KGlobalSettings::self(), SIGNAL(iconChanged(int)),
+        this, SLOT(iconSizeChanged(int)));
 }
 
 // void LancelotApplet::paint(QPainter * p,
@@ -217,16 +221,46 @@
 {
     d->layout->setContentsMargins(0, 0, 0, 0);
     d->layout->setSpacing(SPACING);
+
     if (d->showCategories) {
         d->createCategoriesButtons();
     } else {
         d->createMainButton();
     }
+
+    // We want to update the size hints
+    iconSizeChanged(KIconLoader::Desktop);
+
     emit configNeedsSaving();
     update();
     setAspectRatioMode(Plasma::KeepAspectRatio);
 }
 
+void LancelotApplet::iconSizeChanged(int group)
+{
+    if (group == KIconLoader::Desktop || group == KIconLoader::Panel) {
+        int iconSize;
+
+        switch (formFactor()) {
+            case Plasma::Planar:
+            case Plasma::MediaCenter:
+                iconSize = IconSize(KIconLoader::Desktop);
+                break;
+
+            case Plasma::Horizontal:
+            case Plasma::Vertical:
+                iconSize = IconSize(KIconLoader::Panel);
+                break;
+        }
+
+        foreach (Lancelot::HoverIcon * icon, d->buttons) {
+            icon->setPreferredSize(QSizeF(iconSize, iconSize));
+        }
+
+        updateGeometry();
+    }
+}
+
 void LancelotApplet::init()
 {
     d->lancelot->addClient();
Index: kdeplasma-addons/applets/lancelot/app/src/launcher/LancelotApplet.h
===================================================================
--- kdeplasma-addons/applets/lancelot/app/src/launcher/LancelotApplet.h	(revision 1134190)
+++ kdeplasma-addons/applets/lancelot/app/src/launcher/LancelotApplet.h	(working copy)
@@ -58,6 +58,7 @@
     void applyConfig();
     void loadConfig();
     void saveConfig();
+    void iconSizeChanged(int group);
 
 private:
     class Private;
_______________________________________________
Plasma-devel mailing list
Plasma-devel@kde.org
https://mail.kde.org/mailman/listinfo/plasma-devel

Reply via email to