96
95
Nepomuk::ResourceManager::instance()->init();
98
97
qmlRegisterType<PanelProxy>("org.kde.plasma.deviceshell", 0, 1, "DevicePanel");
98
qmlRegisterUncreatableType<ContainmentProperties>("org.kde.plasma.deviceshell", 0, 1, "ContainmentProperties", "ContainmentProperties is just a type holder");
100
100
//FIXME: why does not work?
101
101
//qmlRegisterInterface<Plasma::Wallpaper>("Wallpaper");
164
164
connect(this, SIGNAL(aboutToQuit()), this, SLOT(cleanup()));
166
connect(KWindowSystem::self(), SIGNAL(activeWindowChanged(WId)),
167
this, SLOT(activeWindowChanged(WId)));
167
170
notifyStartup(true);
170
173
m_startupInfo = new KStartupInfo(KStartupInfo::CleanOnCantDetect, this );
172
175
connect(m_startupInfo,
173
SIGNAL(gotNewStartup(const KStartupInfoId&, const KStartupInfoData&)),
174
SLOT(gotStartup(const KStartupInfoId&, const KStartupInfoData&)));
175
connect(m_startupInfo,
176
SIGNAL(gotStartupChange(const KStartupInfoId&, const KStartupInfoData&)),
177
SLOT(gotStartup(const KStartupInfoId&, const KStartupInfoData&)));
178
connect(m_startupInfo,
179
SIGNAL(gotRemoveStartup(const KStartupInfoId&, const KStartupInfoData&)),
180
SLOT(killStartup(const KStartupInfoId&)));
176
SIGNAL(gotNewStartup(KStartupInfoId,KStartupInfoData)),
177
SLOT(gotStartup(KStartupInfoId,KStartupInfoData)));
178
connect(m_startupInfo,
179
SIGNAL(gotStartupChange(KStartupInfoId,KStartupInfoData)),
180
SLOT(gotStartup(KStartupInfoId,KStartupInfoData)));
181
connect(m_startupInfo,
182
SIGNAL(gotRemoveStartup(KStartupInfoId,KStartupInfoData)),
183
SLOT(killStartup(KStartupInfoId)));
183
186
PlasmaApp::~PlasmaApp()
279
282
connect(m_mainView, SIGNAL(containmentActivated()),
280
283
this, SLOT(mainContainmentActivated()));
282
connect(m_homeScreen, SIGNAL(transformingChanged(bool)),
283
this, SLOT(containmentsTransformingChanged(bool)));
285
285
connect(m_homeScreen, SIGNAL(focusActivityView()),
286
286
this, SLOT(focusMainView()));
288
connect(m_homeScreen, SIGNAL(nextActivityRequested()),
289
m_corona, SLOT(activateNextActivity()));
288
KAction *focusHomeAction = new KAction(this);
289
focusHomeAction->setObjectName("Focus Homescreen");
290
focusHomeAction->setGlobalShortcut(
291
KShortcut(QKeySequence(Qt::Key_HomePage)),
292
KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut),
293
KAction::NoAutoloading);
294
connect(focusHomeAction, SIGNAL(triggered()),
295
this, SLOT(focusMainView()));
291
connect(m_homeScreen, SIGNAL(previousActivityRequested()),
292
m_corona, SLOT(activatePreviousActivity()));
297
KAction *togglePanelAction = new KAction(this);
298
togglePanelAction->setObjectName("Toggle Panel");
299
togglePanelAction->setGlobalShortcut(
300
KShortcut(QKeySequence(Qt::Key_Menu)),
301
KAction::ShortcutTypes(KAction::ActiveShortcut | KAction::DefaultShortcut),
302
KAction::NoAutoloading);
303
connect(togglePanelAction, SIGNAL(triggered()),
304
m_homeScreen, SLOT(togglePanel()));
294
306
connect(m_homeScreen, SIGNAL(newActivityRequested()),
295
307
this, SLOT(showActivityCreation()));
307
319
m_oldContainment = m_currentContainment;
309
//FIXME: it should be possible to access containment.wallpaper
310
//expose the current wallpaper into the corona QML
311
if (containment->wallpaper()) {
312
QDeclarativeProperty containmentProperty(m_homeScreen, "activeWallpaper");
313
containmentProperty.write(QVariant::fromValue(static_cast<QObject*>(containment->wallpaper())));
316
321
m_currentContainment = containment;
327
332
connect(m_corona, SIGNAL(containmentAdded(Plasma::Containment*)),
328
333
this, SLOT(manageNewContainment(Plasma::Containment*)), Qt::QueuedConnection);
329
334
connect(m_corona, SIGNAL(configSynced()), this, SLOT(syncConfig()));
330
connect(m_corona, SIGNAL(screenOwnerChanged(int, int, Plasma::Containment *)), this, SLOT(containmentScreenOwnerChanged(int,int,Plasma::Containment*)));
335
connect(m_corona, SIGNAL(screenOwnerChanged(int,int,Plasma::Containment*)), this, SLOT(containmentScreenOwnerChanged(int,int,Plasma::Containment*)));
333
338
// setup our QML home screen;
389
394
connect(containment, SIGNAL(configureRequested(Plasma::Containment*)),
390
395
this, SLOT(showActivityConfiguration(Plasma::Containment*)));
393
//put it into the main scene:
394
//if it's on an edge find a qml element propely named
395
//otherwise delete it
396
QString containmentPanelName;
398
switch (containment->location()) {
399
case Plasma::LeftEdge:
400
containmentPanelName = "leftEdgePanel";
402
case Plasma::TopEdge:
403
containmentPanelName = "topEdgePanel";
405
case Plasma::RightEdge:
406
containmentPanelName = "rightEdgePanel";
408
case Plasma::BottomEdge:
409
containmentPanelName = "bottomEdgePanel";
416
if (!containmentPanelName.isEmpty()) {
417
QDeclarativeItem *containmentPanel = m_homeScreen->findChild<QDeclarativeItem*>(containmentPanelName);
419
if (containmentPanel) {
420
containment->setParentItem(containmentPanel);
421
containment->setParent(containmentPanel);
423
containmentPanel->metaObject()->invokeMethod(containmentPanel, "addContainment", Q_ARG(QVariant, QVariant::fromValue<QGraphicsWidget *>(containment)));
425
m_panelContainments.insert(containment->id(), containment);
427
//done, don't need further management
430
//no panel? discard the containment
431
containment->deleteLater();
399
if (containment->location() == Plasma::LeftEdge ||
400
containment->location() == Plasma::TopEdge ||
401
containment->location() == Plasma::RightEdge ||
402
containment->location() == Plasma::BottomEdge) {
405
m_panelContainments.insert(containment->id(), containment);
407
//add the panel into the QML homescreen
408
m_homeScreen->metaObject()->invokeMethod(m_homeScreen, "addPanel",
409
Q_ARG(QVariant, QVariant::fromValue<QGraphicsWidget *>(containment)),
410
Q_ARG(QVariant, containment->formFactor()),
411
Q_ARG(QVariant, containment->location()));
413
//done, don't need further management
438
419
// to retrieve it later.
439
420
m_containments.insert(containment->id(), containment);
441
connect(containment, SIGNAL(destroyed(QObject *)), this, SLOT(containmentDestroyed(QObject *)));
422
connect(containment, SIGNAL(destroyed(QObject*)), this, SLOT(containmentDestroyed(QObject*)));
443
424
containment->resize(m_mainView->size());
452
433
// we need our homescreen to show something!
453
// for the alternate screen (such as a launcher) we need a containment setted as excludeFromActivities
454
//FIXME: use only the declarativeSlot key?
455
434
if (containment->config().readEntry("excludeFromActivities", false)) {
456
const QString declarativeSlot = containment->config().readEntry("declarativeSlot", "alternateSlot");
457
QDeclarativeItem *alternateSlot = m_homeScreen->findChild<QDeclarativeItem*>(declarativeSlot);
460
m_alternateContainments << containment;
461
alternateSlot->setProperty("width", m_mainView->size().width());
462
alternateSlot->setProperty("height", m_mainView->size().height());
463
containment->setParentItem(alternateSlot);
464
containment->setParent(alternateSlot);
465
containment->setPos(0, 0);
466
containment->setVisible(true);
436
//Don't remove this empty branch
469
437
} else if (containment->screen() > -1) {
470
438
changeContainment(containment);
455
void PlasmaApp::activeWindowChanged(WId id)
457
m_homeScreen->setProperty("windowActive", (id == m_mainView->winId()));
487
460
void PlasmaApp::mainViewGeometryChanged()
489
462
if (m_declarativeWidget) {
495
468
m_declarativeWidget->setGeometry(m_mainView->mapToScene(QRect(QPoint(0,0), m_mainView->size())).boundingRect());
497
470
QRect availableScreenRect(QPoint(0,0), m_mainView->size());
498
QDeclarativeItem *availableScreenRectItem = m_homeScreen->findChild<QDeclarativeItem*>("availableScreenRect");
472
QDeclarativeItem *availableScreenRectItem = m_homeScreen->property("availableScreenRect").value<QDeclarativeItem*>();
499
474
//is there an item that defines the screen geometry?
500
475
if (availableScreenRectItem) {
501
476
availableScreenRect = QRect((int)availableScreenRectItem->property("x").toReal(),
516
491
if (m_currentContainment) {
517
492
m_currentContainment->resize(m_mainView->size());
519
foreach (Plasma::Containment *cont, m_alternateContainments) {
520
cont->resize(m_mainView->size());
523
495
if (m_widgetsExplorer) {
524
496
m_widgetsExplorer.data()->setGeometry(m_declarativeWidget->geometry());