2 * Copyright (C) 2013-2015 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 "MirSurface.h"
20#include "SessionManager.h"
24#include <QGuiApplication>
27#include <QQmlComponent>
30ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
31 : ApplicationInfoInterface(appId, parent)
38 , m_supportedOrientations(Qt::PortraitOrientation |
39 Qt::LandscapeOrientation |
40 Qt::InvertedPortraitOrientation |
41 Qt::InvertedLandscapeOrientation)
42 , m_rotatesWindowContents(false)
43 , m_requestedState(RequestedRunning)
44 , m_manualSurfaceCreation(false)
48ApplicationInfo::ApplicationInfo(QObject *parent)
49 : ApplicationInfoInterface(QString(), parent)
55 , m_supportedOrientations(Qt::PortraitOrientation |
56 Qt::LandscapeOrientation |
57 Qt::InvertedPortraitOrientation |
58 Qt::InvertedLandscapeOrientation)
59 , m_rotatesWindowContents(false)
60 , m_requestedState(RequestedRunning)
61 , m_manualSurfaceCreation(false)
65ApplicationInfo::~ApplicationInfo()
70void ApplicationInfo::createSession()
72 if (m_session || state() == ApplicationInfo::Stopped) { return; }
74 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
75 setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
78void ApplicationInfo::destroySession()
80 Session *session = this->session();
85void ApplicationInfo::setSession(Session* session)
87 if (m_session == session)
91 disconnect(this, 0, m_session, 0);
92 m_session->setApplication(nullptr);
93 m_session->setParent(nullptr);
94 Q_EMIT m_session->deregister();
100 m_session->setApplication(this);
101 m_session->setParent(this);
102 SessionManager::singleton()->registerSession(m_session);
103 connect(m_session, &Session::surfaceChanged,
104 this, &ApplicationInfo::onSessionSurfaceChanged);
106 if (!m_manualSurfaceCreation) {
107 QTimer::singleShot(500, m_session, &Session::createSurface);
111 Q_EMIT sessionChanged(m_session);
114void ApplicationInfo::setIconId(const QString &iconId)
116 setIcon(QString("file://%1/graphics/applicationIcons/%2@18.png")
121void ApplicationInfo::setScreenshotId(const QString &screenshotId)
123 QString screenshotFileName;
125 if (screenshotId.endsWith(".svg")) {
126 screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2")
130 screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
135 if (screenshotFileName != m_screenshotFileName) {
136 m_screenshotFileName = screenshotFileName;
138 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
140 m_session->setScreenshot(screenshotUrl);
145void ApplicationInfo::setName(const QString &value)
147 if (value != m_name) {
149 Q_EMIT nameChanged(value);
153void ApplicationInfo::setIcon(const QUrl &value)
155 if (value != m_icon) {
157 Q_EMIT iconChanged(value);
161void ApplicationInfo::setStage(Stage value)
163 if (value != m_stage) {
165 Q_EMIT stageChanged(value);
169void ApplicationInfo::setState(State value)
171 if (value != m_state) {
173 Q_EMIT stateChanged(value);
175 if (!m_manualSurfaceCreation && !m_session && m_state == ApplicationInfo::Starting) {
176 QTimer::singleShot(500, this, &ApplicationInfo::createSession);
177 } else if (m_state == ApplicationInfo::Stopped) {
178 Session *session = m_session;
185void ApplicationInfo::setFocused(bool value)
187 if (value != m_focused) {
189 Q_EMIT focusedChanged(value);
193void ApplicationInfo::setFullscreen(bool value)
195 if (value != m_fullscreen) {
196 m_fullscreen = value;
197 Q_EMIT fullscreenChanged(value);
201void ApplicationInfo::setManualSurfaceCreation(bool value)
203 if (value != m_manualSurfaceCreation) {
204 m_manualSurfaceCreation = value;
205 Q_EMIT manualSurfaceCreationChanged(value);
209Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
211 return m_supportedOrientations;
214void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
216 m_supportedOrientations = orientations;
219bool ApplicationInfo::rotatesWindowContents() const
221 return m_rotatesWindowContents;
224void ApplicationInfo::setRotatesWindowContents(bool value)
226 m_rotatesWindowContents = value;
229ApplicationInfo::RequestedState ApplicationInfo::requestedState() const
231 return m_requestedState;
234void ApplicationInfo::setRequestedState(RequestedState value)
236 if (m_requestedState != value) {
237 m_requestedState = value;
238 Q_EMIT requestedStateChanged(m_requestedState);
240 if (m_requestedState == RequestedRunning && m_state == Suspended) {
242 } else if (m_requestedState == RequestedSuspended && m_state == Running) {
248void ApplicationInfo::onSessionSurfaceChanged(MirSurface* surface)
250 if (surface != nullptr && m_state == Starting) {
251 if (m_requestedState == RequestedRunning) {
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