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 "MirSurfaceItemModel.h"
21#include <QGuiApplication>
24#include <QQmlComponent>
27ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
28 : ApplicationInfoInterface(appId, parent)
36 , m_promptSurfaces(new MirSurfaceItemModel(this))
38 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
41ApplicationInfo::ApplicationInfo(QObject *parent)
42 : ApplicationInfoInterface(QString(), parent)
49 , m_promptSurfaces(new MirSurfaceItemModel(this))
51 connect(this, &ApplicationInfo::stateChanged, this, &ApplicationInfo::onStateChanged);
54ApplicationInfo::~ApplicationInfo()
56 QList<MirSurfaceItem*> promptSurfaces(m_promptSurfaces->list());
57 for (MirSurfaceItem* promptSurface : promptSurfaces) {
62 delete m_promptSurfaces;
65void ApplicationInfo::onStateChanged(State state)
67 if (state == ApplicationInfo::Running) {
68 QTimer::singleShot(1000, this, SLOT(createSurface()));
69 } else if (state == ApplicationInfo::Stopped) {
74void ApplicationInfo::createSurface()
76 if (m_surface || state() == ApplicationInfo::Stopped) return;
78 setSurface(SurfaceManager::singleton()->createSurface(name(),
79 MirSurfaceItem::Normal,
80 fullscreen() ? MirSurfaceItem::Fullscreen : MirSurfaceItem::Maximized,
84void ApplicationInfo::setSurface(MirSurfaceItem* surface)
86 qDebug() << "Application::setSurface - appId=" << appId() << "surface=" << surface;
87 if (m_surface == surface)
91 m_surface->setApplication(nullptr);
92 m_surface->setParent(nullptr);
98 m_surface->setApplication(this);
99 m_surface->setParent(this);
102 Q_EMIT surfaceChanged(m_surface);
105void ApplicationInfo::addPromptSurface(MirSurfaceItem* surface)
107 insertPromptSurface(m_promptSurfaces->count(), surface);
110void ApplicationInfo::insertPromptSurface(uint index, MirSurfaceItem* surface)
112 qDebug() << "ApplicationInfo::insertPromptSurface - " << surface->name() << " to " << name() << " @ " << index;
114 surface->setApplication(this);
115 m_promptSurfaces->insertSurface(index, surface);
118void ApplicationInfo::removeSurface(MirSurfaceItem* surface)
120 qDebug() << "Application::removeSurface - " << surface->name() << " from " << name();
122 if (m_surface == surface) {
125 m_promptSurfaces->removeSurface(surface);
126 surface->setApplication(nullptr);
130MirSurfaceItemModel* ApplicationInfo::promptSurfaces() const
132 return m_promptSurfaces;
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