Rodrigo Belem has proposed merging lp:~rbelem/kdelibs/plasma-mobile-patches 
into lp:~kubuntu-members/kdelibs/ubuntu.

Requested reviews:
  Kubuntu Members (kubuntu-members)

For more details, see:
https://code.launchpad.net/~rbelem/kdelibs/plasma-mobile-patches/+merge/56249
-- 
https://code.launchpad.net/~rbelem/kdelibs/plasma-mobile-patches/+merge/56249
Your team Kubuntu Members is requested to review the proposed merge of 
lp:~rbelem/kdelibs/plasma-mobile-patches into 
lp:~kubuntu-members/kdelibs/ubuntu.
=== added file 'debian/patches/80-KIO-PreviewJob-Respect-the-enabled-plugins-from-Prev.patch'
--- debian/patches/80-KIO-PreviewJob-Respect-the-enabled-plugins-from-Prev.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/80-KIO-PreviewJob-Respect-the-enabled-plugins-from-Prev.patch	2011-04-04 19:37:24 +0000
@@ -0,0 +1,329 @@
+diff --git a/kio/kio/previewjob.cpp b/kio/kio/previewjob.cpp
+--- a/kio/kio/previewjob.cpp
++++ b/kio/kio/previewjob.cpp
+@@ -132,6 +132,7 @@ public:
+     Q_DECLARE_PUBLIC(PreviewJob)
+ };
+ 
++#ifndef KDE_NO_DEPRECATED
+ PreviewJob::PreviewJob( const KFileItemList &items, int width, int height,
+     int iconSize, int iconAlpha, bool scale, bool save,
+     const QStringList *enabledPlugins )
+@@ -142,7 +143,7 @@ PreviewJob::PreviewJob( const KFileItemList &items, int width, int height,
+     d->shmid = -1;
+     d->shmaddr = 0;
+     d->initialItems = items;
+-    d->enabledPlugins = enabledPlugins ? *enabledPlugins : QStringList();
++    d->enabledPlugins = enabledPlugins ? *enabledPlugins : availablePlugins();
+     d->width = width;
+     d->height = height ? height : width;
+     d->cacheWidth = d->width;
+@@ -152,7 +153,46 @@ PreviewJob::PreviewJob( const KFileItemList &items, int width, int height,
+     d->bScale = scale;
+     d->bSave = save && scale;
+     d->succeeded = false;
+-    d->thumbRoot = QDir::homePath() + "/.thumbnails/";
++    d->thumbRoot = QDir::homePath() + QLatin1String("/.thumbnails/");
++    d->ignoreMaximumSize = false;
++    d->sequenceIndex = 0;
++    d->maximumLocalSize = 0;
++    d->maximumRemoteSize = 0;
++
++    // Return to event loop first, determineNextFile() might delete this;
++    QTimer::singleShot(0, this, SLOT(startPreview()));
++}
++#endif
++
++PreviewJob::PreviewJob(const KFileItemList &items,
++                       const QSize &size,
++                       const QStringList *enabledPlugins) :
++    KIO::Job(*new PreviewJobPrivate)
++{
++    Q_D(PreviewJob);
++    d->tOrig = 0;
++    d->shmid = -1;
++    d->shmaddr = 0;
++    d->initialItems = items;
++    if (enabledPlugins) {
++        d->enabledPlugins = *enabledPlugins;
++    } else {
++        const KConfigGroup globalConfig(KGlobal::config(), "PreviewSettings");
++        d->enabledPlugins = globalConfig.readEntry("Plugins", QStringList()
++                                                              << "directorythumbnail"
++                                                              << "imagethumbnail"
++                                                              << "jpegthumbnail");
++    }
++    d->width = size.width();
++    d->height = size.height();
++    d->cacheWidth = d->width;
++    d->cacheHeight = d->height;
++    d->iconSize = 0;
++    d->iconAlpha = 70;
++    d->bScale = true;
++    d->bSave = true;
++    d->succeeded = false;
++    d->thumbRoot = QDir::homePath() + QLatin1String("/.thumbnails/");
+     d->ignoreMaximumSize = false;
+     d->sequenceIndex = 0;
+     d->maximumLocalSize = 0;
+@@ -173,6 +213,60 @@ PreviewJob::~PreviewJob()
+ #endif
+ }
+ 
++void PreviewJob::setOverlayIconSize(int size)
++{
++    Q_D(PreviewJob);
++    d->iconSize = size;
++}
++
++int PreviewJob::overlayIconSize() const
++{
++    Q_D(const PreviewJob);
++    return d->iconSize;
++}
++
++void PreviewJob::setOverlayIconAlpha(int alpha)
++{
++    Q_D(PreviewJob);
++    d->iconAlpha = qBound(0, alpha, 255);
++}
++
++int PreviewJob::overlayIconAlpha() const
++{
++    Q_D(const PreviewJob);
++    return d->iconAlpha;
++}
++
++void PreviewJob::setScaleType(ScaleType type)
++{
++    Q_D(PreviewJob);
++    switch (type) {
++    case Unscaled:
++        d->bScale = false;
++        d->bSave = false;
++        break;
++    case Scaled:
++        d->bScale = true;
++        d->bSave = false;
++        break;
++    case ScaledAndCached:
++        d->bScale = true;
++        d->bSave = true;
++        break;
++    default:
++        break;
++    }
++}
++
++PreviewJob::ScaleType PreviewJob::scaleType() const
++{
++    Q_D(const PreviewJob);
++    if (d->bScale) {
++        return d->bSave ? ScaledAndCached : Scaled;
++    }
++    return Unscaled;
++}
++
+ void PreviewJobPrivate::startPreview()
+ {
+     Q_Q(PreviewJob);
+@@ -181,7 +275,7 @@ void PreviewJobPrivate::startPreview()
+     QMap<QString, KService::Ptr> mimeMap;
+ 
+     for (KService::List::ConstIterator it = plugins.constBegin(); it != plugins.constEnd(); ++it) {
+-        if (enabledPlugins.isEmpty() || enabledPlugins.contains((*it)->desktopEntryName())) {
++        if (enabledPlugins.contains((*it)->desktopEntryName())) {
+             const QStringList mimeTypes = (*it)->serviceTypes();
+             for (QStringList::ConstIterator mt = mimeTypes.constBegin(); mt != mimeTypes.constEnd(); ++mt)
+                 mimeMap.insert(*mt, *it);
+@@ -629,6 +723,7 @@ QStringList PreviewJob::supportedMimeTypes()
+     return result;
+ }
+ 
++#ifndef KDE_NO_DEPRECATED
+ PreviewJob *KIO::filePreview( const KFileItemList &items, int width, int height,
+     int iconSize, int iconAlpha, bool scale, bool save,
+     const QStringList *enabledPlugins )
+@@ -649,6 +744,12 @@ PreviewJob *KIO::filePreview( const KUrl::List &items, int width, int height,
+     return new PreviewJob(fileItems, width, height, iconSize, iconAlpha,
+                           scale, save, enabledPlugins);
+ }
++#endif
++
++PreviewJob *KIO::filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins)
++{
++    return new PreviewJob(items, size, enabledPlugins);
++}
+ 
+ #ifndef KDE_NO_DEPRECATED
+ KIO::filesize_t PreviewJob::maximumFileSize()
+diff --git a/kio/kio/previewjob.h b/kio/kio/previewjob.h
+--- a/kio/kio/previewjob.h
++++ b/kio/kio/previewjob.h
+@@ -40,6 +40,30 @@ namespace KIO {
+         Q_OBJECT
+     public:
+         /**
++         * Specifies the type of scaling that is applied to the generated preview.
++         * @since 4.7
++         */
++        enum ScaleType {
++            /**
++             * The original size of the preview will be returned. Most previews
++             * will return a size of 256 x 256 pixels.
++             */
++            Unscaled,
++            /**
++             * The preview will be scaled to the size specified when constructing
++             * the PreviewJob. The aspect ratio will be kept.
++             */
++            Scaled,
++            /**
++             * The preview will be scaled to the size specified when constructing
++             * the PreviewJob. The result will be cached for later use. Per default
++             * ScaledAndCached is set.
++             */
++            ScaledAndCached
++        };
++
++#ifndef KDE_NO_DEPRECATED
++        /**
+          * Creates a new PreviewJob.
+          * @param items a list of files to create previews for
+          * @param width the desired width
+@@ -51,15 +75,83 @@ namespace KIO {
+          * @param scale if the image is to be scaled to the requested size or
+          * returned in its original size
+          * @param save if the image should be cached for later use
+-         * @param enabledPlugins if non-zero, this points to a list containing
+-         * the names of the plugins that may be used.
++         * @param enabledPlugins If non-zero, this points to a list containing
++         * the names of the plugins that may be used. If enabledPlugins is zero
++         * all available plugins are used.
++         *
++         * @deprecated Use PreviewJob(KFileItemList, QSize, QStringList) in combination
++         *             with the setter-methods instead. Note that the semantics of
++         *             \p enabledPlugins has been slightly changed.
++         */
++        KDE_DEPRECATED PreviewJob(const KFileItemList& items, int width, int height,
++                                  int iconSize, int iconAlpha, bool scale, bool save,
++                                  const QStringList *enabledPlugins);
++#endif
++
++        /**
++         * @param items          List of files to create previews for.
++         * @param size           Desired size of the preview.
++         * @param enabledPlugins If non-zero it defines the list of plugins that
++         *                       are considered for generating the preview. If
++         *                       enabledPlugins is zero the plugins specified in the
++         *                       KConfigGroup "PreviewSettings" are used.
++         * @since 4.7
+          */
+-        PreviewJob( const KFileItemList& items, int width, int height,
+-            int iconSize, int iconAlpha, bool scale, bool save,
+-            const QStringList *enabledPlugins );
++        PreviewJob(const KFileItemList &items,
++                   const QSize &size,
++                   const QStringList *enabledPlugins = 0);
++
+         virtual ~PreviewJob();
+ 
+         /**
++         * Sets the size of the MIME-type icon which overlays the preview. If zero
++         * is passed no overlay will be shown at all. The setting has no effect if
++         * the preview plugin that will be used does not use icon overlays. Per
++         * default the size is set to 0.
++         * @since 4.7
++         */
++        void setOverlayIconSize(int size);
++
++        /**
++         * @return The size of the MIME-type icon which overlays the preview.
++         * @see PreviewJob::setOverlayIconSize()
++         * @since 4.7
++         */
++        int overlayIconSize() const;
++
++        /**
++         * Sets the alpha-value for the MIME-type icon which overlays the preview.
++         * The alpha-value may range from 0 (= fully transparent) to 255 (= opaque).
++         * Per default the value is set to 70.
++         * @see PreviewJob::setOverlayIconSize()
++         * @since 4.7
++         */
++        void setOverlayIconAlpha(int alpha);
++
++        /**
++         * @return The alpha-value for the MIME-type icon which overlays the preview.
++         *         Per default 70 is returned.
++         * @see PreviewJob::setOverlayIconAlpha()
++         * @since 4.7
++         */
++        int overlayIconAlpha() const;
++
++        /**
++         * Sets the scale type for the generated preview. Per default
++         * PreviewJob::ScaledAndCached is set.
++         * @see PreviewJob::ScaleType
++         * @since 4.7
++         */
++        void setScaleType(ScaleType type);
++
++        /**
++         * @return The scale type for the generated preview.
++         * @see PreviewJob::ScaleType
++         * @since 4.7
++         */
++        ScaleType scaleType() const;
++
++        /**
+          * Removes an item from preview processing. Use this if you passed
+          * an item to filePreview and want to delete it now.
+          *
+@@ -142,6 +234,7 @@ namespace KIO {
+         Q_DECLARE_PRIVATE(PreviewJob)
+     };
+ 
++#ifndef KDE_NO_DEPRECATED
+     /**
+      * Creates a PreviewJob to generate or retrieve a preview image
+      * for the given URL.
+@@ -161,8 +254,11 @@ namespace KIO {
+      * the names of the plugins that may be used.
+      * @return the new PreviewJob
+      * @see PreviewJob::availablePlugins()
++     * @deprecated Use KIO::filePreview(KFileItemList, QSize, QStringList) in combination
++     *             with the setter-methods instead. Note that the semantics of
++     *             \p enabledPlugins has been slightly changed.
+      */
+-KIO_EXPORT PreviewJob *filePreview( const KFileItemList &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 ); // KDE5: use enums instead of bool scale + bool save
++    KIO_EXPORT_DEPRECATED PreviewJob *filePreview( const KFileItemList &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 ); // KDE5: use enums instead of bool scale + bool save
+ 
+     /**
+      * Creates a PreviewJob to generate or retrieve a preview image
+@@ -183,8 +279,24 @@ KIO_EXPORT PreviewJob *filePreview( const KFileItemList &items, int width, int h
+      * the names of the plugins that may be used.
+      * @return the new PreviewJob
+      * @see PreviewJob::availablePlugins()
++     * @deprecated Use KIO::filePreview(KFileItemList, QSize, QStringList) in combination
++     *             with the setter-methods instead. Note that the semantics of
++     *             \p enabledPlugins has been slightly changed.
++     */
++    KIO_EXPORT_DEPRECATED PreviewJob *filePreview( const KUrl::List &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 );
++#endif
++
++    /**
++     * Creates a PreviewJob to generate a preview image for the given items.
++     * @param items          List of files to create previews for.
++     * @param size           Desired size of the preview.
++     * @param enabledPlugins If non-zero it defines the list of plugins that
++     *                       are considered for generating the preview. If
++     *                       enabledPlugins is zero the plugins specified in the
++     *                       KConfigGroup "PreviewSettings" are used.
++     * @since 4.7
+      */
+-    KIO_EXPORT PreviewJob *filePreview( const KUrl::List &items, int width, int height = 0, int iconSize = 0, int iconAlpha = 70, bool scale = true, bool save = true, const QStringList *enabledPlugins = 0 );
++    KIO_EXPORT PreviewJob *filePreview(const KFileItemList &items, const QSize &size, const QStringList *enabledPlugins = 0);
+ }
+ 
+ #endif

=== added file 'debian/patches/81-give-Corona-a-proper-private-header-in-private.patch'
--- debian/patches/81-give-Corona-a-proper-private-header-in-private.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/81-give-Corona-a-proper-private-header-in-private.patch	2011-04-04 19:37:24 +0000
@@ -0,0 +1,760 @@
+diff --git a/plasma/corona.cpp b/plasma/corona.cpp
+--- a/plasma/corona.cpp
++++ b/plasma/corona.cpp
+@@ -1,6 +1,6 @@
+ /*
+  *   Copyright 2007 Matt Broadstone <[email protected]>
+- *   Copyright 2007 Aaron Seigo <[email protected]>
++ *   Copyright 2007-2011 Aaron Seigo <[email protected]>
+  *   Copyright 2007 Riccardo Iaconelli <[email protected]>
+  *   Copyright (c) 2009 Chani Armitage <[email protected]>
+  *
+@@ -21,6 +21,7 @@
+  */
+ 
+ #include "corona.h"
++#include "private/corona_p.h"
+ 
+ #include <QApplication>
+ #include <QDesktopWidget>
+@@ -34,7 +35,6 @@
+ #include <cmath>
+ 
+ #include <kaction.h>
+-#include <kactioncollection.h>
+ #include <kdebug.h>
+ #include <kglobal.h>
+ #include <klocale.h>
+@@ -58,240 +58,6 @@ using namespace Plasma;
+ namespace Plasma
+ {
+ 
+-// constant controlling how long between requesting a configuration sync
+-// and one happening should occur. currently 10 seconds
+-const int CONFIG_SYNC_TIMEOUT = 10000;
+-
+-class CoronaPrivate
+-{
+-public:
+-    CoronaPrivate(Corona *corona)
+-        : q(corona),
+-          immutability(Mutable),
+-          mimetype("text/x-plasmoidservicename"),
+-          config(0),
+-          actions(corona)
+-    {
+-        if (KGlobal::hasMainComponent()) {
+-            configName = KGlobal::mainComponent().componentName() + "-appletsrc";
+-        } else {
+-            configName = "plasma-appletsrc";
+-        }
+-    }
+-
+-    ~CoronaPrivate()
+-    {
+-        qDeleteAll(containments);
+-    }
+-
+-    void init()
+-    {
+-        q->setStickyFocus(true);
+-        configSyncTimer.setSingleShot(true);
+-        QObject::connect(&configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
+-
+-        //some common actions
+-        actions.setConfigGroup("Shortcuts");
+-
+-        KAction *lockAction = actions.addAction("lock widgets");
+-        QObject::connect(lockAction, SIGNAL(triggered(bool)), q, SLOT(toggleImmutability()));
+-        lockAction->setText(i18n("Lock Widgets"));
+-        lockAction->setAutoRepeat(true);
+-        lockAction->setIcon(KIcon("object-locked"));
+-        lockAction->setData(AbstractToolBox::ControlTool);
+-        lockAction->setShortcut(KShortcut("alt+d, l"));
+-        lockAction->setShortcutContext(Qt::ApplicationShortcut);
+-
+-        //FIXME this doesn't really belong here. desktop KCM maybe?
+-        //but should the shortcuts be per-app or really-global?
+-        //I don't know how to make kactioncollections use plasmarc
+-        KAction *action = actions.addAction("configure shortcuts");
+-        QObject::connect(action, SIGNAL(triggered()), q, SLOT(showShortcutConfig()));
+-        action->setText(i18n("Shortcut Settings"));
+-        action->setIcon(KIcon("configure-shortcuts"));
+-        action->setAutoRepeat(false);
+-        action->setData(AbstractToolBox::ConfigureTool);
+-        //action->setShortcut(KShortcut("ctrl+h"));
+-        action->setShortcutContext(Qt::ApplicationShortcut);
+-
+-        actions.readSettings();
+-
+-        //fake containment/applet actions
+-        KActionCollection *aActions = AppletPrivate::defaultActions(q);
+-        KActionCollection *cActions = AppletPrivate::defaultActions(q); //containment has to start with applet stuff
+-        ContainmentPrivate::addDefaultActions(cActions); //now it's really containment
+-        //grab the current stuff
+-        cActions->readSettings();
+-        aActions->readSettings();
+-
+-        shortcutsDlg.setModal(false);
+-        shortcutsDlg.addCollection(aActions);
+-        shortcutsDlg.addCollection(cActions);
+-
+-        QObject::connect(&shortcutsDlg, SIGNAL(saved()), q, SIGNAL(shortcutsChanged()));
+-    }
+-
+-    void showShortcutConfig()
+-    {
+-        //show a kshortcutsdialog with the actions
+-        shortcutsDlg.configure();
+-    }
+-
+-    void toggleImmutability()
+-    {
+-        if (immutability == Mutable) {
+-            q->setImmutability(UserImmutable);
+-        } else {
+-            q->setImmutability(Mutable);
+-        }
+-    }
+-
+-    void saveLayout(KSharedConfigPtr cg) const
+-    {
+-        KConfigGroup containmentsGroup(cg, "Containments");
+-        foreach (const Containment *containment, containments) {
+-            QString cid = QString::number(containment->id());
+-            KConfigGroup containmentConfig(&containmentsGroup, cid);
+-            containment->save(containmentConfig);
+-        }
+-    }
+-
+-    void updateContainmentImmutability()
+-    {
+-        foreach (Containment *c, containments) {
+-            // we need to tell each containment that immutability has been altered
+-            c->updateConstraints(ImmutableConstraint);
+-        }
+-    }
+-
+-    void containmentDestroyed(QObject *obj)
+-    {
+-        // we do a static_cast here since it really isn't an Containment by this
+-        // point anymore since we are in the qobject dtor. we don't actually
+-        // try and do anything with it, we just need the value of the pointer
+-        // so this unsafe looking code is actually just fine.
+-        Containment* containment = static_cast<Plasma::Containment*>(obj);
+-        int index = containments.indexOf(containment);
+-
+-        if (index > -1) {
+-            containments.removeAt(index);
+-            q->requestConfigSync();
+-        }
+-    }
+-
+-    void syncConfig()
+-    {
+-        q->config()->sync();
+-        emit q->configSynced();
+-    }
+-
+-    Containment *addContainment(const QString &name, const QVariantList &args,
+-                                uint id, bool delayedInit)
+-    {
+-        QString pluginName = name;
+-        Containment *containment = 0;
+-        Applet *applet = 0;
+-
+-        //kDebug() << "Loading" << name << args << id;
+-
+-        if (pluginName.isEmpty() || pluginName == "default") {
+-            // default to the desktop containment
+-            pluginName = "desktop";
+-        }
+-
+-        bool loadingNull = pluginName == "null";
+-        if (!loadingNull) {
+-            applet = Applet::load(pluginName, id, args);
+-            containment = dynamic_cast<Containment*>(applet);
+-        }
+-
+-        if (!containment) {
+-            if (!loadingNull) {
+-                kDebug() << "loading of containment" << name << "failed.";
+-            }
+-
+-            // in case we got a non-Containment from Applet::loadApplet or
+-            // a null containment was requested
+-            if (applet) {
+-                // the applet probably doesn't know what's hit it, so let's pretend it can be
+-                // initialized to make assumptions in the applet's dtor safer
+-                q->addItem(applet);
+-                applet->init();
+-                q->removeItem(applet);
+-                delete applet;
+-            }
+-            applet = containment = new Containment(0, 0, id);
+-
+-            if (loadingNull) {
+-                containment->setDrawWallpaper(false);
+-            } else {
+-                containment->setFailedToLaunch(false);
+-            }
+-
+-            // we want to provide something and don't care about the failure to launch
+-            containment->setFormFactor(Plasma::Planar);
+-        }
+-
+-        // if this is a new containment, we need to ensure that there are no stale
+-        // configuration data around
+-        if (id == 0) {
+-            KConfigGroup conf(q->config(), "Containments");
+-            conf = KConfigGroup(&conf, QString::number(containment->id()));
+-            conf.deleteGroup();
+-        }
+-
+-        applet->d->isContainment = true;
+-        containment->setPos(containment->d->preferredPos(q));
+-        q->addItem(containment);
+-        applet->d->setIsContainment(true, true);
+-        containments.append(containment);
+-
+-        if (!delayedInit) {
+-            containment->init();
+-            KConfigGroup cg = containment->config();
+-            containment->restore(cg);
+-            containment->updateConstraints(Plasma::StartupCompletedConstraint);
+-            containment->save(cg);
+-            q->requestConfigSync();
+-            containment->flushPendingConstraintsEvents();
+-        }
+-
+-        QObject::connect(containment, SIGNAL(destroyed(QObject*)),
+-                         q, SLOT(containmentDestroyed(QObject*)));
+-        QObject::connect(containment, SIGNAL(configNeedsSaving()),
+-                         q, SLOT(requestConfigSync()));
+-        QObject::connect(containment, SIGNAL(releaseVisualFocus()),
+-                         q, SIGNAL(releaseVisualFocus()));
+-        QObject::connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)),
+-                         q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
+-
+-        if (!delayedInit) {
+-            emit q->containmentAdded(containment);
+-        }
+-
+-        return containment;
+-    }
+-
+-    void offscreenWidgetDestroyed(QObject *);
+-    QList<Plasma::Containment *> importLayout(const KConfigBase &conf, bool mergeConfig);
+-
+-    static bool s_positioningContainments;
+-
+-    Corona *q;
+-    ImmutabilityType immutability;
+-    QString mimetype;
+-    QString configName;
+-    KSharedConfigPtr config;
+-    QTimer configSyncTimer;
+-    QList<Containment*> containments;
+-    QHash<uint, QGraphicsWidget*> offscreenWidgets;
+-    KActionCollection actions;
+-    KShortcutsDialog shortcutsDlg;
+-    QMap<Containment::Type, ContainmentActionsPluginsConfig> containmentActionsDefaults;
+-    QWeakPointer<AbstractDialogManager>dialogManager;
+-    QHash<Containment::Type, QString> toolBoxPlugins;
+-};
+-
+ bool CoronaPrivate::s_positioningContainments = false;
+ 
+ Corona::Corona(QObject *parent)
+@@ -374,6 +140,10 @@ void Corona::exportLayout(KConfigGroup &config, QList<Containment*> containments
+ 
+ void Corona::requestConfigSync()
+ {
++    // constant controlling how long between requesting a configuration sync
++    // and one happening should occur. currently 10 seconds
++    static const int CONFIG_SYNC_TIMEOUT = 10000;
++
+     // TODO: should we check into our immutability before doing this?
+ 
+     //NOTE: this is a pretty simplistic model: we simply save no more than CONFIG_SYNC_TIMEOUT
+@@ -506,71 +276,6 @@ QList<Plasma::Containment *> Corona::importLayout(const KConfigBase &conf)
+ }
+ #endif
+ 
+-QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigBase &conf, bool mergeConfig)
+-{
+-    if (const KConfigGroup *group = dynamic_cast<const KConfigGroup *>(&conf)) {
+-        if (!group->isValid()) {
+-            return QList<Containment *>();
+-        }
+-    }
+-
+-    QList<Plasma::Containment *> newContainments;
+-    QSet<uint> containmentsIds;
+-
+-    foreach (Containment *containment, containments) {
+-        containmentsIds.insert(containment->id());
+-    }
+-
+-    KConfigGroup containmentsGroup(&conf, "Containments");
+-
+-    foreach (const QString &group, containmentsGroup.groupList()) {
+-        KConfigGroup containmentConfig(&containmentsGroup, group);
+-
+-        if (containmentConfig.entryMap().isEmpty()) {
+-            continue;
+-        }
+-
+-        uint cid = group.toUInt();
+-        if (containmentsIds.contains(cid)) {
+-            cid = ++AppletPrivate::s_maxAppletId;
+-        } else if (cid > AppletPrivate::s_maxAppletId) {
+-            AppletPrivate::s_maxAppletId = cid;
+-        }
+-
+-        if (mergeConfig) {
+-            KConfigGroup realConf(q->config(), "Containments");
+-            realConf = KConfigGroup(&realConf, QString::number(cid));
+-            // in case something was there before us
+-            realConf.deleteGroup();
+-            containmentConfig.copyTo(&realConf);
+-        }
+-
+-        //kDebug() << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
+-        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin", QString());
+-        Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, true);
+-        if (!c) {
+-            continue;
+-        }
+-
+-        newContainments.append(c);
+-        containmentsIds.insert(c->id());
+-
+-        c->init();
+-        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Init Containment" << c->pluginName();
+-        c->restore(containmentConfig);
+-        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Restored Containment" << c->pluginName();
+-    }
+-
+-    foreach (Containment *containment, newContainments) {
+-        containment->updateConstraints(Plasma::StartupCompletedConstraint);
+-        containment->d->initApplets();
+-        emit q->containmentAdded(containment);
+-        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Containment" << containment->name();
+-    }
+-
+-    return newContainments;
+-}
+-
+ Containment *Corona::containmentForScreen(int screen, int desktop) const
+ {
+     foreach (Containment *containment, d->containments) {
+@@ -602,6 +307,7 @@ Containment *Corona::containmentForScreen(int screen, int desktop,
+ 
+     return containment;
+ }
++
+ QList<Containment*> Corona::containments() const
+ {
+     return d->containments;
+@@ -989,13 +695,29 @@ void Corona::enableAction(const QString &name, bool enable)
+ 
+ void Corona::updateShortcuts()
+ {
+-    d->actions.readSettings();
+-    d->shortcutsDlg.addCollection(&d->actions);
++    QMutableListIterator<QWeakPointer<KActionCollection> > it(d->actionCollections);
++    while (it.hasNext()) {
++        it.next();
++        KActionCollection *collection = it.value().data();
++        if (!collection) {
++            // get rid of KActionCollections that have been deleted behind our backs
++            it.remove();
++            continue;
++        }
++
++        collection->readSettings();
++        if (d->shortcutsDlg) {
++            d->shortcutsDlg.data()->addCollection(collection);
++        }
++    }
+ }
+ 
+ void Corona::addShortcuts(KActionCollection *newShortcuts)
+ {
+-    d->shortcutsDlg.addCollection(newShortcuts);
++    d->actionCollections << newShortcuts;
++    if (d->shortcutsDlg) {
++        d->shortcutsDlg.data()->addCollection(newShortcuts);
++    }
+ }
+ 
+ void Corona::setContainmentActionsDefaults(Containment::Type containmentType, const ContainmentActionsPluginsConfig &config)
+@@ -1018,6 +740,292 @@ AbstractDialogManager *Corona::dialogManager()
+     return d->dialogManager.data();
+ }
+ 
++CoronaPrivate::CoronaPrivate(Corona *corona)
++    : q(corona),
++      immutability(Mutable),
++      mimetype("text/x-plasmoidservicename"),
++      config(0),
++      actions(corona)
++{
++    if (KGlobal::hasMainComponent()) {
++        configName = KGlobal::mainComponent().componentName() + "-appletsrc";
++    } else {
++        configName = "plasma-appletsrc";
++    }
++}
++
++CoronaPrivate::~CoronaPrivate()
++{
++    qDeleteAll(containments);
++}
++
++void CoronaPrivate::init()
++{
++    q->setStickyFocus(true);
++    configSyncTimer.setSingleShot(true);
++    QObject::connect(&configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
++
++    //some common actions
++    actions.setConfigGroup("Shortcuts");
++
++    KAction *lockAction = actions.addAction("lock widgets");
++    QObject::connect(lockAction, SIGNAL(triggered(bool)), q, SLOT(toggleImmutability()));
++    lockAction->setText(i18n("Lock Widgets"));
++    lockAction->setAutoRepeat(true);
++    lockAction->setIcon(KIcon("object-locked"));
++    lockAction->setData(AbstractToolBox::ControlTool);
++    lockAction->setShortcut(KShortcut("alt+d, l"));
++    lockAction->setShortcutContext(Qt::ApplicationShortcut);
++
++    //FIXME this doesn't really belong here. desktop KCM maybe?
++    //but should the shortcuts be per-app or really-global?
++    //I don't know how to make kactioncollections use plasmarc
++    KAction *action = actions.addAction("configure shortcuts");
++    QObject::connect(action, SIGNAL(triggered()), q, SLOT(showShortcutConfig()));
++    action->setText(i18n("Shortcut Settings"));
++    action->setIcon(KIcon("configure-shortcuts"));
++    action->setAutoRepeat(false);
++    action->setData(AbstractToolBox::ConfigureTool);
++    //action->setShortcut(KShortcut("ctrl+h"));
++    action->setShortcutContext(Qt::ApplicationShortcut);
++
++    //fake containment/applet actions
++    KActionCollection *containmentActions = AppletPrivate::defaultActions(q); //containment has to start with applet stuff
++    ContainmentPrivate::addDefaultActions(containmentActions); //now it's really containment
++    actionCollections << &actions << AppletPrivate::defaultActions(q) << containmentActions;
++    q->updateShortcuts();
++}
++
++void CoronaPrivate::showShortcutConfig()
++{
++    //show a kshortcutsdialog with the actions
++    KShortcutsDialog *dlg = shortcutsDlg.data();
++    if (!dlg) {
++        dlg = new KShortcutsDialog();
++        dlg->setModal(false);
++        dlg->setAttribute(Qt::WA_DeleteOnClose, true);
++        QObject::connect(dlg, SIGNAL(saved()), q, SIGNAL(shortcutsChanged()));
++
++        dlg->addCollection(&actions);
++        QMutableListIterator<QWeakPointer<KActionCollection> > it(actionCollections);
++        while (it.hasNext()) {
++            it.next();
++            KActionCollection *collection = it.value().data();
++            if (!collection) {
++                // get rid of KActionCollections that have been deleted behind our backs
++                it.remove();
++                continue;
++            }
++
++            dlg->addCollection(collection);
++        }
++    }
++
++    KWindowSystem::setOnDesktop(dlg->winId(), KWindowSystem::currentDesktop());
++    dlg->configure();
++    dlg->raise();
++}
++
++void CoronaPrivate::toggleImmutability()
++{
++    if (immutability == Mutable) {
++        q->setImmutability(UserImmutable);
++    } else {
++        q->setImmutability(Mutable);
++    }
++}
++
++void CoronaPrivate::saveLayout(KSharedConfigPtr cg) const
++{
++    KConfigGroup containmentsGroup(cg, "Containments");
++    foreach (const Containment *containment, containments) {
++        QString cid = QString::number(containment->id());
++        KConfigGroup containmentConfig(&containmentsGroup, cid);
++        containment->save(containmentConfig);
++    }
++}
++
++void CoronaPrivate::updateContainmentImmutability()
++{
++    foreach (Containment *c, containments) {
++        // we need to tell each containment that immutability has been altered
++        c->updateConstraints(ImmutableConstraint);
++    }
++}
++
++void CoronaPrivate::containmentDestroyed(QObject *obj)
++{
++        // we do a static_cast here since it really isn't an Containment by this
++        // point anymore since we are in the qobject dtor. we don't actually
++        // try and do anything with it, we just need the value of the pointer
++        // so this unsafe looking code is actually just fine.
++        Containment* containment = static_cast<Plasma::Containment*>(obj);
++        int index = containments.indexOf(containment);
++
++        if (index > -1) {
++            containments.removeAt(index);
++            q->requestConfigSync();
++        }
++    }
++
++void CoronaPrivate::syncConfig()
++{
++    q->config()->sync();
++    emit q->configSynced();
++}
++
++Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args,
++        uint id, bool delayedInit)
++{
++    QString pluginName = name;
++    Containment *containment = 0;
++    Applet *applet = 0;
++
++    //kDebug() << "Loading" << name << args << id;
++
++    if (pluginName.isEmpty() || pluginName == "default") {
++        // default to the desktop containment
++        pluginName = "desktop";
++    }
++
++    bool loadingNull = pluginName == "null";
++    if (!loadingNull) {
++        applet = Applet::load(pluginName, id, args);
++        containment = dynamic_cast<Containment*>(applet);
++    }
++
++    if (!containment) {
++        if (!loadingNull) {
++            kDebug() << "loading of containment" << name << "failed.";
++        }
++
++        // in case we got a non-Containment from Applet::loadApplet or
++        // a null containment was requested
++        if (applet) {
++            // the applet probably doesn't know what's hit it, so let's pretend it can be
++            // initialized to make assumptions in the applet's dtor safer
++            q->addItem(applet);
++            applet->init();
++            q->removeItem(applet);
++            delete applet;
++        }
++        applet = containment = new Containment(0, 0, id);
++
++        if (loadingNull) {
++            containment->setDrawWallpaper(false);
++        } else {
++            containment->setFailedToLaunch(false);
++        }
++
++        // we want to provide something and don't care about the failure to launch
++        containment->setFormFactor(Plasma::Planar);
++    }
++
++    // if this is a new containment, we need to ensure that there are no stale
++    // configuration data around
++    if (id == 0) {
++        KConfigGroup conf(q->config(), "Containments");
++        conf = KConfigGroup(&conf, QString::number(containment->id()));
++        conf.deleteGroup();
++    }
++
++    applet->d->isContainment = true;
++    containment->setPos(containment->d->preferredPos(q));
++    q->addItem(containment);
++    applet->d->setIsContainment(true, true);
++    containments.append(containment);
++
++    if (!delayedInit) {
++        containment->init();
++        KConfigGroup cg = containment->config();
++        containment->restore(cg);
++        containment->updateConstraints(Plasma::StartupCompletedConstraint);
++        containment->save(cg);
++        q->requestConfigSync();
++        containment->flushPendingConstraintsEvents();
++    }
++
++    QObject::connect(containment, SIGNAL(destroyed(QObject*)),
++            q, SLOT(containmentDestroyed(QObject*)));
++    QObject::connect(containment, SIGNAL(configNeedsSaving()),
++            q, SLOT(requestConfigSync()));
++    QObject::connect(containment, SIGNAL(releaseVisualFocus()),
++            q, SIGNAL(releaseVisualFocus()));
++    QObject::connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)),
++            q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
++
++    if (!delayedInit) {
++        emit q->containmentAdded(containment);
++    }
++
++    return containment;
++}
++
++QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigBase &conf, bool mergeConfig)
++{
++    if (const KConfigGroup *group = dynamic_cast<const KConfigGroup *>(&conf)) {
++        if (!group->isValid()) {
++            return QList<Containment *>();
++        }
++    }
++
++    QList<Plasma::Containment *> newContainments;
++    QSet<uint> containmentsIds;
++
++    foreach (Containment *containment, containments) {
++        containmentsIds.insert(containment->id());
++    }
++
++    KConfigGroup containmentsGroup(&conf, "Containments");
++
++    foreach (const QString &group, containmentsGroup.groupList()) {
++        KConfigGroup containmentConfig(&containmentsGroup, group);
++
++        if (containmentConfig.entryMap().isEmpty()) {
++            continue;
++        }
++
++        uint cid = group.toUInt();
++        if (containmentsIds.contains(cid)) {
++            cid = ++AppletPrivate::s_maxAppletId;
++        } else if (cid > AppletPrivate::s_maxAppletId) {
++            AppletPrivate::s_maxAppletId = cid;
++        }
++
++        if (mergeConfig) {
++            KConfigGroup realConf(q->config(), "Containments");
++            realConf = KConfigGroup(&realConf, QString::number(cid));
++            // in case something was there before us
++            realConf.deleteGroup();
++            containmentConfig.copyTo(&realConf);
++        }
++
++        //kDebug() << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
++        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Adding Containment" << containmentConfig.readEntry("plugin", QString());
++        Containment *c = addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(), cid, true);
++        if (!c) {
++            continue;
++        }
++
++        newContainments.append(c);
++        containmentsIds.insert(c->id());
++
++        c->init();
++        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Init Containment" << c->pluginName();
++        c->restore(containmentConfig);
++        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Restored Containment" << c->pluginName();
++    }
++
++    foreach (Containment *containment, newContainments) {
++        containment->updateConstraints(Plasma::StartupCompletedConstraint);
++        containment->d->initApplets();
++        emit q->containmentAdded(containment);
++        kDebug() << "!!{} STARTUP TIME" << QTime().msecsTo(QTime::currentTime()) << "Containment" << containment->name();
++    }
++
++    return newContainments;
++}
++
+ } // namespace Plasma
+ 
+ #include "corona.moc"
+diff --git a/plasma/private/corona_p.h b/plasma/private/corona_p.h
+--- /dev/null
++++ b/plasma/private/corona_p.h
+@@ -0,0 +1,71 @@
++/*
++ *   Copyright 2007-2011 Aaron Seigo <[email protected]>
++ *
++ *   This program is free software; you can redistribute it and/or modify
++ *   it under the terms of the GNU Library General Public License as
++ *   published by the Free Software Foundation; either version 2, or
++ *   (at your option) any later version.
++ *
++ *   This program is distributed in the hope that it will be useful,
++ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
++ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ *   GNU General Public License for more details
++ *
++ *   You should have received a copy of the GNU Library General Public
++ *   License along with this program; if not, write to the
++ *   Free Software Foundation, Inc.,
++ *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
++ */
++
++#ifndef PLASMA_CORONA_P_H
++#define PLASMA_CORONA_P_H
++
++#include <QTimer>
++
++#include <kactioncollection.h>
++
++class KShortcutsDialog;
++
++namespace Plasma
++{
++
++class Containment;
++
++class CoronaPrivate
++{
++public:
++    CoronaPrivate(Corona *corona);
++    ~CoronaPrivate();
++
++    void init();
++    void showShortcutConfig();
++    void toggleImmutability();
++    void saveLayout(KSharedConfigPtr cg) const;
++    void updateContainmentImmutability();
++    void containmentDestroyed(QObject *obj);
++    void syncConfig();
++    Containment *addContainment(const QString &name, const QVariantList &args, uint id, bool delayedInit);
++    void offscreenWidgetDestroyed(QObject *);
++    QList<Plasma::Containment *> importLayout(const KConfigBase &conf, bool mergeConfig);
++
++    static bool s_positioningContainments;
++
++    Corona *q;
++    ImmutabilityType immutability;
++    QString mimetype;
++    QString configName;
++    KSharedConfigPtr config;
++    QTimer configSyncTimer;
++    QList<Containment*> containments;
++    QHash<uint, QGraphicsWidget*> offscreenWidgets;
++    KActionCollection actions;
++    QMap<Containment::Type, ContainmentActionsPluginsConfig> containmentActionsDefaults;
++    QWeakPointer<KShortcutsDialog> shortcutsDlg;
++    QWeakPointer<AbstractDialogManager> dialogManager;
++    QHash<Containment::Type, QString> toolBoxPlugins;
++    QList<QWeakPointer<KActionCollection> > actionCollections;
++};
++
++}
++
++#endif

=== added file 'debian/patches/82-FEATURE-configurable-default-containment-plugin-name.patch'
--- debian/patches/82-FEATURE-configurable-default-containment-plugin-name.patch	1970-01-01 00:00:00 +0000
+++ debian/patches/82-FEATURE-configurable-default-containment-plugin-name.patch	2011-04-04 19:37:24 +0000
@@ -0,0 +1,92 @@
+diff --git a/plasma/corona.cpp b/plasma/corona.cpp
+--- a/plasma/corona.cpp
++++ b/plasma/corona.cpp
+@@ -92,6 +92,20 @@ QString Corona::appletMimeType()
+     return d->mimetype;
+ }
+ 
++void Corona::setDefaultContainmentPlugin(const QString &name)
++{
++    // we could check if it is in:
++    // Containment::listContainments().contains(name) ||
++    // Containment::listContainments(QString(), KGlobal::mainComponent().componentName()).contains(name)
++    // but that seems like overkill
++    d->defaultContainmentPlugin = name;
++}
++
++QString Corona::defaultContainmentPlugin() const
++{
++    return d->defaultContainmentPlugin;
++}
++
+ void Corona::saveLayout(const QString &configName) const
+ {
+     KSharedConfigPtr c;
+@@ -744,6 +758,7 @@ CoronaPrivate::CoronaPrivate(Corona *corona)
+     : q(corona),
+       immutability(Mutable),
+       mimetype("text/x-plasmoidservicename"),
++      defaultContainmentPlugin("desktop"),
+       config(0),
+       actions(corona)
+ {
+@@ -874,8 +889,7 @@ void CoronaPrivate::syncConfig()
+     emit q->configSynced();
+ }
+ 
+-Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args,
+-        uint id, bool delayedInit)
++Containment *CoronaPrivate::addContainment(const QString &name, const QVariantList &args, uint id, bool delayedInit)
+ {
+     QString pluginName = name;
+     Containment *containment = 0;
+@@ -885,7 +899,7 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
+ 
+     if (pluginName.isEmpty() || pluginName == "default") {
+         // default to the desktop containment
+-        pluginName = "desktop";
++        pluginName = defaultContainmentPlugin;
+     }
+ 
+     bool loadingNull = pluginName == "null";
+diff --git a/plasma/corona.h b/plasma/corona.h
+--- a/plasma/corona.h
++++ b/plasma/corona.h
+@@ -67,6 +67,12 @@ public:
+     QString appletMimeType();
+ 
+     /**
++     * @return the default containment plugin type
++     * @since 4.7
++     */
++    QString defaultContainmentPlugin() const;
++
++    /**
+      * @return all containments on this Corona
+      */
+     QList<Containment*> containments() const;
+@@ -479,6 +485,12 @@ protected:
+      */
+     void setPreferredToolBoxPlugin(const Containment::Type type, const QString &plugin);
+ 
++    /**
++     * Sets the default containment plugin to try and load
++     * @since 4.7
++     */
++    void setDefaultContainmentPlugin(const QString &name);
++
+     //Reimplemented from QGraphicsScene
+     void dragEnterEvent(QGraphicsSceneDragDropEvent *event);
+     void dragLeaveEvent(QGraphicsSceneDragDropEvent *event);
+diff --git a/plasma/private/corona_p.h b/plasma/private/corona_p.h
+index 5240fc2..5749c28 100644
+--- a/plasma/private/corona_p.h
++++ b/plasma/private/corona_p.h
+@@ -54,6 +54,7 @@ public:
+     ImmutabilityType immutability;
+     QString mimetype;
+     QString configName;
++    QString defaultContainmentPlugin;
+     KSharedConfigPtr config;
+     QTimer configSyncTimer;
+     QList<Containment*> containments;

=== modified file 'debian/patches/series'
--- debian/patches/series	2011-03-09 14:25:35 +0000
+++ debian/patches/series	2011-04-04 19:37:24 +0000
@@ -29,3 +29,6 @@
 kubuntu_77_ksambashare.diff
 kubuntu_78_hide_old_file_share.diff
 kubuntu_77_no_kbookmark_write_error.diff
+80-KIO-PreviewJob-Respect-the-enabled-plugins-from-Prev.patch
+81-give-Corona-a-proper-private-header-in-private.patch
+82-FEATURE-configurable-default-containment-plugin-name.patch

-- 
kubuntu-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/kubuntu-devel

Reply via email to