provide a containmentForScreen implementation that allows adding containments for screens / desktop affinities even in spite of immutabilities

svn path=/trunk/KDE/kdelibs/; revision=1198498
This commit is contained in:
Aaron J. Seigo 2010-11-18 17:17:56 +00:00
parent 3edc7be1c5
commit c21986f62d
2 changed files with 37 additions and 4 deletions

View File

@ -33,13 +33,14 @@
#include <cmath>
#include <kaction.h>
#include <kactioncollection.h>
#include <kdebug.h>
#include <kglobal.h>
#include <klocale.h>
#include <kmimetype.h>
#include <kactioncollection.h>
#include <kaction.h>
#include <kshortcutsdialog.h>
#include <kwindowsystem.h>
#include "animator.h"
#include "abstracttoolbox.h"
@ -192,7 +193,7 @@ public:
//kDebug() << "Loading" << name << args << id;
if (pluginName.isEmpty()) {
if (pluginName.isEmpty() || pluginName == "default") {
// default to the desktop containment
pluginName = "desktop";
}
@ -583,6 +584,23 @@ Containment *Corona::containmentForScreen(int screen, int desktop) const
return 0;
}
Containment *Corona::containmentForScreen(int screen, int desktop,
const QString &defaultPluginIfNonExistent, const QVariantList &defaultArgs)
{
Containment *containment = containmentForScreen(screen, desktop);
if (!containment && !defaultPluginIfNonExistent.isEmpty()) {
// screen requests are allowed to bypass immutability
if (screen >= 0 && screen < numScreens() &&
desktop >= -1 && desktop < KWindowSystem::numberOfDesktops()) {
containment = d->addContainment(defaultPluginIfNonExistent, defaultArgs, 0, false);
if (containment) {
containment->setScreen(screen, desktop);
}
}
}
return containment;
}
QList<Containment*> Corona::containments() const
{
return d->containments;

View File

@ -96,7 +96,7 @@ public:
Containment *addContainment(const QString &name, const QVariantList &args = QVariantList());
/**
* Returns the Containment, if any, for a given physical screen
* Returns the Containment, if any, for a given physical screen and desktop
*
* @param screen number of the physical screen to locate
* @param desktop the virtual desktop) to locate; if < 0 then it will
@ -104,6 +104,21 @@ public:
*/
Containment *containmentForScreen(int screen, int desktop = -1) const;
/**
* Returns the Containment for a given physical screen and desktop, creating one
* if none exists
*
* @param screen number of the physical screen to locate
* @param desktop the virtual desktop) to locate; if < 0 then it will
* simply return the first Containment associated with screen
* @param defaultPluginIfNonExistent the plugin to load by default; "null" is an empty
* Containment and "default" creates the default plugin
* @param defaultArgs optional arguments to pass in when creating a Containment if needed
* @since 4.6
*/
Containment *containmentForScreen(int screen, int desktop,
const QString &defaultPluginIfNonExistent,
const QVariantList &defaultArgs = QVariantList());
/**
* Adds a widget in the topleft quadrant in the scene. Widgets in the topleft quadrant are
* normally never shown unless you specifically aim a view at it, which makes it ideal for