2 * Copyright (C) 2013-2016 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)
47 , m_shellChrome(Mir::NormalChrome)
51ApplicationInfo::ApplicationInfo(QObject *parent)
52 : ApplicationInfoInterface(QString(), parent)
58 , m_supportedOrientations(Qt::PortraitOrientation |
59 Qt::LandscapeOrientation |
60 Qt::InvertedPortraitOrientation |
61 Qt::InvertedLandscapeOrientation)
62 , m_rotatesWindowContents(false)
63 , m_requestedState(RequestedRunning)
65 , m_exemptFromLifecycle(false)
66 , m_manualSurfaceCreation(false)
67 , m_shellChrome(Mir::NormalChrome)
71ApplicationInfo::~ApplicationInfo()
76void ApplicationInfo::createSession()
78 if (m_session || state() == ApplicationInfo::Stopped) { return; }
80 setSession(SessionManager::singleton()->createSession(appId(), m_screenshotFileName));
83void ApplicationInfo::destroySession()
85 Session *session = this->session();
90void ApplicationInfo::setSession(Session* session)
92 if (m_session == session)
96 disconnect(this, 0, m_session, 0);
97 m_session->setApplication(nullptr);
98 m_session->setParent(nullptr);
99 Q_EMIT m_session->deregister();
105 m_session->setApplication(this);
106 m_session->setParent(this);
107 m_session->setFullscreen(m_fullscreen);
108 SessionManager::singleton()->registerSession(m_session);
109 connect(m_session, &Session::surfaceAdded,
110 this, &ApplicationInfo::onSessionSurfaceAdded);
111 connect(m_session, &Session::fullscreenChanged, this, &ApplicationInfo::fullscreenChanged);
113 if (!m_manualSurfaceCreation) {
114 QTimer::singleShot(500, m_session, &Session::createSurface);
118 Q_EMIT sessionChanged(m_session);
121void ApplicationInfo::setIconId(const QString &iconId)
123 setIcon(QUrl(testDataDir() + "/graphics/applicationIcons/" + iconId + "@18.png"));
126void ApplicationInfo::setScreenshotId(const QString &screenshotId)
128 QString screenshotFileName;
130 if (screenshotId.endsWith(".svg")) {
131 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2")
134 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2@12.png")
138 if (screenshotFileName != m_screenshotFileName) {
139 m_screenshotFileName = screenshotFileName;
142 m_session->setScreenshot(screenshotFileName);
147void ApplicationInfo::setName(const QString &value)
149 if (value != m_name) {
151 Q_EMIT nameChanged(value);
155void ApplicationInfo::setIcon(const QUrl &value)
157 if (value != m_icon) {
159 Q_EMIT iconChanged(value);
163void ApplicationInfo::setStage(Stage value)
165 if (value != m_stage) {
167 Q_EMIT stageChanged(value);
171void ApplicationInfo::setState(State value)
173 if (value != m_state) {
175 Q_EMIT stateChanged(value);
177 if (!m_manualSurfaceCreation && !m_session && m_state == ApplicationInfo::Starting) {
178 QTimer::singleShot(500, this, &ApplicationInfo::createSession);
179 } else if (m_state == ApplicationInfo::Stopped) {
180 Session *session = m_session;
187void ApplicationInfo::setFocused(bool value)
189 if (value != m_focused) {
191 Q_EMIT focusedChanged(value);
195void ApplicationInfo::setFullscreen(bool value)
197 m_fullscreen = value;
199 m_session->setFullscreen(value);
203bool ApplicationInfo::fullscreen() const
205 return m_session ? m_session->fullscreen() : m_fullscreen;
208void ApplicationInfo::setManualSurfaceCreation(bool value)
210 if (value != m_manualSurfaceCreation) {
211 m_manualSurfaceCreation = value;
212 Q_EMIT manualSurfaceCreationChanged(value);
216Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
218 return m_supportedOrientations;
221void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
223 m_supportedOrientations = orientations;
226bool ApplicationInfo::rotatesWindowContents() const
228 return m_rotatesWindowContents;
231void ApplicationInfo::setRotatesWindowContents(bool value)
233 m_rotatesWindowContents = value;
236ApplicationInfo::RequestedState ApplicationInfo::requestedState() const
238 return m_requestedState;
241void ApplicationInfo::setRequestedState(RequestedState value)
243 if (m_requestedState != value) {
244 m_requestedState = value;
245 Q_EMIT requestedStateChanged(m_requestedState);
247 if (m_requestedState == RequestedRunning && m_state == Suspended) {
249 } else if (m_requestedState == RequestedSuspended && m_state == Running) {
255bool ApplicationInfo::isTouchApp() const
260void ApplicationInfo::setIsTouchApp(bool isTouchApp)
262 m_isTouchApp = isTouchApp;
265void ApplicationInfo::onSessionSurfaceAdded(MirSurface* surface)
267 if (surface != nullptr && m_state == Starting) {
268 if (m_requestedState == RequestedRunning) {
273 surface->setShellChrome(m_shellChrome);
277bool ApplicationInfo::exemptFromLifecycle() const
279 return m_exemptFromLifecycle;
282void ApplicationInfo::setExemptFromLifecycle(bool exemptFromLifecycle)
284 if (m_exemptFromLifecycle != exemptFromLifecycle)
286 m_exemptFromLifecycle = exemptFromLifecycle;
287 Q_EMIT exemptFromLifecycleChanged(m_exemptFromLifecycle);
291QSize ApplicationInfo::initialSurfaceSize() const
293 return m_initialSurfaceSize;
296void ApplicationInfo::setInitialSurfaceSize(const QSize &size)
298 if (size != m_initialSurfaceSize) {
299 m_initialSurfaceSize = size;
300 Q_EMIT initialSurfaceSizeChanged(m_initialSurfaceSize);
304void ApplicationInfo::setShellChrome(Mir::ShellChrome shellChrome)
306 m_shellChrome = shellChrome;
307 if (m_session && m_session->lastSurface()) {
308 m_session->lastSurface()->setShellChrome(shellChrome);
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