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)
45 , m_exemptFromLifecycle(false)
46 , m_manualSurfaceCreation(false)
50ApplicationInfo::ApplicationInfo(QObject *parent)
51 : ApplicationInfoInterface(QString(), parent)
57 , m_supportedOrientations(Qt::PortraitOrientation |
58 Qt::LandscapeOrientation |
59 Qt::InvertedPortraitOrientation |
60 Qt::InvertedLandscapeOrientation)
61 , m_rotatesWindowContents(false)
62 , m_requestedState(RequestedRunning)
64 , m_exemptFromLifecycle(false)
65 , m_manualSurfaceCreation(false)
69ApplicationInfo::~ApplicationInfo()
74void ApplicationInfo::createSession()
76 if (m_session || state() == ApplicationInfo::Stopped) { return; }
78 setSession(SessionManager::singleton()->createSession(appId(), m_screenshotFileName));
81void ApplicationInfo::destroySession()
83 Session *session = this->session();
88void ApplicationInfo::setSession(Session* session)
90 if (m_session == session)
94 disconnect(this, 0, m_session, 0);
95 m_session->setApplication(nullptr);
96 m_session->setParent(nullptr);
97 Q_EMIT m_session->deregister();
103 m_session->setApplication(this);
104 m_session->setParent(this);
105 SessionManager::singleton()->registerSession(m_session);
106 connect(m_session, &Session::surfaceAdded,
107 this, &ApplicationInfo::onSessionSurfaceAdded);
109 if (!m_manualSurfaceCreation) {
110 QTimer::singleShot(500, m_session, &Session::createSurface);
114 Q_EMIT sessionChanged(m_session);
117void ApplicationInfo::setIconId(const QString &iconId)
119 setIcon(QString("../../tests/graphics/applicationIcons/%2@18.png")
123void ApplicationInfo::setScreenshotId(const QString &screenshotId)
125 QString screenshotFileName;
127 if (screenshotId.endsWith(".svg")) {
128 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2")
131 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2@12.png")
135 if (screenshotFileName != m_screenshotFileName) {
136 m_screenshotFileName = screenshotFileName;
139 m_session->setScreenshot(screenshotFileName);
144void ApplicationInfo::setName(const QString &value)
146 if (value != m_name) {
148 Q_EMIT nameChanged(value);
152void ApplicationInfo::setIcon(const QUrl &value)
154 if (value != m_icon) {
156 Q_EMIT iconChanged(value);
160void ApplicationInfo::setStage(Stage value)
162 if (value != m_stage) {
164 Q_EMIT stageChanged(value);
168void ApplicationInfo::setState(State value)
170 if (value != m_state) {
172 Q_EMIT stateChanged(value);
174 if (!m_manualSurfaceCreation && !m_session && m_state == ApplicationInfo::Starting) {
175 QTimer::singleShot(500, this, &ApplicationInfo::createSession);
176 } else if (m_state == ApplicationInfo::Stopped) {
177 Session *session = m_session;
184void ApplicationInfo::setFocused(bool value)
186 if (value != m_focused) {
188 Q_EMIT focusedChanged(value);
192void ApplicationInfo::setFullscreen(bool value)
194 if (value != m_fullscreen) {
195 m_fullscreen = value;
196 Q_EMIT fullscreenChanged(value);
200void ApplicationInfo::setManualSurfaceCreation(bool value)
202 if (value != m_manualSurfaceCreation) {
203 m_manualSurfaceCreation = value;
204 Q_EMIT manualSurfaceCreationChanged(value);
208Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
210 return m_supportedOrientations;
213void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
215 m_supportedOrientations = orientations;
218bool ApplicationInfo::rotatesWindowContents() const
220 return m_rotatesWindowContents;
223void ApplicationInfo::setRotatesWindowContents(bool value)
225 m_rotatesWindowContents = value;
228ApplicationInfo::RequestedState ApplicationInfo::requestedState() const
230 return m_requestedState;
233void ApplicationInfo::setRequestedState(RequestedState value)
235 if (m_requestedState != value) {
236 m_requestedState = value;
237 Q_EMIT requestedStateChanged(m_requestedState);
239 if (m_requestedState == RequestedRunning && m_state == Suspended) {
241 } else if (m_requestedState == RequestedSuspended && m_state == Running) {
247bool ApplicationInfo::isTouchApp() const
252void ApplicationInfo::setIsTouchApp(bool isTouchApp)
254 m_isTouchApp = isTouchApp;
257void ApplicationInfo::onSessionSurfaceAdded(MirSurface* surface)
259 if (surface != nullptr && m_state == Starting) {
260 if (m_requestedState == RequestedRunning) {
268bool ApplicationInfo::exemptFromLifecycle() const
270 return m_exemptFromLifecycle;
273void ApplicationInfo::setExemptFromLifecycle(bool exemptFromLifecycle)
275 if (m_exemptFromLifecycle != exemptFromLifecycle)
277 m_exemptFromLifecycle = exemptFromLifecycle;
278 Q_EMIT exemptFromLifecycleChanged(m_exemptFromLifecycle);
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