2007-06-01 00:27:33 +02:00
|
|
|
/*
|
2007-08-06 13:20:02 +02:00
|
|
|
* Copyright 2007 Matt Broadstone <mbroadst@gmail.com>
|
|
|
|
* Copyright 2007 Aaron Seigo <aseigo@kde.org>
|
|
|
|
* Copyright 2007 Riccardo Iaconelli <riccardo@kde.org>
|
2007-06-01 00:27:33 +02:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
2007-09-14 21:06:18 +02:00
|
|
|
* 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.
|
2007-06-01 00:27:33 +02:00
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "corona.h"
|
|
|
|
|
|
|
|
#include <QApplication>
|
|
|
|
#include <QGraphicsSceneDragDropEvent>
|
2008-08-02 13:48:56 +02:00
|
|
|
#include <QGraphicsGridLayout>
|
2007-06-01 00:27:33 +02:00
|
|
|
#include <QMimeData>
|
2008-03-06 20:50:25 +01:00
|
|
|
#include <QPainter>
|
2008-01-01 23:44:56 +01:00
|
|
|
#include <QTimer>
|
2007-06-01 00:27:33 +02:00
|
|
|
|
2007-06-21 20:25:09 +02:00
|
|
|
#include <KDebug>
|
2008-02-11 22:43:09 +01:00
|
|
|
#include <KGlobal>
|
2007-06-01 00:27:33 +02:00
|
|
|
#include <KLocale>
|
2007-06-21 20:25:09 +02:00
|
|
|
#include <KMimeType>
|
2007-06-01 00:27:33 +02:00
|
|
|
|
2007-09-18 23:25:15 +02:00
|
|
|
#include "containment.h"
|
2008-09-22 19:50:23 +02:00
|
|
|
#include "private/applet_p.h"
|
2007-06-01 00:27:33 +02:00
|
|
|
|
|
|
|
using namespace Plasma;
|
|
|
|
|
|
|
|
namespace Plasma
|
|
|
|
{
|
|
|
|
|
2008-05-09 07:32:15 +02:00
|
|
|
// constant controlling how long between requesting a configuration sync
|
2008-07-01 20:41:42 +02:00
|
|
|
// and one happening should occur. currently 30 seconds
|
|
|
|
const int CONFIG_SYNC_TIMEOUT = 30000;
|
2008-01-01 23:44:56 +01:00
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
class CoronaPrivate
|
2007-06-01 00:27:33 +02:00
|
|
|
{
|
|
|
|
public:
|
2008-07-01 20:56:43 +02:00
|
|
|
CoronaPrivate(Corona *corona)
|
2008-04-24 21:46:07 +02:00
|
|
|
: q(corona),
|
2008-05-08 06:26:52 +02:00
|
|
|
immutability(Mutable),
|
2007-11-25 00:38:37 +01:00
|
|
|
mimetype("text/x-plasmoidservicename"),
|
2008-08-02 13:48:56 +02:00
|
|
|
config(0),
|
|
|
|
offscreenLayout(0)
|
2007-06-01 00:27:33 +02:00
|
|
|
{
|
2008-02-11 22:43:09 +01:00
|
|
|
if (KGlobal::hasMainComponent()) {
|
|
|
|
configName = KGlobal::mainComponent().componentName() + "-appletsrc";
|
|
|
|
} else {
|
|
|
|
configName = "plasma-appletsrc";
|
|
|
|
}
|
2007-06-01 00:27:33 +02:00
|
|
|
}
|
2007-06-07 22:57:18 +02:00
|
|
|
|
2008-07-01 20:56:43 +02:00
|
|
|
~CoronaPrivate()
|
2007-06-07 22:57:18 +02:00
|
|
|
{
|
2007-12-02 01:54:20 +01:00
|
|
|
qDeleteAll(containments);
|
2007-06-07 22:57:18 +02:00
|
|
|
}
|
|
|
|
|
2008-04-24 21:46:07 +02:00
|
|
|
void init()
|
2007-11-09 01:44:35 +01:00
|
|
|
{
|
2008-01-01 23:44:56 +01:00
|
|
|
configSyncTimer.setSingleShot(true);
|
2008-07-01 20:56:43 +02:00
|
|
|
QObject::connect(&configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig()));
|
2007-11-09 01:44:35 +01:00
|
|
|
}
|
|
|
|
|
2008-04-24 21:04:15 +02:00
|
|
|
void saveLayout(KSharedConfigPtr cg) const
|
2008-01-02 00:41:59 +01:00
|
|
|
{
|
|
|
|
KConfigGroup containmentsGroup(cg, "Containments");
|
|
|
|
foreach (const Containment *containment, containments) {
|
|
|
|
QString cid = QString::number(containment->id());
|
|
|
|
KConfigGroup containmentConfig(&containmentsGroup, cid);
|
2008-05-22 17:53:48 +02:00
|
|
|
containment->save(containmentConfig);
|
2008-01-02 00:41:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-01-07 05:00:39 +01:00
|
|
|
void updateContainmentImmutability()
|
|
|
|
{
|
|
|
|
foreach (Containment *c, containments) {
|
|
|
|
// we need to tell each containment that immutability has been altered
|
|
|
|
c->updateConstraints(ImmutableConstraint);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-24 21:46:07 +02:00
|
|
|
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);
|
2008-05-22 17:53:48 +02:00
|
|
|
|
2008-04-24 21:46:07 +02:00
|
|
|
if (index > -1) {
|
|
|
|
containments.removeAt(index);
|
2008-07-07 00:43:53 +02:00
|
|
|
q->requestConfigSync();
|
2008-04-24 21:46:07 +02:00
|
|
|
}
|
|
|
|
}
|
2008-04-27 21:05:06 +02:00
|
|
|
|
2008-04-24 21:46:07 +02:00
|
|
|
void syncConfig()
|
|
|
|
{
|
|
|
|
q->config()->sync();
|
2008-06-14 03:31:53 +02:00
|
|
|
emit q->configSynced();
|
2008-04-24 21:46:07 +02:00
|
|
|
}
|
2008-04-27 21:05:06 +02:00
|
|
|
|
2008-04-25 19:15:14 +02:00
|
|
|
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()) {
|
|
|
|
// default to the desktop containment
|
|
|
|
pluginName = "desktop";
|
2008-07-07 04:16:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (pluginName != "null") {
|
2008-04-25 19:15:14 +02:00
|
|
|
applet = Applet::load(pluginName, id, args);
|
|
|
|
containment = dynamic_cast<Containment*>(applet);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!containment) {
|
|
|
|
kDebug() << "loading of containment" << name << "failed.";
|
|
|
|
|
|
|
|
// in case we got a non-Containment from Applet::loadApplet or a null containment was requested
|
|
|
|
delete applet;
|
|
|
|
containment = new Containment(0, 0, id);
|
|
|
|
|
2008-09-09 03:16:10 +02:00
|
|
|
if (pluginName == "null") {
|
|
|
|
containment->setDrawWallpaper(false);
|
|
|
|
}
|
|
|
|
|
2008-04-25 19:15:14 +02:00
|
|
|
// we want to provide something and don't care about the failure to launch
|
|
|
|
containment->setFailedToLaunch(false);
|
|
|
|
containment->setFormFactor(Plasma::Planar);
|
|
|
|
}
|
|
|
|
|
2008-09-22 19:50:23 +02:00
|
|
|
static_cast<Applet*>(containment)->d->setIsContainment(true);
|
2008-07-07 04:16:08 +02:00
|
|
|
q->addItem(containment);
|
2008-04-25 19:15:14 +02:00
|
|
|
|
|
|
|
if (!delayedInit) {
|
|
|
|
containment->init();
|
|
|
|
containment->updateConstraints(Plasma::StartupCompletedConstraint);
|
2008-07-07 04:16:08 +02:00
|
|
|
KConfigGroup cg = containment->config();
|
|
|
|
containment->save(cg);
|
|
|
|
q->requestConfigSync();
|
2008-04-25 19:15:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
containments.append(containment);
|
2008-07-01 20:56:43 +02:00
|
|
|
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*)),
|
2008-07-07 00:43:53 +02:00
|
|
|
q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
|
2008-04-25 19:15:14 +02:00
|
|
|
|
|
|
|
if (!delayedInit) {
|
|
|
|
emit q->containmentAdded(containment);
|
|
|
|
}
|
|
|
|
|
|
|
|
return containment;
|
|
|
|
}
|
2008-04-24 21:46:07 +02:00
|
|
|
|
|
|
|
Corona *q;
|
2008-04-24 20:24:11 +02:00
|
|
|
ImmutabilityType immutability;
|
2007-07-17 23:13:41 +02:00
|
|
|
QString mimetype;
|
2007-11-25 00:38:37 +01:00
|
|
|
QString configName;
|
|
|
|
KSharedConfigPtr config;
|
2008-01-01 23:44:56 +01:00
|
|
|
QTimer configSyncTimer;
|
2007-09-18 23:25:15 +02:00
|
|
|
QList<Containment*> containments;
|
2008-08-02 13:48:56 +02:00
|
|
|
QGraphicsGridLayout *offscreenLayout;
|
2007-06-01 00:27:33 +02:00
|
|
|
};
|
|
|
|
|
2007-08-05 15:03:54 +02:00
|
|
|
Corona::Corona(QObject *parent)
|
2007-06-01 00:27:33 +02:00
|
|
|
: QGraphicsScene(parent),
|
2008-07-01 20:56:43 +02:00
|
|
|
d(new CoronaPrivate(this))
|
2007-06-01 00:27:33 +02:00
|
|
|
{
|
2008-04-24 21:46:07 +02:00
|
|
|
d->init();
|
2007-07-17 19:55:05 +02:00
|
|
|
//setViewport(new QGLWidget(QGLFormat(QGL::StencilBuffer | QGL::AlphaChannel)));
|
2007-06-01 00:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Corona::~Corona()
|
|
|
|
{
|
2008-08-26 19:25:04 +02:00
|
|
|
// FIXME: Same fix as in Plasma::View - make sure that when the focused widget is
|
|
|
|
// destroyed we don't try to transfer it to something that's already been
|
|
|
|
// deleted.
|
|
|
|
clearFocus();
|
|
|
|
|
2007-12-07 06:02:54 +01:00
|
|
|
KConfigGroup cg(config(), "General");
|
|
|
|
|
|
|
|
// we call the dptr member directly for locked since isImmutable()
|
|
|
|
// also checks kiosk and parent containers
|
2008-04-24 20:24:11 +02:00
|
|
|
cg.writeEntry("immutability", (int)d->immutability);
|
2007-06-07 22:57:18 +02:00
|
|
|
delete d;
|
2007-06-01 00:27:33 +02:00
|
|
|
}
|
|
|
|
|
2007-07-17 23:13:41 +02:00
|
|
|
void Corona::setAppletMimeType(const QString& type)
|
|
|
|
{
|
|
|
|
d->mimetype = type;
|
|
|
|
}
|
|
|
|
|
|
|
|
QString Corona::appletMimeType()
|
|
|
|
{
|
|
|
|
return d->mimetype;
|
|
|
|
}
|
|
|
|
|
2008-04-24 21:04:15 +02:00
|
|
|
void Corona::saveLayout(const QString &configName) const
|
2007-06-01 00:27:33 +02:00
|
|
|
{
|
2008-02-11 22:43:09 +01:00
|
|
|
KSharedConfigPtr c;
|
2007-08-05 15:03:54 +02:00
|
|
|
|
2008-02-11 22:43:09 +01:00
|
|
|
if (configName.isEmpty() || configName == d->configName) {
|
|
|
|
c = config();
|
|
|
|
} else {
|
|
|
|
c = KSharedConfig::openConfig(configName);
|
|
|
|
}
|
|
|
|
|
2008-04-24 21:04:15 +02:00
|
|
|
d->saveLayout(c);
|
2007-08-05 15:03:54 +02:00
|
|
|
}
|
|
|
|
|
2008-06-14 03:31:53 +02:00
|
|
|
void Corona::requestConfigSync()
|
2008-01-01 23:44:56 +01:00
|
|
|
{
|
2008-04-29 04:19:12 +02:00
|
|
|
// TODO: should we check into our immutability before doing this?
|
|
|
|
|
2008-01-01 23:44:56 +01:00
|
|
|
//NOTE: this is a pretty simplistic model: we simply save no more than CONFIG_SYNC_TIMEOUT
|
|
|
|
// after the first time this is called. not much of a heuristic for save points, but
|
|
|
|
// it should at least compress these activities a bit and provide a way for applet
|
|
|
|
// authors to ween themselves from the sync() disease. A more interesting/dynamic
|
|
|
|
// algorithm for determining when to actually sync() to disk might be better, though.
|
2008-06-14 03:31:53 +02:00
|
|
|
if (!d->configSyncTimer.isActive()) {
|
|
|
|
d->configSyncTimer.start(CONFIG_SYNC_TIMEOUT);
|
2008-01-01 23:44:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-24 01:12:05 +02:00
|
|
|
void Corona::initializeLayout(const QString &configName)
|
2007-08-05 15:03:54 +02:00
|
|
|
{
|
2008-04-16 23:15:38 +02:00
|
|
|
clearContainments();
|
2008-05-24 01:12:05 +02:00
|
|
|
loadLayout(configName);
|
|
|
|
|
|
|
|
if (d->containments.isEmpty()) {
|
|
|
|
loadDefaultLayout();
|
|
|
|
if (!d->containments.isEmpty()) {
|
2008-06-14 03:31:53 +02:00
|
|
|
requestConfigSync();
|
2008-05-24 01:12:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (config()->isImmutable()) {
|
|
|
|
d->updateContainmentImmutability();
|
|
|
|
}
|
|
|
|
|
|
|
|
KConfigGroup coronaConfig(config(), "General");
|
|
|
|
setImmutability((ImmutabilityType)coronaConfig.readEntry("immutability", (int)Mutable));
|
|
|
|
}
|
|
|
|
|
|
|
|
void Corona::loadLayout(const QString& configName)
|
|
|
|
{
|
2008-02-11 22:43:09 +01:00
|
|
|
KSharedConfigPtr c;
|
|
|
|
|
|
|
|
if (configName.isEmpty() || configName == d->configName) {
|
|
|
|
c = config();
|
|
|
|
} else {
|
|
|
|
c = KSharedConfig::openConfig(configName);
|
2008-01-02 00:41:59 +01:00
|
|
|
}
|
2007-08-29 04:33:22 +02:00
|
|
|
|
2007-12-07 06:02:54 +01:00
|
|
|
KConfigGroup containments(config(), "Containments");
|
2007-09-18 23:25:15 +02:00
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
foreach (const QString& group, containments.groupList()) {
|
|
|
|
KConfigGroup containmentConfig(&containments, group);
|
2007-11-27 08:47:23 +01:00
|
|
|
|
|
|
|
if (containmentConfig.entryMap().isEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2007-11-25 00:38:37 +01:00
|
|
|
int cid = group.toUInt();
|
2008-02-29 18:50:57 +01:00
|
|
|
//kDebug() << "got a containment in the config, trying to make a" << containmentConfig.readEntry("plugin", QString()) << "from" << group;
|
2008-04-25 19:15:14 +02:00
|
|
|
Containment *c = d->addContainment(containmentConfig.readEntry("plugin", QString()), QVariantList(),
|
|
|
|
cid, true);
|
2007-09-18 23:25:15 +02:00
|
|
|
if (!c) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-07-07 04:16:08 +02:00
|
|
|
//addItem(c);
|
2007-11-29 02:02:33 +01:00
|
|
|
c->init();
|
2008-05-22 17:53:48 +02:00
|
|
|
c->restore(containmentConfig);
|
2007-09-13 19:03:13 +02:00
|
|
|
}
|
2008-02-29 18:50:57 +01:00
|
|
|
|
2008-05-24 01:12:05 +02:00
|
|
|
foreach (Containment* containment, d->containments) {
|
|
|
|
QString cid = QString::number(containment->id());
|
|
|
|
KConfigGroup containmentConfig(&containments, cid);
|
2007-09-18 23:25:15 +02:00
|
|
|
|
2008-05-24 01:12:05 +02:00
|
|
|
foreach(Applet* applet, containment->applets()) {
|
|
|
|
applet->init();
|
2008-08-19 23:36:52 +02:00
|
|
|
// We have to flush the applet constraints manually
|
|
|
|
applet->flushPendingConstraintsEvents();
|
2007-11-25 00:38:37 +01:00
|
|
|
}
|
2007-10-26 03:08:19 +02:00
|
|
|
|
2008-05-24 01:12:05 +02:00
|
|
|
containment->updateConstraints(Plasma::StartupCompletedConstraint);
|
|
|
|
containment->flushPendingConstraintsEvents();
|
|
|
|
emit containmentAdded(containment);
|
2008-01-07 05:00:39 +01:00
|
|
|
}
|
2007-08-05 15:03:54 +02:00
|
|
|
}
|
|
|
|
|
2007-09-18 23:25:15 +02:00
|
|
|
Containment* Corona::containmentForScreen(int screen) const
|
2007-08-05 15:03:54 +02:00
|
|
|
{
|
2007-09-18 23:25:15 +02:00
|
|
|
foreach (Containment* containment, d->containments) {
|
2007-10-26 03:08:19 +02:00
|
|
|
if (containment->screen() == screen &&
|
2008-03-16 08:20:42 +01:00
|
|
|
(containment->containmentType() == Containment::DesktopContainment ||
|
2008-04-24 18:16:50 +02:00
|
|
|
containment->containmentType() >= Containment::CustomContainment)) {
|
2007-09-18 23:25:15 +02:00
|
|
|
return containment;
|
|
|
|
}
|
2007-06-01 00:27:33 +02:00
|
|
|
}
|
2007-06-20 10:11:59 +02:00
|
|
|
|
2007-09-18 23:25:15 +02:00
|
|
|
return 0;
|
|
|
|
}
|
2007-09-01 14:34:22 +02:00
|
|
|
|
2007-09-30 20:06:08 +02:00
|
|
|
QList<Containment*> Corona::containments() const
|
|
|
|
{
|
|
|
|
return d->containments;
|
|
|
|
}
|
|
|
|
|
2008-04-16 23:15:38 +02:00
|
|
|
void Corona::clearContainments()
|
2007-09-18 23:25:15 +02:00
|
|
|
{
|
|
|
|
foreach (Containment* containment, d->containments) {
|
|
|
|
containment->clearApplets();
|
2007-09-01 14:34:22 +02:00
|
|
|
}
|
2007-09-18 23:25:15 +02:00
|
|
|
}
|
|
|
|
|
2008-01-02 00:41:59 +01:00
|
|
|
KSharedConfigPtr Corona::config() const
|
2007-11-25 00:38:37 +01:00
|
|
|
{
|
|
|
|
if (!d->config) {
|
|
|
|
d->config = KSharedConfig::openConfig(d->configName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return d->config;
|
|
|
|
}
|
|
|
|
|
2008-04-25 19:15:14 +02:00
|
|
|
Containment* Corona::addContainment(const QString& name, const QVariantList& args)
|
2007-09-18 23:25:15 +02:00
|
|
|
{
|
2008-07-07 04:16:08 +02:00
|
|
|
return d->addContainment(name, args, 0, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
Containment* Corona::addContainmentDelayed(const QString& name, const QVariantList& args)
|
|
|
|
{
|
|
|
|
return d->addContainment(name, args, 0, true);
|
2007-09-18 23:25:15 +02:00
|
|
|
}
|
|
|
|
|
2008-08-02 13:48:56 +02:00
|
|
|
void Corona::addOffscreenWidget(QGraphicsWidget *widget)
|
|
|
|
{
|
|
|
|
widget->setParentItem(0);
|
|
|
|
if (!d->offscreenLayout) {
|
2008-08-28 16:32:48 +02:00
|
|
|
kDebug() << "adding offscreen widget.";
|
2008-08-02 13:48:56 +02:00
|
|
|
QGraphicsWidget *offscreenWidget = new QGraphicsWidget(0);
|
|
|
|
addItem(offscreenWidget);
|
|
|
|
d->offscreenLayout = new QGraphicsGridLayout(offscreenWidget);
|
|
|
|
//FIXME: do this a nice way.
|
|
|
|
offscreenWidget->setPos(-10000, -10000);
|
|
|
|
offscreenWidget->setLayout(d->offscreenLayout);
|
|
|
|
}
|
|
|
|
|
2008-08-28 16:32:48 +02:00
|
|
|
//check if the layout allready contains this widget.
|
|
|
|
//XXX: duplicated from removeOffscreenWidget()
|
|
|
|
for (int i = 0; i < d->offscreenLayout->count(); i++) {
|
|
|
|
QGraphicsWidget *foundWidget =
|
|
|
|
dynamic_cast<QGraphicsWidget*>(d->offscreenLayout->itemAt(i));
|
|
|
|
if (foundWidget == widget) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-02 13:48:56 +02:00
|
|
|
d->offscreenLayout->addItem(widget, d->offscreenLayout->rowCount() + 1,
|
|
|
|
d->offscreenLayout->columnCount() + 1);
|
2008-09-04 19:09:34 +02:00
|
|
|
widget->update();
|
2008-08-02 13:48:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Corona::removeOffscreenWidget(QGraphicsWidget *widget)
|
|
|
|
{
|
|
|
|
if (!d->offscreenLayout) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (int i = 0; i < d->offscreenLayout->count(); i++) {
|
|
|
|
QGraphicsWidget *foundWidget =
|
|
|
|
dynamic_cast<QGraphicsWidget*>(d->offscreenLayout->itemAt(i));
|
|
|
|
if (foundWidget == widget) {
|
|
|
|
d->offscreenLayout->removeAt(i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-04-24 20:36:39 +02:00
|
|
|
void Corona::loadDefaultLayout()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2008-06-13 18:16:53 +02:00
|
|
|
void Corona::dragEnterEvent(QGraphicsSceneDragDropEvent *event)
|
2007-06-01 00:27:33 +02:00
|
|
|
{
|
2008-06-13 18:16:53 +02:00
|
|
|
QGraphicsScene::dragEnterEvent(event);
|
2007-06-01 00:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Corona::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)
|
|
|
|
{
|
2007-08-16 07:32:54 +02:00
|
|
|
QGraphicsScene::dragLeaveEvent(event);
|
2007-06-01 00:27:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Corona::dragMoveEvent(QGraphicsSceneDragDropEvent *event)
|
|
|
|
{
|
2007-08-01 09:09:27 +02:00
|
|
|
QGraphicsScene::dragMoveEvent(event);
|
2007-06-01 00:27:33 +02:00
|
|
|
}
|
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
ImmutabilityType Corona::immutability() const
|
2007-06-04 02:25:44 +02:00
|
|
|
{
|
2008-04-24 20:24:11 +02:00
|
|
|
return d->immutability;
|
2007-12-04 05:15:21 +01:00
|
|
|
}
|
|
|
|
|
2008-04-24 20:24:11 +02:00
|
|
|
void Corona::setImmutability(const ImmutabilityType immutable)
|
2007-06-04 02:25:44 +02:00
|
|
|
{
|
2008-04-24 20:24:11 +02:00
|
|
|
if (d->immutability == immutable ||
|
|
|
|
d->immutability == SystemImmutable) {
|
2007-06-07 21:40:16 +02:00
|
|
|
return;
|
|
|
|
}
|
2008-06-14 00:43:38 +02:00
|
|
|
|
2008-01-08 02:25:09 +01:00
|
|
|
kDebug() << "setting immutability to" << immutable;
|
2008-04-24 20:24:11 +02:00
|
|
|
d->immutability = immutable;
|
2008-01-07 05:00:39 +01:00
|
|
|
d->updateContainmentImmutability();
|
2007-06-04 02:25:44 +02:00
|
|
|
}
|
|
|
|
|
2007-06-01 00:27:33 +02:00
|
|
|
} // namespace Plasma
|
|
|
|
|
|
|
|
#include "corona.moc"
|
|
|
|
|