2 * Copyright (C) 2013 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17#include "ApplicationInfo.h"
18#include "MirSurfaceItem.h"
19#include "SurfaceManager.h"
21#include <QGuiApplication>
24#include <QQmlComponent>
27ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
28 : ApplicationInfoInterface(appId, parent)
35 , m_windowComponent(0)
39 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
42ApplicationInfo::ApplicationInfo(QObject *parent)
43 : ApplicationInfoInterface(QString(), parent)
49 , m_windowComponent(0)
53 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
56ApplicationInfo::~ApplicationInfo()
59 Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(m_surface);
60 m_surface->deleteLater();
64void ApplicationInfo::onWindowComponentStatusChanged(QQmlComponent::Status status)
66 if (status == QQmlComponent::Ready && !m_windowItem)
70void ApplicationInfo::onStateChanged(State state)
72 if (state == ApplicationInfo::Running) {
73 QTimer::singleShot(1000, this, SLOT(createSurface()));
74 } else if (state == ApplicationInfo::Stopped) {
79void ApplicationInfo::createSurface()
81 if (m_surface || state() == ApplicationInfo::Stopped) return;
83 m_surface = new MirSurfaceItem(name(),
84 MirSurfaceItem::Normal,
85 fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
87 Q_EMIT surfaceChanged(m_surface);
88 Q_EMIT SurfaceManager::singleton()->surfaceCreated(m_surface);
91void ApplicationInfo::destroySurface()
93 if (!m_surface) return;
94 MirSurfaceItem* oldSurface = m_surface;
97 Q_EMIT surfaceChanged(nullptr);
98 Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(oldSurface);
99 oldSurface->deleteLater();
102void ApplicationInfo::createWindowComponent()
104 // The assumptions I make here really should hold.
105 QQuickView *quickView =
106 qobject_cast<QQuickView*>(QGuiApplication::topLevelWindows()[0]);
108 QQmlEngine *engine = quickView->engine();
110 m_windowComponent = new QQmlComponent(engine, this);
111 m_windowComponent->setData(m_windowQml.toLatin1(), QUrl());
114void ApplicationInfo::doCreateWindowItem()
116 m_windowItem = qobject_cast<QQuickItem *>(m_windowComponent->create());
117 m_windowItem->setParentItem(m_parentItem);
120void ApplicationInfo::createWindowItem()
122 if (!m_windowComponent)
123 createWindowComponent();
125 // only create the windowItem once the component is ready
126 if (!m_windowComponent->isReady()) {
127 connect(m_windowComponent, &QQmlComponent::statusChanged,
128 this, &ApplicationInfo::onWindowComponentStatusChanged);
130 doCreateWindowItem();
134void ApplicationInfo::showWindow(QQuickItem *parent)
136 m_parentItem = parent;
142 m_windowItem->setVisible(true);
146void ApplicationInfo::hideWindow()
151 m_windowItem->setVisible(false);
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list