@@ -48,11 +48,6 @@ ApplicationManager *ApplicationManager::singleton()
4848ApplicationManager::ApplicationManager(QObject *parent)
4949 : ApplicationManagerInterface(parent)
5050 , m_suspended(false)
51− , m_mainStageComponent(0)
52− , m_mainStage(0)
53− , m_sideStageComponent(0)
54− , m_sideStage(0)
55− , m_rightMargin(0)
5651{
5752 m_roleNames.insert(RoleSurface, "surface");
5853 m_roleNames.insert(RoleFullscreen, "fullscreen");
@@ -300,39 +295,25 @@ bool ApplicationManager::focusApplication(const QString &appId)
300295 for (ApplicationInfo *app : m_runningApplications) {
301296 if (app->focused() && app->stage() == ApplicationInfo::MainStage) {
302297 app->setFocused(false);
303− app->hideWindow();
304298 app->setState(ApplicationInfo::Suspended);
305299 }
306300 }
307301
308302 // focus this app
309303 application->setFocused(true);
310− if (!m_mainStage)
311− createMainStage();
312304 application->setState(ApplicationInfo::Running);
313− application->showWindow(m_mainStage);
314− m_mainStage->setZ(-1000);
315− if (m_sideStage)
316− m_sideStage->setZ(-2000);
317305 } else if (application->stage() == ApplicationInfo::SideStage) {
318306 // unfocus currently focused sidestage app
319307 for (ApplicationInfo *app : m_runningApplications) {
320308 if (app->focused() && app->stage() == ApplicationInfo::SideStage) {
321309 app->setFocused(false);
322− app->hideWindow();
323310 app->setState(ApplicationInfo::Suspended);
324311 }
325312 }
326313
327314 // focus this app
328315 application->setFocused(true);
329− if (!m_sideStage)
330− createSideStage();
331316 application->setState(ApplicationInfo::Running);
332− application->showWindow(m_sideStage);
333− m_sideStage->setZ(-1000);
334− if (m_mainStage)
335− m_mainStage->setZ(-2000);
336317 }
337318
338319 // move app to top of stack
@@ -354,7 +335,6 @@ void ApplicationManager::unfocusCurrentApplication()
354335{
355336 for (ApplicationInfo *app : m_runningApplications) {
356337 if (app->focused()) {
357− app->hideWindow();
358338 app->setFocused(false);
359339 }
360340 }
@@ -363,42 +343,6 @@ void ApplicationManager::unfocusCurrentApplication()
363343
364344void ApplicationManager::generateQmlStrings(ApplicationInfo *application)
365345{
366− // TODO: Is there a better way of solving this fullscreen vs. regular
367− // application height?
368− QString topMargin;
369− if (application->fullscreen()) {
370− topMargin.append("0");
371− } else {
372− // Taken from Panel.panelHeight
373− topMargin.append("units.gu(3) + units.dp(2)");
374− }
375−
376− QString windowQml = QString(
377− "import QtQuick 2.0\n"
378− "Image {\n"
379− " anchors.fill: parent\n"
380− " anchors.topMargin: %1\n"
381− " anchors.rightMargin: %2\n"
382− " source: \"file://%3/Dash/graphics/phone/screenshots/%4.png\"\n"
383− " smooth: true\n"
384− " fillMode: Image.PreserveAspectCrop\n"
385− "}").arg(topMargin)
386− .arg(m_rightMargin)
387− .arg(qmlDirectory())
388− .arg(application->icon().toString());
389− application->setWindowQml(windowQml);
390−
391− QString imageQml = QString(
392− "import QtQuick 2.0\n"
393− "Image {\n"
394− " anchors.fill: parent\n"
395− " source: \"file://%1/Dash/graphics/phone/screenshots/%2.png\"\n"
396− " smooth: true\n"
397− " fillMode: Image.PreserveAspectCrop\n"
398− "}").arg(qmlDirectory())
399− .arg(application->icon().toString());
400− application->setImageQml(imageQml);
401−
402346 application->setScreenshot(QString("file://%1/Dash/graphics/phone/screenshots/%2@12.png").arg(qmlDirectory())
403347 .arg(application->icon().toString()));
404348}
@@ -535,78 +479,6 @@ void ApplicationManager::buildListOfAvailableApplications()
535479 m_availableApplications.append(application);
536480}
537481
538−void ApplicationManager::createMainStageComponent()
539−{
540− // The assumptions I make here really should hold.
541− QQuickView *quickView =
542− qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
543−
544− QQmlEngine *engine = quickView->engine();
545−
546− m_mainStageComponent = new QQmlComponent(engine, this);
547− QString mainStageQml =
548− "import QtQuick 2.0\n"
549− "Rectangle {\n"
550− " anchors.fill: parent\n"
551− " color: 'black'\n"
552− " z: -2000\n"
553− "}\n";
554− m_mainStageComponent->setData(mainStageQml.toLatin1(), QUrl());
555−}
556−
557−void ApplicationManager::createMainStage()
558−{
559− if (!m_mainStageComponent)
560− createMainStageComponent();
561−
562− // The assumptions I make here really should hold.
563− QQuickView *quickView =
564− qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
565−
566− QQuickItem *shell = quickView->rootObject();
567−
568− m_mainStage = qobject_cast<QQuickItem *>(m_mainStageComponent->create());
569− m_mainStage->setParentItem(shell);
570−}
571−
572−void ApplicationManager::createSideStageComponent()
573−{
574− // The assumptions I make here really should hold.
575− QQuickView *quickView =
576− qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
577−
578− QQmlEngine *engine = quickView->engine();
579−
580− m_sideStageComponent = new QQmlComponent(engine, this);
581− QString sideStageQml =
582− "import QtQuick 2.0\n"
583− "import Ubuntu.Components 0.1\n"
584− "Item {\n"
585− " width: units.gu(40)\n" // from SideStage in Shell.qml
586− " anchors.top: parent.top\n"
587− " anchors.bottom: parent.bottom\n"
588− " anchors.right: parent.right\n"
589− " z: -1000\n"
590− "}\n";
591− m_sideStageComponent->setData(sideStageQml.toLatin1(), QUrl());
592−}
593−
594−void ApplicationManager::createSideStage()
595−{
596− if (!m_sideStageComponent)
597− createSideStageComponent();
598−
599− // The assumptions I make here really should hold.
600− QQuickView *quickView =
601− qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
602−
603− QQuickItem *shell = quickView->rootObject();
604−
605− m_sideStage = qobject_cast<QQuickItem *>(m_sideStageComponent->create());
606− m_sideStage->setParentItem(shell);
607− m_sideStage->setFlag(QQuickItem::ItemHasContents, false);
608−}
609−
610482QStringList ApplicationManager::availableApplications()
611483{
612484 QStringList appIds;
@@ -616,19 +488,6 @@ QStringList ApplicationManager::availableApplications()
616488 return appIds;
617489}
618490
619−int ApplicationManager::rightMargin() const
620−{
621− return m_rightMargin;
622−}
623−
624−void ApplicationManager::setRightMargin(int rightMargin)
625−{
626− m_rightMargin = rightMargin;
627− Q_FOREACH(ApplicationInfo *app, m_availableApplications) {
628− generateQmlStrings(app);
629− }
630−}
631−
632491bool ApplicationManager::isEmpty() const
633492{
634493 return m_runningApplications.isEmpty();