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_manualSurfaceCreation(false)
46ApplicationInfo::ApplicationInfo(QObject *parent)
47 : ApplicationInfoInterface(QString(), parent)
53 , m_supportedOrientations(Qt::PortraitOrientation |
54 Qt::LandscapeOrientation |
55 Qt::InvertedPortraitOrientation |
56 Qt::InvertedLandscapeOrientation)
57 , m_rotatesWindowContents(false)
58 , m_manualSurfaceCreation(false)
62ApplicationInfo::~ApplicationInfo()
67void ApplicationInfo::createSession()
69 if (m_session || state() == ApplicationInfo::Stopped) { return; }
71 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
72 setSession(SessionManager::singleton()->createSession(appId(), screenshotUrl));
75void ApplicationInfo::setSession(Session* session)
77 qDebug() << "Application::setSession - appId=" << appId() << "session=" << session;
78 if (m_session == session)
82 disconnect(this, 0, m_session, 0);
83 m_session->setApplication(nullptr);
84 m_session->setParent(nullptr);
85 Q_EMIT m_session->deregister();
91 m_session->setApplication(this);
92 m_session->setParent(this);
93 SessionManager::singleton()->registerSession(m_session);
95 if (!m_manualSurfaceCreation) {
96 QTimer::singleShot(500, m_session, SLOT(createSurface()));
100 Q_EMIT sessionChanged(m_session);
103void ApplicationInfo::setIconId(const QString &iconId)
105 setIcon(QString("file://%1/graphics/applicationIcons/%2@18.png")
110void ApplicationInfo::setScreenshotId(const QString &screenshotId)
112 QString screenshotFileName;
114 if (screenshotId.endsWith(".svg")) {
115 screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2")
119 screenshotFileName = QString("%1/Dash/graphics/phone/screenshots/%2@12.png")
124 if (screenshotFileName != m_screenshotFileName) {
125 m_screenshotFileName = screenshotFileName;
127 QUrl screenshotUrl = QString("file://%1").arg(m_screenshotFileName);
129 m_session->setScreenshot(screenshotUrl);
134void ApplicationInfo::setName(const QString &value)
136 if (value != m_name) {
138 Q_EMIT nameChanged(value);
142void ApplicationInfo::setIcon(const QUrl &value)
144 if (value != m_icon) {
146 Q_EMIT iconChanged(value);
150void ApplicationInfo::setStage(Stage value)
152 if (value != m_stage) {
154 Q_EMIT stageChanged(value);
158void ApplicationInfo::setState(State value)
160 if (value != m_state) {
162 Q_EMIT stateChanged(value);
164 if (!m_manualSurfaceCreation && m_state == ApplicationInfo::Running) {
165 QTimer::singleShot(500, this, SLOT(createSession()));
166 } else if (m_state == ApplicationInfo::Stopped) {
173void ApplicationInfo::setFocused(bool value)
175 if (value != m_focused) {
177 Q_EMIT focusedChanged(value);
181void ApplicationInfo::setFullscreen(bool value)
183 if (value != m_fullscreen) {
184 m_fullscreen = value;
185 Q_EMIT fullscreenChanged(value);
189void ApplicationInfo::setManualSurfaceCreation(bool value)
191 if (value != m_manualSurfaceCreation) {
192 m_manualSurfaceCreation = value;
193 Q_EMIT manualSurfaceCreationChanged(value);
197Qt::ScreenOrientations ApplicationInfo::supportedOrientations() const
199 return m_supportedOrientations;
202void ApplicationInfo::setSupportedOrientations(Qt::ScreenOrientations orientations)
204 m_supportedOrientations = orientations;
207bool ApplicationInfo::rotatesWindowContents() const
209 return m_rotatesWindowContents;
212void ApplicationInfo::setRotatesWindowContents(bool value)
214 m_rotatesWindowContents = value;
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