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"
21#include <QGuiApplication>
24#include <QQmlComponent>
27ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
28 : ApplicationInfoInterface(appId, parent)
37 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
40ApplicationInfo::ApplicationInfo(QObject *parent)
41 : ApplicationInfoInterface(QString(), parent)
49 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
52ApplicationInfo::~ApplicationInfo()
55 Q_EMIT SurfaceManager::singleton()->surfaceDestroyed(m_surface);
56 m_surface->deleteLater();
60void ApplicationInfo::onStateChanged(State state)
62 if (state == ApplicationInfo::Running) {
63 QTimer::singleShot(1000, this, SLOT(createSurface()));
64 } else if (state == ApplicationInfo::Stopped) {
69void ApplicationInfo::createSurface()
71 if (m_surface || state() == ApplicationInfo::Stopped) return;
73 setSurface(new MirSurfaceItem(name(),
74 MirSurfaceItem::Normal,
75 fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
79void ApplicationInfo::setSurface(MirSurfaceItem* surface)
81 if (m_surface == surface)
85 m_surface->setApplication(nullptr);
86 m_surface->setParent(nullptr);
87 SurfaceManager::singleton()->unregisterSurface(m_surface);
93 m_surface->setApplication(this);
94 m_surface->setParent(this);
95 SurfaceManager::singleton()->registerSurface(m_surface);
98 Q_EMIT surfaceChanged(m_surface);
99 SurfaceManager::singleton()->registerSurface(m_surface);
102void ApplicationInfo::removeSurface(MirSurfaceItem* surface)
104 if (m_surface == surface) {
106 } else if (m_promptSurfaces.contains(surface)) {
107 m_promptSurfaces.removeAll(surface);
108 surface->setApplication(nullptr);
110 Q_EMIT promptSurfacesChanged();
114void ApplicationInfo::addPromptSurface(MirSurfaceItem* surface)
116 if (surface == m_surface || m_promptSurfaces.contains(surface)) return;
118 surface->setApplication(this);
119 m_promptSurfaces.append(surface);
120 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];
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