remove delayedContainmentInit

This commit is contained in:
Marco Martin 2013-02-05 14:55:40 +01:00
parent 7f654acfd2
commit 48561504c8
7 changed files with 66 additions and 80 deletions

View File

@ -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<Containment> 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<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig)
{
if (!conf.isValid()) {

View File

@ -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;

View File

@ -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<Plasma::Containment *> importLayout(const KConfigGroup &conf, bool mergeConfig);
@ -59,9 +58,7 @@ public:
QString defaultContainmentPlugin;
KSharedConfigPtr config;
QTimer *configSyncTimer;
QTimer *delayedInitTimer;
QList<Containment*> containments;
QList<QWeakPointer<Containment> > containmentsNeedingInit;
QHash<uint, QGraphicsWidget*> offscreenWidgets;
KActionCollection actions;
QMap<Containment::Type, ContainmentActionsPluginsConfig> containmentActionsDefaults;

View File

@ -473,6 +473,9 @@ void ContainmentInterface::appletAddedForward(Plasma::Applet *applet, const QPoi
QObject *contGraphicObject = containment()->property("graphicObject").value<QObject *>();
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);

View File

@ -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();

View File

@ -46,9 +46,6 @@ int main(int argc, char** argv)
QApplication app(argc, argv);
//qmlRegisterType<Svg>("org.kde.plasma", 2, 0, "Svg");
DesktopCorona *corona = new DesktopCorona();
corona->initializeLayout();

View File

@ -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