2 * Copyright (C) 2013-2014 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"
23#include <QGuiApplication>
26#include <QQmlComponent>
29ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
30 : ApplicationInfoInterface(appId, parent)
37 , m_manualSurfaceCreation(false)
42ApplicationInfo::ApplicationInfo(QObject *parent)
43 : ApplicationInfoInterface(QString(), parent)
49 , m_manualSurfaceCreation(false)
54ApplicationInfo::~ApplicationInfo()
57 // break the cyclic reference before destroying it
58 m_surface->setApplication(nullptr);
60 Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(m_surface);
61 m_surface->deleteLater();
65void ApplicationInfo::createSurface()
67 if (m_surface || state() == ApplicationInfo::Stopped) return;
69 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
71 setSurface(new MirSurfaceItem(name(),
72 MirSurfaceItem::Normal,
73 fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
77void ApplicationInfo::setSurface(MirSurfaceItem* surface)
79 qDebug() << "Application::setSurface - appId=" << appId() << "surface=" << surface;
80 if (m_surface == surface)
84 m_surface->setApplication(nullptr);
85 m_surface->setParent(nullptr);
86 SurfaceManager::singleton()->unregisterSurface(m_surface);
92 m_surface->setApplication(this);
93 m_surface->setParent(this);
94 SurfaceManager::singleton()->registerSurface(m_surface);
97 Q_EMIT surfaceChanged(m_surface);
98 SurfaceManager::singleton()->registerSurface(m_surface);
101void ApplicationInfo::addPromptSurface(MirSurfaceItem* surface)
103 qDebug() << "ApplicationInfo::addPromptSurface " << surface->name() << " to " << name();
104 if (surface == m_surface || m_promptSurfaces.contains(surface)) return;
106 surface->setApplication(this);
107 m_promptSurfaces.append(surface);
108 Q_EMIT promptSurfacesChanged();
111void ApplicationInfo::removeSurface(MirSurfaceItem* surface)
113 if (m_surface == surface) {
115 } else if (m_promptSurfaces.contains(surface)) {
116 qDebug() << "Application::removeSurface " << surface->name() << " from " << name();
118 m_promptSurfaces.removeAll(surface);
119 surface->setApplication(nullptr);
121 Q_EMIT promptSurfacesChanged();
125QList<MirSurfaceItem*> ApplicationInfo::promptSurfaceList() const
127 return m_promptSurfaces;
130QQmlListProperty<MirSurfaceItem> ApplicationInfo::promptSurfaces()
132 return QQmlListProperty<MirSurfaceItem>(this,
134 ApplicationInfo::promptSurfaceCount,
135 ApplicationInfo::promptSurfaceAt);
138int ApplicationInfo::promptSurfaceCount(QQmlListProperty<MirSurfaceItem> *prop)
140 ApplicationInfo *p = qobject_cast<ApplicationInfo*>(prop->object);
141 return p->m_promptSurfaces.count();
144MirSurfaceItem* ApplicationInfo::promptSurfaceAt(QQmlListProperty<MirSurfaceItem> *prop, int index)
146 ApplicationInfo *p = qobject_cast<ApplicationInfo*>(prop->object);
148 if (index < 0 || index >= p->m_promptSurfaces.count())
150 return p->m_promptSurfaces[index];
153void ApplicationInfo::setIconId(const QString &iconId)
155 setIcon(QString("file://%1/graphics/applicationIcons/%2@18.png")
160void ApplicationInfo::setScreenshotId(const QString &screenshotId)
162 m_screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
167void ApplicationInfo::setName(const QString &value)
169 if (value != m_name) {
171 Q_EMIT nameChanged(value);
175void ApplicationInfo::setIcon(const QUrl &value)
177 if (value != m_icon) {
179 Q_EMIT iconChanged(value);
183void ApplicationInfo::setStage(Stage value)
185 if (value != m_stage) {
187 Q_EMIT stageChanged(value);
191void ApplicationInfo::setState(State value)
193 if (value != m_state) {
195 Q_EMIT stateChanged(value);
197 if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
198 QTimer::singleShot(1000, this, SLOT(createSurface()));
203void ApplicationInfo::setFocused(bool value)
205 if (value != m_focused) {
207 Q_EMIT focusedChanged(value);
211void ApplicationInfo::setFullscreen(bool value)
213 if (value != m_fullscreen) {
214 m_fullscreen = value;
215 Q_EMIT fullscreenChanged(value);
219void ApplicationInfo::setManualSurfaceCreation(bool value)
221 if (value != m_manualSurfaceCreation) {
222 m_manualSurfaceCreation = value;
223 Q_EMIT manualSurfaceCreationChanged(value);
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