~mterry/qtmir/report-osk-max-height

« back to all changes in this revision

Viewing changes to src/modules/Unity/Application/application.cpp

  • Committer: CI Train Bot
  • Author(s): Michael Terry
  • Date: 2016-04-28 12:48:42 UTC
  • mfrom: (434.4.18 use-ual-info)
  • Revision ID: ci-train-bot@canonical.com-20160428124842-x84nsytuv4n0dsib
Use latest UbuntuAppLaunch API which supports libertine apps.
Approved by: Nick Dedekind

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
 
17
17
// local
18
18
#include "application.h"
 
19
#include "applicationinfo.h"
19
20
#include "application_manager.h"
20
 
#include "desktopfilereader.h"
21
21
#include "session.h"
22
22
#include "sharedwakelock.h"
23
23
#include "timer.h"
44
44
{
45
45
 
46
46
Application::Application(const QSharedPointer<SharedWakelock>& sharedWakelock,
47
 
                         DesktopFileReader *desktopFileReader,
 
47
                         const QSharedPointer<ApplicationInfo>& appInfo,
48
48
                         const QStringList &arguments,
49
49
                         ApplicationManager *parent)
50
 
    : ApplicationInfoInterface(desktopFileReader->appId(), parent)
 
50
    : ApplicationInfoInterface(appInfo->appId(), parent)
51
51
    , m_sharedWakelock(sharedWakelock)
52
 
    , m_desktopData(desktopFileReader)
 
52
    , m_appInfo(appInfo)
53
53
    , m_pid(0)
54
 
    , m_stage((desktopFileReader->stageHint() == "SideStage") ? Application::SideStage : Application::MainStage)
 
54
    , m_stage(Application::MainStage)
55
55
    , m_supportedStages(Application::MainStage|Application::SideStage)
56
56
    , m_state(InternalState::Starting)
57
57
    , m_arguments(arguments)
66
66
    // Because m_state is InternalState::Starting
67
67
    acquireWakelock();
68
68
 
69
 
    // FIXME(greyback) need to save long appId internally until ubuntu-app-launch can hide it from us
70
 
    m_longAppId = desktopFileReader->file().remove(QRegExp(".desktop$")).split('/').last();
71
 
 
72
 
    m_supportedOrientations = m_desktopData->supportedOrientations();
73
 
 
74
 
    m_rotatesWindowContents = m_desktopData->rotatesWindowContents();
 
69
    m_supportedOrientations = m_appInfo->supportedOrientations();
 
70
 
 
71
    m_rotatesWindowContents = m_appInfo->rotatesWindowContents();
75
72
 
76
73
    setStopTimer(new Timer);
77
74
}
108
105
        m_session->setApplication(nullptr);
109
106
        delete m_session;
110
107
    }
111
 
    delete m_desktopData;
112
108
    delete m_stopTimer;
113
109
}
114
110
 
130
126
 
131
127
bool Application::isValid() const
132
128
{
133
 
    return m_desktopData->loaded();
134
 
}
135
 
 
136
 
QString Application::desktopFile() const
137
 
{
138
 
    return m_desktopData->file();
 
129
    return !appId().isEmpty();
139
130
}
140
131
 
141
132
QString Application::appId() const
142
133
{
143
 
    return m_desktopData->appId();
 
134
    return m_appInfo->appId();
144
135
}
145
136
 
146
137
QString Application::name() const
147
138
{
148
 
    return m_desktopData->name();
 
139
    return m_appInfo->name();
149
140
}
150
141
 
151
142
QString Application::comment() const
152
143
{
153
 
    return m_desktopData->comment();
 
144
    return m_appInfo->comment();
154
145
}
155
146
 
156
147
QUrl Application::icon() const
157
148
{
158
 
    QString iconString = m_desktopData->icon();
159
 
    QString pathString = m_desktopData->path();
160
 
 
161
 
    if (QFileInfo(iconString).exists()) {
162
 
        return QUrl(iconString);
163
 
    } else if (QFileInfo(pathString + '/' + iconString).exists()) {
164
 
        return QUrl(pathString + '/' + iconString);
165
 
    } else {
166
 
        return QUrl("image://theme/" + iconString);
167
 
    }
 
149
    return m_appInfo->icon();
168
150
}
169
151
 
170
152
QString Application::splashTitle() const
171
153
{
172
 
    return m_desktopData->splashTitle();
 
154
    return m_appInfo->splashTitle();
173
155
}
174
156
 
175
157
QUrl Application::splashImage() const
176
158
{
177
 
    if (m_desktopData->splashImage().isEmpty()) {
178
 
        return QUrl();
179
 
    } else {
180
 
        QFileInfo imageFileInfo(m_desktopData->path(), m_desktopData->splashImage());
181
 
        if (imageFileInfo.exists()) {
182
 
            return QUrl::fromLocalFile(imageFileInfo.canonicalFilePath());
183
 
        } else {
184
 
            qCWarning(QTMIR_APPLICATIONS)
185
 
                << QString("Application(%1).splashImage file does not exist: \"%2\". Ignoring it.")
186
 
                    .arg(appId()).arg(imageFileInfo.absoluteFilePath());
187
 
 
188
 
            return QUrl();
189
 
        }
190
 
    }
 
159
    return m_appInfo->splashImage();
191
160
}
192
161
 
193
162
QColor Application::colorFromString(const QString &colorString, const char *colorName) const
242
211
 
243
212
bool Application::splashShowHeader() const
244
213
{
245
 
    QString showHeader = m_desktopData->splashShowHeader();
246
 
    if (showHeader.toLower() == "true") {
247
 
        return true;
248
 
    } else {
249
 
        return false;
250
 
    }
 
214
    return m_appInfo->splashShowHeader();
251
215
}
252
216
 
253
217
QColor Application::splashColor() const
254
218
{
255
 
    QString colorStr = m_desktopData->splashColor();
 
219
    QString colorStr = m_appInfo->splashColor();
256
220
    return colorFromString(colorStr, "splashColor");
257
221
}
258
222
 
259
223
QColor Application::splashColorHeader() const
260
224
{
261
 
    QString colorStr = m_desktopData->splashColorHeader();
 
225
    QString colorStr = m_appInfo->splashColorHeader();
262
226
    return colorFromString(colorStr, "splashColorHeader");
263
227
}
264
228
 
265
229
QColor Application::splashColorFooter() const
266
230
{
267
 
    QString colorStr = m_desktopData->splashColorFooter();
 
231
    QString colorStr = m_appInfo->splashColorFooter();
268
232
    return colorFromString(colorStr, "splashColorFooter");
269
233
}
270
234
 
271
 
QString Application::exec() const
272
 
{
273
 
    return m_desktopData->exec();
274
 
}
275
 
 
276
235
Application::Stage Application::stage() const
277
236
{
278
237
    return m_stage;
746
705
 
747
706
bool Application::isTouchApp() const
748
707
{
749
 
    return m_desktopData->isTouchApp();
 
708
    return m_appInfo->isTouchApp();
750
709
}
751
710
 
752
711
bool Application::exemptFromLifecycle() const
766
725
    }
767
726
}
768
727
 
769
 
QString Application::longAppId() const
770
 
{
771
 
    return m_longAppId;
772
 
}
773
 
 
774
728
Qt::ScreenOrientations Application::supportedOrientations() const
775
729
{
776
730
    return m_supportedOrientations;