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 Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(m_surface);
58 m_surface->deleteLater();
63void ApplicationInfo::createSurface()
65 if (m_surface || state() == ApplicationInfo::Stopped) return;
67 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
69 setSurface(new MirSurfaceItem(name(),
70 MirSurfaceItem::Normal,
71 fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
75void ApplicationInfo::setSurface(MirSurfaceItem* surface)
77 qDebug() << "Application::setSurface - appId=" << appId() << "surface=" << surface;
78 if (m_surface == surface)
82 m_surface->setApplication(nullptr);
83 m_surface->setParent(nullptr);
84 SurfaceManager::singleton()->unregisterSurface(m_surface);
90 m_surface->setApplication(this);
91 m_surface->setParent(this);
92 SurfaceManager::singleton()->registerSurface(m_surface);
95 Q_EMIT surfaceChanged(m_surface);
96 SurfaceManager::singleton()->registerSurface(m_surface);
99void ApplicationInfo::addPromptSurface(MirSurfaceItem* surface)
101 qDebug() << "ApplicationInfo::addPromptSurface " << surface->name() << " to " << name();
102 if (surface == m_surface || m_promptSurfaces.contains(surface)) return;
104 surface->setApplication(this);
105 m_promptSurfaces.append(surface);
106 Q_EMIT promptSurfacesChanged();
109void ApplicationInfo::removeSurface(MirSurfaceItem* surface)
111 if (m_surface == surface) {
113 } else if (m_promptSurfaces.contains(surface)) {
114 qDebug() << "Application::removeSurface " << surface->name() << " from " << name();
116 m_promptSurfaces.removeAll(surface);
117 surface->setApplication(nullptr);
119 Q_EMIT promptSurfacesChanged();
123QList<MirSurfaceItem*> ApplicationInfo::promptSurfaceList() const
125 return m_promptSurfaces;
128QQmlListProperty<MirSurfaceItem> ApplicationInfo::promptSurfaces()
130 return QQmlListProperty<MirSurfaceItem>(this,
132 ApplicationInfo::promptSurfaceCount,
133 ApplicationInfo::promptSurfaceAt);
136int ApplicationInfo::promptSurfaceCount(QQmlListProperty<MirSurfaceItem> *prop)
138 ApplicationInfo *p = qobject_cast<ApplicationInfo*>(prop->object);
139 return p->m_promptSurfaces.count();
142MirSurfaceItem* ApplicationInfo::promptSurfaceAt(QQmlListProperty<MirSurfaceItem> *prop, int index)
144 ApplicationInfo *p = qobject_cast<ApplicationInfo*>(prop->object);
146 if (index < 0 || index >= p->m_promptSurfaces.count())
148 return p->m_promptSurfaces[index];
151void ApplicationInfo::setIconId(const QString &iconId)
153 setIcon(QString("file://%1/graphics/applicationIcons/%2@18.png")
158void ApplicationInfo::setScreenshotId(const QString &screenshotId)
160 m_screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
165void ApplicationInfo::setName(const QString &value)
167 if (value != m_name) {
169 Q_EMIT nameChanged(value);
173void ApplicationInfo::setIcon(const QUrl &value)
175 if (value != m_icon) {
177 Q_EMIT iconChanged(value);
181void ApplicationInfo::setStage(Stage value)
183 if (value != m_stage) {
185 Q_EMIT stageChanged(value);
189void ApplicationInfo::setState(State value)
191 if (value != m_state) {
193 Q_EMIT stateChanged(value);
195 if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
196 QTimer::singleShot(1000, this, SLOT(createSurface()));
201void ApplicationInfo::setFocused(bool value)
203 if (value != m_focused) {
205 Q_EMIT focusedChanged(value);
209void ApplicationInfo::setFullscreen(bool value)
211 if (value != m_fullscreen) {
212 m_fullscreen = value;
213 Q_EMIT fullscreenChanged(value);
217void ApplicationInfo::setManualSurfaceCreation(bool value)
219 if (value != m_manualSurfaceCreation) {
220 m_manualSurfaceCreation = value;
221 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