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(QString("../../tests/graphics/applicationIcons/%2@18.png")
127void ApplicationInfo::setScreenshotId(const QString &screenshotId)
129 QString screenshotFileName;
131 if (screenshotId.endsWith(".svg")) {
132 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2")
135 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2@12.png")
139 if (screenshotFileName != m_screenshotFileName) {
140 m_screenshotFileName = screenshotFileName;
143 m_session->setScreenshot(screenshotFileName);
148void ApplicationInfo::setName(const QString &value)
150 if (value != m_name) {
152 Q_EMIT nameChanged(value);
156void ApplicationInfo::setIcon(const QUrl &value)
158 if (value != m_icon) {
160 Q_EMIT iconChanged(value);
164void ApplicationInfo::setStage(Stage value)
166 if (value != m_stage) {
168 Q_EMIT stageChanged(value);
172void ApplicationInfo::setState(State value)
174 if (value != m_state) {
176 Q_EMIT stateChanged(value);
178 if (!m_manualSurfaceCreation && !m_session && m_state == ApplicationInfo::Starting) {
179 QTimer::singleShot(500, this, &ApplicationInfo::createSession);
180 } else if (m_state == ApplicationInfo::Stopped) {
181 Session *session = m_session;
188void ApplicationInfo::setFocused(bool value)
190 if (value != m_focused) {
192 Q_EMIT focusedChanged(value);
196void ApplicationInfo::setFullscreen(bool value)
198 m_fullscreen = value;
200 m_session->setFullscreen(value);
204bool ApplicationInfo::fullscreen() const
206 return m_session ? m_session->fullscreen() : m_fullscreen;
209void ApplicationInfo::setManualSurfaceCreation(bool value)
211 if (value != m_manualSurfaceCreation) {
212 m_manualSurfaceCreation = value;
213 Q_EMIT manualSurfaceCreationChanged(value);
217Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
219 return m_supportedOrientations;
222void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
224 m_supportedOrientations = orientations;
227bool ApplicationInfo::rotatesWindowContents() const
229 return m_rotatesWindowContents;
232void ApplicationInfo::setRotatesWindowContents(bool value)
234 m_rotatesWindowContents = value;
237ApplicationInfo::RequestedState ApplicationInfo::requestedState() const
239 return m_requestedState;
242void ApplicationInfo::setRequestedState(RequestedState value)
244 if (m_requestedState != value) {
245 m_requestedState = value;
246 Q_EMIT requestedStateChanged(m_requestedState);
248 if (m_requestedState == RequestedRunning && m_state == Suspended) {
250 } else if (m_requestedState == RequestedSuspended && m_state == Running) {
256bool ApplicationInfo::isTouchApp() const
261void ApplicationInfo::setIsTouchApp(bool isTouchApp)
263 m_isTouchApp = isTouchApp;
266void ApplicationInfo::onSessionSurfaceAdded(MirSurface* surface)
268 if (surface != nullptr && m_state == Starting) {
269 if (m_requestedState == RequestedRunning) {
274 surface->setShellChrome(m_shellChrome);
278bool ApplicationInfo::exemptFromLifecycle() const
280 return m_exemptFromLifecycle;
283void ApplicationInfo::setExemptFromLifecycle(bool exemptFromLifecycle)
285 if (m_exemptFromLifecycle != exemptFromLifecycle)
287 m_exemptFromLifecycle = exemptFromLifecycle;
288 Q_EMIT exemptFromLifecycleChanged(m_exemptFromLifecycle);
292QSize ApplicationInfo::initialSurfaceSize() const
294 return m_initialSurfaceSize;
297void ApplicationInfo::setInitialSurfaceSize(const QSize &size)
299 if (size != m_initialSurfaceSize) {
300 m_initialSurfaceSize = size;
301 Q_EMIT initialSurfaceSizeChanged(m_initialSurfaceSize);
305void ApplicationInfo::setShellChrome(Mir::ShellChrome shellChrome)
307 m_shellChrome = shellChrome;
308 if (m_session && m_session->lastSurface()) {
309 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