From 48561504c88ca5ea3db444a0cd6831407df71434 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Tue, 5 Feb 2013 14:55:40 +0100 Subject: [PATCH] remove delayedContainmentInit --- plasma/corona.cpp | 36 ++----- plasma/corona.h | 1 - plasma/private/corona_p.h | 3 - .../qml/plasmoid/appletinterface.cpp | 3 + shell/desktopcorona.cpp | 5 + shell/main.cpp | 3 - shell/testcontainment/contents/ui/main.qml | 95 ++++++++++--------- 7 files changed, 66 insertions(+), 80 deletions(-) diff --git a/plasma/corona.cpp b/plasma/corona.cpp index fb284b9bd..11e3d404e 100644 --- a/plasma/corona.cpp +++ b/plasma/corona.cpp @@ -436,7 +436,6 @@ CoronaPrivate::CoronaPrivate(Corona *corona) defaultContainmentPlugin("desktop"), config(0), configSyncTimer(new QTimer(corona)), - delayedInitTimer(new QTimer(corona)), actions(corona) { if (QCoreApplication::instance()) { @@ -453,9 +452,6 @@ CoronaPrivate::~CoronaPrivate() void CoronaPrivate::init() { - delayedInitTimer->setInterval(100); - delayedInitTimer->setSingleShot(true); - QObject::connect(delayedInitTimer, SIGNAL(timeout()), q, SLOT(delayedContainmentInit())); configSyncTimer->setSingleShot(true); QObject::connect(configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig())); @@ -628,8 +624,6 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi applet->d->isContainment = true; applet->d->setIsContainment(true, true); containments.append(containment); - containmentsNeedingInit.append(containment); - delayedInitTimer->start(); QObject::connect(containment, SIGNAL(destroyed(QObject*)), q, SLOT(containmentDestroyed(QObject*))); @@ -640,30 +634,18 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi QObject::connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)), q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*))); + containment->init(); + KConfigGroup cg = containment->config(); + containment->restore(cg); + containment->updateConstraints(Plasma::StartupCompletedConstraint); + containment->save(cg); + q->requestConfigSync(); + containment->flushPendingConstraintsEvents(); + emit q->containmentAdded(containment); + return containment; } -void CoronaPrivate::delayedContainmentInit() -{ - foreach (QWeakPointer c, containmentsNeedingInit) { - Containment *containment = c.data(); - if (!containment) { - continue; - } - - containment->init(); - KConfigGroup cg = containment->config(); - containment->restore(cg); - containment->updateConstraints(Plasma::StartupCompletedConstraint); - containment->save(cg); - q->requestConfigSync(); - containment->flushPendingConstraintsEvents(); - emit q->containmentAdded(containment); - } - - containmentsNeedingInit.clear(); -} - QList CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig) { if (!conf.isValid()) { diff --git a/plasma/corona.h b/plasma/corona.h index f84aa2e6e..b6543b3f3 100644 --- a/plasma/corona.h +++ b/plasma/corona.h @@ -393,7 +393,6 @@ private: Q_PRIVATE_SLOT(d, void syncConfig()) Q_PRIVATE_SLOT(d, void toggleImmutability()) Q_PRIVATE_SLOT(d, void showShortcutConfig()) - Q_PRIVATE_SLOT(d, void delayedContainmentInit()) friend class CoronaPrivate; friend class View; diff --git a/plasma/private/corona_p.h b/plasma/private/corona_p.h index 2cd809897..9c35c6703 100644 --- a/plasma/private/corona_p.h +++ b/plasma/private/corona_p.h @@ -46,7 +46,6 @@ public: void containmentDestroyed(QObject *obj); void syncConfig(); Containment *addContainment(const QString &name, const QVariantList &args, uint id); - void delayedContainmentInit(); void offscreenWidgetDestroyed(QObject *); QList importLayout(const KConfigGroup &conf, bool mergeConfig); @@ -59,9 +58,7 @@ public: QString defaultContainmentPlugin; KSharedConfigPtr config; QTimer *configSyncTimer; - QTimer *delayedInitTimer; QList containments; - QList > containmentsNeedingInit; QHash offscreenWidgets; KActionCollection actions; QMap containmentActionsDefaults; diff --git a/scriptengines/qml/plasmoid/appletinterface.cpp b/scriptengines/qml/plasmoid/appletinterface.cpp index f74d68b70..0d7ab585e 100644 --- a/scriptengines/qml/plasmoid/appletinterface.cpp +++ b/scriptengines/qml/plasmoid/appletinterface.cpp @@ -473,6 +473,9 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPoi QObject *contGraphicObject = containment()->property("graphicObject").value(); qDebug() << "Applet added:" << applet << applet->name() << appletGraphicObject; +foreach(Plasma::Applet *appl, containment()->applets()) { + qDebug() << appl << applet->name() << appl->property("graphicObject"); +} if (applet && contGraphicObject && appletGraphicObject) { appletGraphicObject->setProperty("visible", false); diff --git a/shell/desktopcorona.cpp b/shell/desktopcorona.cpp index 7b113ad4a..69517e8ec 100644 --- a/shell/desktopcorona.cpp +++ b/shell/desktopcorona.cpp @@ -117,6 +117,11 @@ void DesktopCorona::checkDesktop(/*Activity *activity,*/ bool signalWhenExists, } c->setScreen(screen, desktop); + if (screen >= 0 || m_views.count() >= screen + 1) { + m_views[screen]->setContainment(c); + } else { + qWarning() << "Invalid screen"; + } c->flushPendingConstraintsEvents(); requestConfigSync(); diff --git a/shell/main.cpp b/shell/main.cpp index a2aee5486..17963a686 100644 --- a/shell/main.cpp +++ b/shell/main.cpp @@ -46,9 +46,6 @@ int main(int argc, char** argv) QApplication app(argc, argv); - //qmlRegisterType("org.kde.plasma", 2, 0, "Svg"); - - DesktopCorona *corona = new DesktopCorona(); corona->initializeLayout(); diff --git a/shell/testcontainment/contents/ui/main.qml b/shell/testcontainment/contents/ui/main.qml index 9ae5f884b..04d510bc1 100644 --- a/shell/testcontainment/contents/ui/main.qml +++ b/shell/testcontainment/contents/ui/main.qml @@ -29,8 +29,12 @@ Rectangle { Connections { target: plasmoid onAppletAdded: { + var container = appletContainerComponent.createObject(root) + container.visible = true print("Applet added: " + applet) - applet.parent = root + applet.parent = container + container.applet = applet + applet.anchors.fill= applet.parent applet.visible = true } } @@ -40,57 +44,56 @@ Rectangle { imagePath: "widgets/configuration-icons" } - PlasmaCore.FrameSvgItem { - id: frame - x: 50 - y: 50 - width: txt.paintedWidth + 80 - height: txt.paintedHeight + 80 * 2 - property int small: 100 - property int large: parent.width - width - 150 - imagePath: "widgets/background" - MouseArea { - anchors.fill: parent - drag.target: parent - onClicked: { - var s = (frame.x == frame.large) ? frame.small : frame.large; - frame.x = s - frame.height = s + Component { + id: appletContainerComponent + PlasmaCore.FrameSvgItem { + id: frame + x: 50 + y: 50 + width: 150 + height: 150 + property alias applet: appletContainer.children + property int small: 100 + property int large: parent.width - width - 150 + imagePath: "widgets/background" + MouseArea { + anchors.fill: parent + drag.target: parent + onClicked: { + var s = (frame.x == frame.large) ? frame.small : frame.large; + frame.x = s + frame.height = s + } } - } - Behavior on x { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } } - //Behavior on y { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } } - Behavior on height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } } + Behavior on x { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } } + //Behavior on y { PropertyAnimation { easing.type: Easing.OutElastic; duration: 800 } } + Behavior on height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } } - Column { - anchors.centerIn: parent - Text { - id: txt - text: "Click or Drag"; + Item { + id: appletContainer + anchors { + fill: parent + leftMargin: frame.margins.left + rightMargin: parent.margins.right + topMargin: parent.margins.top + bottomMargin: parent.margins.bottom + } } - Text { - text: plasmoid + PlasmaCore.SvgItem { + svg: actionssvg + elementId: "rotate" + width: 16 + height: width + anchors.margins: frame.margins.left + anchors { + top: parent.top + left: parent.left + } + //Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; } } } - PlasmaCore.SvgItem { - svg: actionssvg - elementId: "rotate" - width: 16 - height: width - anchors.margins: frame.margins.left - anchors { - top: parent.top - left: parent.left - } - //Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; } - } } -// PlasmaCore.SvgItem { -// svg: actionssvg -// elementId: "rotate" -// width: 128 -// height: width -// } + PlasmaCore.IconItem { source: "accessories-dictionary" x: 50