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"
19#include "SessionManager.h"
23#include <QGuiApplication>
26#include <QQmlComponent>
29ApplicationInfo::ApplicationInfo(const QString &appId, QObject *parent)
30 : ApplicationInfoInterface(appId, parent)
37 , m_supportedOrientations(Qt::PortraitOrientation |
38 Qt::LandscapeOrientation |
39 Qt::InvertedPortraitOrientation |
40 Qt::InvertedLandscapeOrientation)
41 , m_rotatesWindowContents(false)
42 , m_requestedState(RequestedRunning)
43 , m_manualSurfaceCreation(false)
47ApplicationInfo::ApplicationInfo(QObject *parent)
48 : ApplicationInfoInterface(QString(), parent)
54 , m_supportedOrientations(Qt::PortraitOrientation |
55 Qt::LandscapeOrientation |
56 Qt::InvertedPortraitOrientation |
57 Qt::InvertedLandscapeOrientation)
58 , m_rotatesWindowContents(false)
59 , m_requestedState(RequestedRunning)
60 , m_manualSurfaceCreation(false)
64ApplicationInfo::~ApplicationInfo()
69void ApplicationInfo::createSession()
71 if (m_session || state() == ApplicationInfo::Stopped) { return; }
73 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
74 setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
77void ApplicationInfo::setSession(Session* session)
79 if (m_session == session)
83 disconnect(this, 0, m_session, 0);
84 m_session->setApplication(nullptr);
85 m_session->setParent(nullptr);
86 Q_EMIT m_session->deregister();
92 m_session->setApplication(this);
93 m_session->setParent(this);
94 SessionManager::singleton()->registerSession(m_session);
95 connect(m_session, &Session::surfaceChanged,
96 this, &ApplicationInfo::onSessionSurfaceChanged);
98 if (!m_manualSurfaceCreation) {
99 QTimer::singleShot(500, m_session, SLOT(createSurface()));
103 Q_EMIT sessionChanged(m_session);
106void ApplicationInfo::setIconId(const QString &iconId)
108 setIcon(QString("file://%1/graphics/applicationIcons/%2@18.png")
113void ApplicationInfo::setScreenshotId(const QString &screenshotId)
115 QString screenshotFileName;
117 if (screenshotId.endsWith(".svg")) {
118 screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2")
122 screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
127 if (screenshotFileName != m_screenshotFileName) {
128 m_screenshotFileName = screenshotFileName;
130 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
132 m_session->setScreenshot(screenshotUrl);
137void ApplicationInfo::setName(const QString &value)
139 if (value != m_name) {
141 Q_EMIT nameChanged(value);
145void ApplicationInfo::setIcon(const QUrl &value)
147 if (value != m_icon) {
149 Q_EMIT iconChanged(value);
153void ApplicationInfo::setStage(Stage value)
155 if (value != m_stage) {
157 Q_EMIT stageChanged(value);
161void ApplicationInfo::setState(State value)
163 if (value != m_state) {
165 Q_EMIT stateChanged(value);
167 if (!m_manualSurfaceCreation && !m_session && m_state == ApplicationInfo::Starting) {
168 QTimer::singleShot(500, this, SLOT(createSession()));
169 } else if (m_state == ApplicationInfo::Stopped) {
170 Session *session = m_session;
177void ApplicationInfo::setFocused(bool value)
179 if (value != m_focused) {
181 Q_EMIT focusedChanged(value);
185void ApplicationInfo::setFullscreen(bool value)
187 if (value != m_fullscreen) {
188 m_fullscreen = value;
189 Q_EMIT fullscreenChanged(value);
193void ApplicationInfo::setManualSurfaceCreation(bool value)
195 if (value != m_manualSurfaceCreation) {
196 m_manualSurfaceCreation = value;
197 Q_EMIT manualSurfaceCreationChanged(value);
201Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
203 return m_supportedOrientations;
206void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
208 m_supportedOrientations = orientations;
211bool ApplicationInfo::rotatesWindowContents() const
213 return m_rotatesWindowContents;
216void ApplicationInfo::setRotatesWindowContents(bool value)
218 m_rotatesWindowContents = value;
221ApplicationInfo::RequestedState ApplicationInfo::requestedState() const
223 return m_requestedState;
226void ApplicationInfo::setRequestedState(RequestedState value)
228 if (m_requestedState != value) {
229 m_requestedState = value;
230 Q_EMIT requestedStateChanged(m_requestedState);
232 if (m_requestedState == RequestedRunning && m_state == Suspended) {
234 } else if (m_requestedState == RequestedSuspended && m_state == Running) {
240void ApplicationInfo::onSessionSurfaceChanged(MirSurfaceItem* surface)
242 if (surface != nullptr && m_state == Starting) {
243 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