KDE

Marco Martin notmart at gmail.com
Sat Jul 31 15:02:08 CEST 2010


SVN commit 1157537 by mart:

The Desktop ToolBox and the Panel ToolBox becomes plugins, shipped with
Plasma-Desktop (so shells have to implement their own plugins or pick
one already installed)

Unfortunately, 3 virtuals were needed in AbstractToolBox
void restore(const KConfigGroup &group);
void save(const KConfigGroup &group);
void reposition();

since this is not possible for obvious BC reasons, they are "faked" with
slots, not really nice butthe most painless way.

There shouldn't be significant regressions, but wise to keep an eye on
it in the immediate future

CCMAIL:plasma-devel at kde.org



 M  +1 -0      kdebase/workspace/plasma/desktop/shell/CMakeLists.txt  
 M  +3 -0      kdebase/workspace/plasma/desktop/shell/desktopcorona.cpp  
 A             kdebase/workspace/plasma/desktop/shell/toolbox (directory)  
 A             kdebase/workspace/plasma/desktop/shell/toolbox/CMakeLists.txt  
 A             kdebase/workspace/plasma/desktop/shell/toolbox/Messages.sh  
 A             kdebase/workspace/plasma/desktop/shell/toolbox/desktoptoolbox.cpp   kdelibs/plasma/private/desktoptoolbox.cpp#1157178 [License: LGPL (v2+)]
 A             kdebase/workspace/plasma/desktop/shell/toolbox/desktoptoolbox_p.h   kdelibs/plasma/private/desktoptoolbox_p.h#1157178 [License: LGPL (v2+)]
 A             kdebase/workspace/plasma/desktop/shell/toolbox/internaltoolbox.cpp   kdelibs/plasma/private/internaltoolbox.cpp#1157178 [License: LGPL (v2+)]
 A             kdebase/workspace/plasma/desktop/shell/toolbox/internaltoolbox_p.h   kdelibs/plasma/private/internaltoolbox_p.h#1157178 [License: LGPL (v2+)]
 A             kdebase/workspace/plasma/desktop/shell/toolbox/paneltoolbox.cpp   kdelibs/plasma/private/paneltoolbox.cpp#1157178 [License: LGPL (v2+)]
 A             kdebase/workspace/plasma/desktop/shell/toolbox/paneltoolbox_p.h   kdelibs/plasma/private/paneltoolbox_p.h#1157178 [License: LGPL (v2+)]
 A             kdebase/workspace/plasma/desktop/shell/toolbox/plasma-toolbox-desktoptoolbox.desktop  
 A             kdebase/workspace/plasma/desktop/shell/toolbox/plasma-toolbox-paneltoolbox.desktop  
 M  +0 -3      kdelibs/plasma/CMakeLists.txt  
 M  +13 -0     kdelibs/plasma/abstracttoolbox.cpp  
 M  +34 -1     kdelibs/plasma/abstracttoolbox.h  
 M  +23 -66    kdelibs/plasma/containment.cpp  
 D             kdelibs/plasma/private/desktoptoolbox.cpp  
 D             kdelibs/plasma/private/desktoptoolbox_p.h  
 D             kdelibs/plasma/private/internaltoolbox.cpp  
 D             kdelibs/plasma/private/internaltoolbox_p.h  
 D             kdelibs/plasma/private/paneltoolbox.cpp  
 D             kdelibs/plasma/private/paneltoolbox_p.h  


--- trunk/KDE/kdebase/workspace/plasma/desktop/shell/CMakeLists.txt #1157536:1157537
@@ -1,6 +1,7 @@
 include_directories(${KDEBASE_WORKSPACE_SOURCE_DIR}/libs ${KDEBASE_WORKSPACE_SOURCE_DIR}/libs/plasmagenericshell ${KDEBASE_WORKSPACE_SOURCE_DIR}/plasma/shells/common ${KDEBASE_WORKSPACE_SOURCE_DIR}/plasma/desktop/shell/scripting/ ${KDEBASE_WORKSPACE_SOURCE_DIR}/libs/kephal)
 
 add_subdirectory(configupdates)
+add_subdirectory(toolbox)
 
 set(activitymanager_SRCS
     activitymanager/activitymanager.cpp
--- trunk/KDE/kdebase/workspace/plasma/desktop/shell/desktopcorona.cpp #1157536:1157537
@@ -74,6 +74,9 @@
 
 void DesktopCorona::init()
 {
+    setPreferredToolBoxPlugin(Plasma::Containment::DesktopContainment, "org.kde.desktoptoolbox");
+    setPreferredToolBoxPlugin(Plasma::Containment::PanelContainment, "org.kde.paneltoolbox");
+
     kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "DesktopCorona init start" << "(line:" << __LINE__ << ")";
     Kephal::Screens *screens = Kephal::Screens::self();
     connect(screens, SIGNAL(screenAdded(Kephal::Screen *)), SLOT(screenAdded(Kephal::Screen *)));
--- trunk/KDE/kdelibs/plasma/CMakeLists.txt #1157536:1157537
@@ -119,14 +119,12 @@
     private/dataengineconsumer.cpp
     private/dataengineservice.cpp
     private/denyallauthorization.cpp
-    private/desktoptoolbox.cpp
     private/extenderapplet.cpp
     private/extenderitemmimedata.cpp
     private/focusindicator.cpp
     private/getsource.cpp
     private/nativetabbar.cpp
     private/packages.cpp
-    private/paneltoolbox.cpp
     private/pinpairingauthorization.cpp
     private/pinpairingdialog.cpp
     private/plasmoidservice.cpp
@@ -138,7 +136,6 @@
     private/storage.cpp
     private/style.cpp
     private/trustedonlyauthorization.cpp
-    private/internaltoolbox.cpp
     private/tooltip.cpp
     private/wallpaperrenderthread.cpp
     private/windowpreview.cpp
--- trunk/KDE/kdelibs/plasma/abstracttoolbox.cpp #1157536:1157537
@@ -81,6 +81,19 @@
     return d->containment;
 }
 
+void AbstractToolBox::restore(const KConfigGroup &group)
+{
+    Q_UNUSED(group)
+}
+
+void AbstractToolBox::save(const KConfigGroup &group)
+{
+    Q_UNUSED(group)
+}
+
+void AbstractToolBox::reposition()
+{}
+
 } // plasma namespace
 
 #include "abstracttoolbox.moc"
--- trunk/KDE/kdelibs/plasma/abstracttoolbox.h #1157536:1157537
@@ -27,6 +27,8 @@
 
 class QAction;
 
+class KConfigGroup;
+
 namespace Plasma
 {
 
@@ -77,10 +79,41 @@
     virtual bool isShowing() const = 0;
     virtual void setShowing(const bool show) = 0;
 
+public Q_SLOTS:
+    //FIXME for KDE5: those should become virtuals
+    /**
+     * Restore the ToolBox settings
+     * It has to be reimplemented in toolboxes that need it
+     * @since 4.6
+     */
+    void restore(const KConfigGroup &group);
+
+    /**
+     * Save the ToolBox settings
+     * It has to be reimplemented in toolboxes that need it
+     * @since 4.6
+     */
+    void save(const KConfigGroup &group);
+
+    /**
+     * Inform the ToolBox it has to reposition itlself
+     * It has to be reimplemented in toolboxes that need it
+     * @since 4.6
+     */
+    void reposition();
+
 Q_SIGNALS:
+    /**
+     * Toolbox opened or closed
+     */
     void toggled();
-    void visibilityChanged(bool);
 
+    /**
+     * Toolbox opened or closed
+     * @param open tells if the toolbox opened or closed
+     */
+    void visibilityChanged(bool open);
+
 protected:
     Containment *containment() const;
 
--- trunk/KDE/kdelibs/plasma/containment.cpp #1157536:1157537
@@ -48,6 +48,7 @@
 #include "kio/job.h"
 #include "kio/scheduler.h"
 
+#include "abstracttoolbox.h"
 #include "animator.h"
 #include "context.h"
 #include "containmentactions.h"
@@ -64,10 +65,8 @@
 #include "private/applet_p.h"
 #include "private/applethandle_p.h"
 #include "private/containmentactionspluginsconfig_p.h"
-#include "private/desktoptoolbox_p.h"
 #include "private/extenderitemmimedata_p.h"
 #include "private/extenderapplet_p.h"
-#include "private/paneltoolbox_p.h"
 
 #include "plasma/plasma.h"
 #include "animations/animation.h"
@@ -204,7 +203,6 @@
             d->actions()->addAction("lock widgets", lockDesktopAction);
         }
     }
-
     if (d->type != PanelContainment && d->type != CustomPanelContainment) {
         if (corona()) {
             //FIXME this is just here because of the darn keyboard shortcut :/
@@ -219,15 +217,15 @@
             }
         }
 
-        if (d->type == DesktopContainment && d->toolBox) {
-            d->toolBox.data()->addTool(action("add widgets"));
+        if (d->type == DesktopContainment) {
+            addToolBoxAction(action("add widgets"));
 
             //TODO: do we need some way to allow this be overridden?
             //      it's always available because shells rely on this
             //      to offer their own custom configuration as well
             QAction *configureContainment = action("configure");
             if (configureContainment) {
-                d->toolBox.data()->addTool(configureContainment);
+                addToolBoxAction(configureContainment);
             }
         }
     }
@@ -365,11 +363,10 @@
     setWallpaper(group.readEntry("wallpaperplugin", defaultWallpaper),
                  group.readEntry("wallpaperpluginmode", defaultWallpaperMode));
 
-    InternalToolBox *internalToolBox = qobject_cast<InternalToolBox *>(d->toolBox.data());
-    if (internalToolBox) {
-        internalToolBox->restore(group);
-    }
 
+    QMetaObject::invokeMethod(d->toolBox.data(), "restore", Q_ARG(KConfigGroup, group));
+
+
     KConfigGroup cfg(&group, "ActionPlugins");
     kDebug() << cfg.keyList();
     if (cfg.exists()) {
@@ -420,11 +417,10 @@
     group.writeEntry("activity", d->context()->currentActivity());
     group.writeEntry("activityId", d->context()->currentActivityId());
 
-    InternalToolBox *toolBox = qobject_cast<InternalToolBox *>(d->toolBox.data());
-    if (toolBox) {
-        toolBox->save(group);
-    }
 
+    QMetaObject::invokeMethod(d->toolBox.data(), "save", Q_ARG(KConfigGroup, group));
+
+
     if (d->wallpaper) {
         group.writeEntry("wallpaperplugin", d->wallpaper->pluginName());
         group.writeEntry("wallpaperpluginmode", d->wallpaper->renderingMode().name());
@@ -831,17 +827,7 @@
         d->positionPanel(true);
     }
 
-    InternalToolBox *toolBox = qobject_cast<InternalToolBox *>(d->toolBox.data());
-    if (toolBox) {
-        if (d->formFactor == Vertical) {
-            toolBox->setCorner(InternalToolBox::Bottom);
-            //defaults to horizontal
-        } else if (QApplication::layoutDirection() == Qt::RightToLeft) {
-            toolBox->setCorner(InternalToolBox::Left);
-        } else {
-            toolBox->setCorner(InternalToolBox::Right);
-        }
-    }
+    QMetaObject::invokeMethod(d->toolBox.data(), "reposition");
 
     updateConstraints(Plasma::FormFactorConstraint);
 
@@ -1040,10 +1026,10 @@
     Containment *swapScreensWith(0);
     if (d->type == DesktopContainment || d->type >= CustomContainment) {
         // we want to listen to changes in work area if our screen changes
-        if (d->screen < 0 && newScreen > -1) {
-            connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolBox()), Qt::UniqueConnection);
-        } else if (newScreen < 0) {
-            disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), this, SLOT(positionToolBox()));
+        if (d->toolBox && d->screen < 0 && newScreen > -1) {
+            connect(KWindowSystem::self(), SIGNAL(workAreaChanged()), d->toolBox.data(), SLOT(positionToolBox()), Qt::UniqueConnection);
+        } else if (d->toolBox && newScreen < 0) {
+            disconnect(KWindowSystem::self(), SIGNAL(workAreaChanged()), d->toolBox.data(), SLOT(positionToolBox()));
         }
 
         if (newScreen > -1 && corona()) {
@@ -1797,8 +1783,10 @@
 void Containment::addToolBoxAction(QAction *action)
 {
     d->createToolBox();
+    if (d->toolBox) {
     d->toolBox.data()->addTool(action);
 }
+}
 
 void Containment::removeToolBoxAction(QAction *action)
 {
@@ -2185,41 +2173,21 @@
 void ContainmentPrivate::createToolBox()
 {
     if (!toolBox) {
-        if (isPanelContainment()) {
-            PanelToolBox *pt = new PanelToolBox(q);
-            toolBox = pt;
-            pt->setSize(KIconLoader::SizeSmallMedium);
-            pt->setIconSize(QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall));
-            if (q->immutability() != Mutable) {
-                pt->hide();
-            }
-        } else  {
-            DesktopToolBox *dt = new DesktopToolBox(q);
-            toolBox = dt;
-            dt->setSize(KIconLoader::SizeSmallMedium);
-            dt->setIconSize(QSize(KIconLoader::SizeSmall, KIconLoader::SizeSmall));
-        }
+        toolBox = Plasma::AbstractToolBox::load(q->corona()->preferredToolBoxPlugin(type), QVariantList(), q);
 
         if (toolBox) {
             QObject::connect(toolBox.data(), SIGNAL(toggled()), q, SIGNAL(toolBoxToggled()));
             QObject::connect(toolBox.data(), SIGNAL(toggled()), q, SLOT(updateToolBoxVisibility()));
-            InternalToolBox *internalToolBox = qobject_cast<InternalToolBox *>(toolBox.data());
-            if (internalToolBox) {
-                internalToolBox->restore();
+
                 positionToolBox();
             }
         }
     }
-}
 
 void ContainmentPrivate::positionToolBox()
 {
-    InternalToolBox *internalToolBox = qobject_cast<InternalToolBox *>(toolBox.data());
-    if (internalToolBox) {
-        internalToolBox->updateToolBox();
-        internalToolBox->reposition();
+    QMetaObject::invokeMethod(toolBox.data(), "reposition");
     }
-}
 
 void ContainmentPrivate::updateToolBoxVisibility()
 {
@@ -2259,7 +2227,7 @@
     if (constraints & Plasma::ImmutableConstraint) {
         //update actions
         checkRemoveAction();
-        bool unlocked = q->immutability() == Mutable;
+        const bool unlocked = q->immutability() == Mutable;
         q->setAcceptDrops(unlocked);
         q->enableAction("add widgets", unlocked);
 
@@ -2269,17 +2237,6 @@
             a->updateConstraints(ImmutableConstraint);
         }
 
-        if (toolBox) {
-            if (isPanelContainment()) {
-                toolBox.data()->setVisible(unlocked);
-            } else {
-                InternalToolBox *internalToolBox = qobject_cast<InternalToolBox *>(toolBox.data());
-                if (internalToolBox) {
-                    internalToolBox->setIsMovable(unlocked);
-                }
-            }
-        }
-
         //clear handles on lock
         if (!unlocked) {
             QMap<Applet*, AppletHandle*> h = handles;
@@ -2321,8 +2278,8 @@
         positionToolBox();
     }
 
-    if (toolBox && constraints & Plasma::StartupCompletedConstraint && type < Containment::CustomContainment) {
-        toolBox.data()->addTool(q->action("remove"));
+    if (constraints & Plasma::StartupCompletedConstraint && type < Containment::CustomContainment) {
+        q->addToolBoxAction(q->action("remove"));
         checkRemoveAction();
     }
 }


More information about the Plasma-devel mailing list