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"), defaultContainmentPlugin("desktop"),
config(0), config(0),
configSyncTimer(new QTimer(corona)), configSyncTimer(new QTimer(corona)),
delayedInitTimer(new QTimer(corona)),
actions(corona) actions(corona)
{ {
if (QCoreApplication::instance()) { if (QCoreApplication::instance()) {
@ -453,9 +452,6 @@ CoronaPrivate::~CoronaPrivate()
void CoronaPrivate::init() void CoronaPrivate::init()
{ {
delayedInitTimer->setInterval(100);
delayedInitTimer->setSingleShot(true);
QObject::connect(delayedInitTimer, SIGNAL(timeout()), q, SLOT(delayedContainmentInit()));
configSyncTimer->setSingleShot(true); configSyncTimer->setSingleShot(true);
QObject::connect(configSyncTimer, SIGNAL(timeout()), q, SLOT(syncConfig())); 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->isContainment = true;
applet->d->setIsContainment(true, true); applet->d->setIsContainment(true, true);
containments.append(containment); containments.append(containment);
containmentsNeedingInit.append(containment);
delayedInitTimer->start();
QObject::connect(containment, SIGNAL(destroyed(QObject*)), QObject::connect(containment, SIGNAL(destroyed(QObject*)),
q, SLOT(containmentDestroyed(QObject*))); q, SLOT(containmentDestroyed(QObject*)));
@ -640,17 +634,6 @@ Containment *CoronaPrivate::addContainment(const QString &name, const QVariantLi
QObject::connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)), QObject::connect(containment, SIGNAL(screenChanged(int,int,Plasma::Containment*)),
q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*))); q, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)));
return containment;
}
void CoronaPrivate::delayedContainmentInit()
{
foreach (QWeakPointer<Containment> c, containmentsNeedingInit) {
Containment *containment = c.data();
if (!containment) {
continue;
}
containment->init(); containment->init();
KConfigGroup cg = containment->config(); KConfigGroup cg = containment->config();
containment->restore(cg); containment->restore(cg);
@ -659,9 +642,8 @@ void CoronaPrivate::delayedContainmentInit()
q->requestConfigSync(); q->requestConfigSync();
containment->flushPendingConstraintsEvents(); containment->flushPendingConstraintsEvents();
emit q->containmentAdded(containment); emit q->containmentAdded(containment);
}
containmentsNeedingInit.clear(); return containment;
} }
QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig) QList<Plasma::Containment *> CoronaPrivate::importLayout(const KConfigGroup &conf, bool mergeConfig)

View File

@ -393,7 +393,6 @@ private:
Q_PRIVATE_SLOT(d, void syncConfig()) Q_PRIVATE_SLOT(d, void syncConfig())
Q_PRIVATE_SLOT(d, void toggleImmutability()) Q_PRIVATE_SLOT(d, void toggleImmutability())
Q_PRIVATE_SLOT(d, void showShortcutConfig()) Q_PRIVATE_SLOT(d, void showShortcutConfig())
Q_PRIVATE_SLOT(d, void delayedContainmentInit())
friend class CoronaPrivate; friend class CoronaPrivate;
friend class View; friend class View;

View File

@ -46,7 +46,6 @@ public:
void containmentDestroyed(QObject *obj); void containmentDestroyed(QObject *obj);
void syncConfig(); void syncConfig();
Containment *addContainment(const QString &name, const QVariantList &args, uint id); Containment *addContainment(const QString &name, const QVariantList &args, uint id);
void delayedContainmentInit();
void offscreenWidgetDestroyed(QObject *); void offscreenWidgetDestroyed(QObject *);
QList<Plasma::Containment *> importLayout(const KConfigGroup &conf, bool mergeConfig); QList<Plasma::Containment *> importLayout(const KConfigGroup &conf, bool mergeConfig);
@ -59,9 +58,7 @@ public:
QString defaultContainmentPlugin; QString defaultContainmentPlugin;
KSharedConfigPtr config; KSharedConfigPtr config;
QTimer *configSyncTimer; QTimer *configSyncTimer;
QTimer *delayedInitTimer;
QList<Containment*> containments; QList<Containment*> containments;
QList<QWeakPointer<Containment> > containmentsNeedingInit;
QHash<uint, QGraphicsWidget*> offscreenWidgets; QHash<uint, QGraphicsWidget*> offscreenWidgets;
KActionCollection actions; KActionCollection actions;
QMap<Containment::Type, ContainmentActionsPluginsConfig> containmentActionsDefaults; 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 *>(); QObject *contGraphicObject = containment()->property("graphicObject").value<QObject *>();
qDebug() << "Applet added:" << applet << applet->name() << appletGraphicObject; qDebug() << "Applet added:" << applet << applet->name() << appletGraphicObject;
foreach(Plasma::Applet *appl, containment()->applets()) {
qDebug() << appl << applet->name() << appl->property("graphicObject");
}
if (applet && contGraphicObject && appletGraphicObject) { if (applet && contGraphicObject && appletGraphicObject) {
appletGraphicObject->setProperty("visible", false); appletGraphicObject->setProperty("visible", false);

View File

@ -117,6 +117,11 @@ void DesktopCorona::checkDesktop(/*Activity *activity,*/ bool signalWhenExists,
} }
c->setScreen(screen, desktop); c->setScreen(screen, desktop);
if (screen >= 0 || m_views.count() >= screen + 1) {
m_views[screen]->setContainment(c);
} else {
qWarning() << "Invalid screen";
}
c->flushPendingConstraintsEvents(); c->flushPendingConstraintsEvents();
requestConfigSync(); requestConfigSync();

View File

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

View File

@ -29,8 +29,12 @@ Rectangle {
Connections { Connections {
target: plasmoid target: plasmoid
onAppletAdded: { onAppletAdded: {
var container = appletContainerComponent.createObject(root)
container.visible = true
print("Applet added: " + applet) print("Applet added: " + applet)
applet.parent = root applet.parent = container
container.applet = applet
applet.anchors.fill= applet.parent
applet.visible = true applet.visible = true
} }
} }
@ -40,12 +44,15 @@ Rectangle {
imagePath: "widgets/configuration-icons" imagePath: "widgets/configuration-icons"
} }
Component {
id: appletContainerComponent
PlasmaCore.FrameSvgItem { PlasmaCore.FrameSvgItem {
id: frame id: frame
x: 50 x: 50
y: 50 y: 50
width: txt.paintedWidth + 80 width: 150
height: txt.paintedHeight + 80 * 2 height: 150
property alias applet: appletContainer.children
property int small: 100 property int small: 100
property int large: parent.width - width - 150 property int large: parent.width - width - 150
imagePath: "widgets/background" imagePath: "widgets/background"
@ -62,14 +69,14 @@ Rectangle {
//Behavior on y { 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 height { PropertyAnimation { easing.type: Easing.InOutDouble; duration: 300 } }
Column { Item {
anchors.centerIn: parent id: appletContainer
Text { anchors {
id: txt fill: parent
text: "Click or Drag"; leftMargin: frame.margins.left
} rightMargin: parent.margins.right
Text { topMargin: parent.margins.top
text: plasmoid bottomMargin: parent.margins.bottom
} }
} }
PlasmaCore.SvgItem { PlasmaCore.SvgItem {
@ -85,12 +92,8 @@ Rectangle {
//Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; } //Rectangle { color: "white"; opacity: 0.2; anchors.fill: parent; }
} }
} }
// PlasmaCore.SvgItem { }
// svg: actionssvg
// elementId: "rotate"
// width: 128
// height: width
// }
PlasmaCore.IconItem { PlasmaCore.IconItem {
source: "accessories-dictionary" source: "accessories-dictionary"
x: 50 x: 50