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_manualSurfaceCreation(false)
49ApplicationInfo::ApplicationInfo(QObject *parent)
50 : ApplicationInfoInterface(QString(), parent)
56 , m_supportedOrientations(Qt::PortraitOrientation |
57 Qt::LandscapeOrientation |
58 Qt::InvertedPortraitOrientation |
59 Qt::InvertedLandscapeOrientation)
60 , m_rotatesWindowContents(false)
61 , m_requestedState(RequestedRunning)
63 , m_manualSurfaceCreation(false)
67ApplicationInfo::~ApplicationInfo()
72void ApplicationInfo::createSession()
74 if (m_session || state() == ApplicationInfo::Stopped) { return; }
76 setSession(SessionManager::singleton()->createSession(appId(), m_screenshotFileName));
79void ApplicationInfo::destroySession()
81 Session *session = this->session();
86void ApplicationInfo::setSession(Session* session)
88 if (m_session == session)
92 disconnect(this, 0, m_session, 0);
93 m_session->setApplication(nullptr);
94 m_session->setParent(nullptr);
95 Q_EMIT m_session->deregister();
101 m_session->setApplication(this);
102 m_session->setParent(this);
103 SessionManager::singleton()->registerSession(m_session);
104 connect(m_session, &Session::surfaceChanged,
105 this, &ApplicationInfo::onSessionSurfaceChanged);
107 if (!m_manualSurfaceCreation) {
108 QTimer::singleShot(500, m_session, &Session::createSurface);
112 Q_EMIT sessionChanged(m_session);
115void ApplicationInfo::setIconId(const QString &iconId)
117 setIcon(QString("file://%1/graphics/applicationIcons/%2@18.png")
122void ApplicationInfo::setScreenshotId(const QString &screenshotId)
124 QString screenshotFileName;
126 if (screenshotId.endsWith(".svg")) {
127 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2")
130 screenshotFileName = QString("qrc:///Unity/Application/screenshots/%2@12.png")
134 if (screenshotFileName != m_screenshotFileName) {
135 m_screenshotFileName = screenshotFileName;
138 m_session->setScreenshot(screenshotFileName);
143void ApplicationInfo::setName(const QString &value)
145 if (value != m_name) {
147 Q_EMIT nameChanged(value);
151void ApplicationInfo::setIcon(const QUrl &value)
153 if (value != m_icon) {
155 Q_EMIT iconChanged(value);
159void ApplicationInfo::setStage(Stage value)
161 if (value != m_stage) {
163 Q_EMIT stageChanged(value);
167void ApplicationInfo::setState(State value)
169 if (value != m_state) {
171 Q_EMIT stateChanged(value);
173 if (!m_manualSurfaceCreation && !m_session && m_state == ApplicationInfo::Starting) {
174 QTimer::singleShot(500, this, &ApplicationInfo::createSession);
175 } else if (m_state == ApplicationInfo::Stopped) {
176 Session *session = m_session;
183void ApplicationInfo::setFocused(bool value)
185 if (value != m_focused) {
187 Q_EMIT focusedChanged(value);
191void ApplicationInfo::setFullscreen(bool value)
193 if (value != m_fullscreen) {
194 m_fullscreen = value;
195 Q_EMIT fullscreenChanged(value);
199void ApplicationInfo::setManualSurfaceCreation(bool value)
201 if (value != m_manualSurfaceCreation) {
202 m_manualSurfaceCreation = value;
203 Q_EMIT manualSurfaceCreationChanged(value);
207Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
209 return m_supportedOrientations;
212void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
214 m_supportedOrientations = orientations;
217bool ApplicationInfo::rotatesWindowContents() const
219 return m_rotatesWindowContents;
222void ApplicationInfo::setRotatesWindowContents(bool value)
224 m_rotatesWindowContents = value;
227ApplicationInfo::RequestedState ApplicationInfo::requestedState() const
229 return m_requestedState;
232void ApplicationInfo::setRequestedState(RequestedState value)
234 if (m_requestedState != value) {
235 m_requestedState = value;
236 Q_EMIT requestedStateChanged(m_requestedState);
238 if (m_requestedState == RequestedRunning && m_state == Suspended) {
240 } else if (m_requestedState == RequestedSuspended && m_state == Running) {
246bool ApplicationInfo::isTouchApp() const
251void ApplicationInfo::setIsTouchApp(bool isTouchApp)
253 m_isTouchApp = isTouchApp;
256void ApplicationInfo::onSessionSurfaceChanged(MirSurface* surface)
258 if (surface != nullptr && m_state == Starting) {
259 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