Merge lp:~ted/pay-service/pay-test-app into lp:pay-service/14.10

Proposed by Ted Gould
Status: Merged
Approved by: Alejandro J. Cura
Approved revision: 39
Merged at revision: 35
Proposed branch: lp:~ted/pay-service/pay-test-app
Merge into: lp:pay-service/14.10
Prerequisite: lp:~ted/pay-service/trusted-prompt-sessions
Diff against target: 617 lines (+532/-1)
13 files modified
CMakeLists.txt (+1/-0)
debian/control (+10/-0)
debian/pay-service.install (+3/-1)
debian/pay-test-app.install (+3/-0)
pay-test-app/CMakeLists.txt (+25/-0)
pay-test-app/package.cpp (+105/-0)
pay-test-app/package.h (+39/-0)
pay-test-app/pay-test-app.cpp (+20/-0)
pay-test-app/pay-test-app.desktop.in (+9/-0)
pay-test-app/pay-test-app.qml (+81/-0)
pay-test-app/pay-test-app.svg (+122/-0)
pay-test-app/qtquick2applicationviewer.cpp (+81/-0)
pay-test-app/qtquick2applicationviewer.h (+33/-0)
To merge this branch: bzr merge lp:~ted/pay-service/pay-test-app
Reviewer Review Type Date Requested Status
Alejandro J. Cura (community) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+229714@code.launchpad.net

Commit message

Include pay-test-app in the pay-service repository

Description of the change

Adds a small app to help with testing. No code that should end up in production, just test code.

To post a comment you must log in.
lp:~ted/pay-service/pay-test-app updated
39. By Ted Gould

Fix file name

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Alejandro J. Cura (alecu) wrote :

Looks good

review: Approve
lp:~ted/pay-service/pay-test-app updated
40. By Ted Gould

Make sure pay-test-app doesn't get in pay-service

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'CMakeLists.txt'
2--- CMakeLists.txt 2014-08-06 15:07:40 +0000
3+++ CMakeLists.txt 2014-08-06 15:07:40 +0000
4@@ -100,6 +100,7 @@
5 if (${enable_tests})
6 add_subdirectory(tests)
7 endif ()
8+add_subdirectory(pay-test-app)
9
10
11 ##
12
13=== modified file 'debian/control'
14--- debian/control 2014-08-06 15:07:40 +0000
15+++ debian/control 2014-08-06 15:07:40 +0000
16@@ -23,7 +23,9 @@
17 libubuntu-app-launch2-dev,
18 libubuntuoneauth-2.0-dev,
19 python3-dbusmock,
20+ qt5-default,
21 qtbase5-dev,
22+ qtdeclarative5-dev,
23 Standards-Version: 3.9.5
24 Homepage: http://launchpad.net/pay-service
25 # If you aren't a member of ~indicator-applet-developers but need to upload
26@@ -68,3 +70,11 @@
27 Description: Pay service - library development files
28 This library contains information to purchase items and figure out
29 their purchase status.
30+
31+Package: pay-test-app
32+Architecture: any
33+Depends: ${shlibs:Depends},
34+ ${misc:Depends}
35+Description: Small application to help test payment
36+ Not a useful application for users but gives additional
37+ information about what's happening in the pay-service
38
39=== modified file 'debian/pay-service.install'
40--- debian/pay-service.install 2014-08-06 15:07:40 +0000
41+++ debian/pay-service.install 2014-08-06 15:07:40 +0000
42@@ -1,3 +1,5 @@
43-usr/lib/*/pay-service/*
44+usr/lib/*/pay-service/pay-service
45+usr/lib/*/pay-service/setup-staging.sh
46+usr/lib/*/pay-service/mir-connection-demangler
47 usr/lib/*/ubuntu-app-launch/pay-ui/*
48 usr/share/upstart/sessions/*
49
50=== added file 'debian/pay-test-app.install'
51--- debian/pay-test-app.install 1970-01-01 00:00:00 +0000
52+++ debian/pay-test-app.install 2014-08-06 15:07:40 +0000
53@@ -0,0 +1,3 @@
54+usr/share/applications
55+usr/share/icons
56+usr/lib/*/pay-service/pay-test-app*
57
58=== added directory 'pay-test-app'
59=== added file 'pay-test-app/CMakeLists.txt'
60--- pay-test-app/CMakeLists.txt 1970-01-01 00:00:00 +0000
61+++ pay-test-app/CMakeLists.txt 2014-08-06 15:07:40 +0000
62@@ -0,0 +1,25 @@
63+
64+set(CMAKE_INCLUDE_CURRENT_DIR ON)
65+set(CMAKE_AUTOMOC ON)
66+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -g -Wall -Werror")
67+
68+find_package(Qt5Core)
69+find_package(Qt5Qml)
70+find_package(Qt5Quick)
71+find_package(PkgConfig)
72+
73+include_directories (${CMAKE_SOURCE_DIR})
74+
75+set(pkglibexecdir "${CMAKE_INSTALL_FULL_PKGLIBEXECDIR}")
76+
77+add_executable(pay-test-app pay-test-app.cpp package.h package.cpp qtquick2applicationviewer.cpp qtquick2applicationviewer.h)
78+qt5_use_modules(pay-test-app Core Qml Quick)
79+target_link_libraries(pay-test-app libpay)
80+install(TARGETS pay-test-app RUNTIME DESTINATION ${pkglibexecdir})
81+
82+install(FILES pay-test-app.qml DESTINATION ${pkglibexecdir})
83+install(FILES pay-test-app.svg DESTINATION "${CMAKE_INSTALL_DATADIR}/icons/hicolor/scalable/apps/")
84+
85+configure_file("pay-test-app.desktop.in" "${CMAKE_CURRENT_BINARY_DIR}/pay-test-app.desktop" @ONLY)
86+install(FILES "${CMAKE_CURRENT_BINARY_DIR}/pay-test-app.desktop"
87+ DESTINATION "${CMAKE_INSTALL_DATADIR}/applications/")
88
89=== added file 'pay-test-app/package.cpp'
90--- pay-test-app/package.cpp 1970-01-01 00:00:00 +0000
91+++ pay-test-app/package.cpp 2014-08-06 15:07:40 +0000
92@@ -0,0 +1,105 @@
93+#include "package.h"
94+#include <QDebug>
95+
96+static QString enum2str (PayPackageItemStatus val);
97+
98+Package::Package (QObject * parent):
99+ QObject(parent)
100+{
101+ return;
102+}
103+
104+QString Package::pkgname (void) const
105+{
106+ return _pkgname;
107+}
108+
109+static void itemObserver (PayPackage * pkg, const char * itemid, PayPackageItemStatus status, void * user_data)
110+{
111+ Package * notthis = reinterpret_cast<Package *>(user_data);
112+ QString item(itemid);
113+ notthis->emitItemChanged(item, enum2str(status));
114+}
115+
116+void Package::emitItemChanged (const QString &item, const QString &status)
117+{
118+ emit itemStatusChanged(item, status);
119+}
120+
121+void Package::setPkgname (const QString &pkgname)
122+{
123+ if (pkgname == _pkgname) {
124+ return;
125+ }
126+
127+ _pkgname = pkgname;
128+ pkg = std::shared_ptr<PayPackage>([this]() -> PayPackage * {
129+ PayPackage * pkg = pay_package_new(_pkgname.toUtf8().data());
130+
131+ if (pkg != nullptr) {
132+ pay_package_item_observer_install(pkg, itemObserver, this);
133+ }
134+
135+ return pkg;
136+ }(),
137+ [this](PayPackage * pkg) {
138+ if (pkg != nullptr) {
139+ pay_package_item_observer_uninstall(pkg, itemObserver, this);
140+ pay_package_delete(pkg);
141+ }});
142+
143+ qDebug() << "Pay Package built for:" << _pkgname.toUtf8().data();
144+
145+ pkgnameChanged();
146+}
147+
148+static QString enum2str (PayPackageItemStatus val)
149+{
150+ switch (val) {
151+ case PAY_PACKAGE_ITEM_STATUS_VERIFYING:
152+ return QString("Verifying");
153+ case PAY_PACKAGE_ITEM_STATUS_PURCHASED:
154+ return QString("Purchased");
155+ case PAY_PACKAGE_ITEM_STATUS_PURCHASING:
156+ return QString("Purchasing");
157+ case PAY_PACKAGE_ITEM_STATUS_NOT_PURCHASED:
158+ return QString("Not Purchased");
159+ case PAY_PACKAGE_ITEM_STATUS_UNKNOWN:
160+ break;
161+ }
162+
163+ return QString("Unknown");
164+}
165+
166+QString Package::itemStatus (const QString &item)
167+{
168+ QString retval;
169+
170+ if (pkg == nullptr) {
171+ return retval;
172+ }
173+
174+ return enum2str(pay_package_item_status(pkg.get(), item.toUtf8().data()));
175+}
176+
177+bool Package::verifyItem (const QString & item)
178+{
179+ if (pkg == nullptr)
180+ return false;
181+
182+ qDebug() << "Verifying item" << item << "for package" << _pkgname;
183+
184+ return pay_package_item_start_verification(pkg.get(), item.toUtf8().data());
185+}
186+
187+bool Package::purchaseItem (const QString & item)
188+{
189+ if (pkg == nullptr)
190+ return false;
191+
192+ qDebug() << "Purchasing item" << item << "for package" << _pkgname;
193+
194+ return pay_package_item_start_purchase(pkg.get(), item.toUtf8().data());
195+}
196+
197+#include "moc_package.cpp"
198
199=== added file 'pay-test-app/package.h'
200--- pay-test-app/package.h 1970-01-01 00:00:00 +0000
201+++ pay-test-app/package.h 2014-08-06 15:07:40 +0000
202@@ -0,0 +1,39 @@
203+
204+#ifndef PACKAGE_H
205+#define PACKAGE_H 1
206+
207+#include <memory>
208+
209+#include <QObject>
210+
211+#include <libpay/pay-package.h>
212+
213+class Package : public QObject
214+{
215+ Q_OBJECT
216+
217+ Q_PROPERTY(QString pkgname READ pkgname WRITE setPkgname NOTIFY pkgnameChanged)
218+
219+public:
220+ QString pkgname() const;
221+ void setPkgname(const QString &pkgname);
222+
223+ Package (QObject * parent = nullptr);
224+
225+ Q_INVOKABLE QString itemStatus (const QString & item);
226+ Q_INVOKABLE bool verifyItem (const QString & item);
227+ Q_INVOKABLE bool purchaseItem (const QString & item);
228+
229+signals:
230+ void pkgnameChanged();
231+ void itemStatusChanged(const QString &item, const QString& status);
232+
233+private:
234+ std::shared_ptr<PayPackage> pkg;
235+ QString _pkgname;
236+
237+public:
238+ void emitItemChanged(const QString& item, const QString& status);
239+};
240+
241+#endif /* PACKAGE_H */
242
243=== added file 'pay-test-app/pay-test-app.cpp'
244--- pay-test-app/pay-test-app.cpp 1970-01-01 00:00:00 +0000
245+++ pay-test-app/pay-test-app.cpp 2014-08-06 15:07:40 +0000
246@@ -0,0 +1,20 @@
247+
248+#include <QQuickView>
249+#include <QtGui/QGuiApplication>
250+#include <QtQml/qqml.h>
251+
252+#include "qtquick2applicationviewer.h"
253+#include "package.h"
254+
255+int main (int argc, char * argv[])
256+{
257+ QGuiApplication app(argc, argv);
258+
259+ qmlRegisterType<Package>("Pay", 1, 0, "Package");
260+
261+ QtQuick2ApplicationViewer view;
262+ view.setMainQmlFile(QStringLiteral("pay-test-app.qml"));
263+ view.showExpanded();
264+
265+ return app.exec();
266+}
267
268=== added file 'pay-test-app/pay-test-app.desktop.in'
269--- pay-test-app/pay-test-app.desktop.in 1970-01-01 00:00:00 +0000
270+++ pay-test-app/pay-test-app.desktop.in 2014-08-06 15:07:40 +0000
271@@ -0,0 +1,9 @@
272+[Desktop Entry]
273+Name=Pay Test App
274+Comment=Used for testing pay service, nothing else
275+Exec=@pkglibexecdir@/pay-test-app
276+Path=@pkglibexecdir@
277+Type=Application
278+Icon=pay-test-app
279+X-Ubuntu-Single-Instance=true
280+X-Ubuntu-Touch=true
281
282=== added file 'pay-test-app/pay-test-app.qml'
283--- pay-test-app/pay-test-app.qml 1970-01-01 00:00:00 +0000
284+++ pay-test-app/pay-test-app.qml 2014-08-06 15:07:40 +0000
285@@ -0,0 +1,81 @@
286+import QtQuick 2.0
287+import Ubuntu.Components 1.1
288+import Ubuntu.Components.ListItems 1.0 as ListItem
289+import Pay 1.0
290+
291+MainView {
292+ id: mainview
293+ automaticOrientation: true
294+
295+ Package {
296+ id: pkg
297+ pkgname: "pay-test-app"
298+
299+ onItemStatusChanged: {
300+ statusBox.text = pkg.itemStatus(idBox.text)
301+ }
302+ }
303+
304+ Page {
305+ title: i18n.tr("Pay Test")
306+
307+ Column {
308+
309+ width: parent.width
310+ height: parent.height
311+
312+ ListItem.SingleControl {
313+ control: TextField {
314+ id: idBox
315+ x: units.gu(1)
316+ y: units.gu(1)
317+ width: parent.width - units.gu(2)
318+ text: i18n.tr("Item ID")
319+
320+ onTextChanged: {
321+ statusBox.text = pkg.itemStatus(idBox.text)
322+ }
323+ }
324+ }
325+ ListItem.Divider {
326+ }
327+ ListItem.SingleControl {
328+ control: TextField {
329+ id: statusBox
330+ x: units.gu(1)
331+ y: units.gu(1)
332+ width: parent.width - units.gu(2)
333+ text: i18n.tr("Unknown")
334+ readOnly: true
335+ hasClearButton: false
336+ }
337+ }
338+ ListItem.Divider {
339+ }
340+ ListItem.SingleControl {
341+ control: Button {
342+ x: units.gu(1)
343+ y: units.gu(1)
344+ width: parent.width - units.gu(2)
345+ text: i18n.tr("Verify")
346+ onClicked: {
347+ pkg.verifyItem(idBox.text)
348+ return false
349+ }
350+ }
351+ }
352+ ListItem.SingleControl {
353+ control: Button {
354+ x: units.gu(1)
355+ y: units.gu(1)
356+ width: parent.width - units.gu(2)
357+ text: i18n.tr("Purchase")
358+ onClicked: {
359+ pkg.purchaseItem(idBox.text)
360+ return false
361+ }
362+ }
363+ }
364+ }
365+ }
366+}
367
368=== added file 'pay-test-app/pay-test-app.svg'
369--- pay-test-app/pay-test-app.svg 1970-01-01 00:00:00 +0000
370+++ pay-test-app/pay-test-app.svg 2014-08-06 15:07:40 +0000
371@@ -0,0 +1,122 @@
372+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
373+<!-- Created with Inkscape (http://www.inkscape.org/) -->
374+
375+<svg
376+ xmlns:dc="http://purl.org/dc/elements/1.1/"
377+ xmlns:cc="http://creativecommons.org/ns#"
378+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
379+ xmlns:svg="http://www.w3.org/2000/svg"
380+ xmlns="http://www.w3.org/2000/svg"
381+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
382+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
383+ width="256"
384+ height="256"
385+ id="svg2"
386+ version="1.1"
387+ inkscape:version="0.48.4 r9939"
388+ sodipodi:docname="pay-test-app.svg">
389+ <defs
390+ id="defs4">
391+ <clipPath
392+ id="clipPath18"
393+ clipPathUnits="userSpaceOnUse">
394+ <path
395+ id="path20"
396+ d="M 0,2743.88 0,0 l 2743.81,0 0,2743.88 -2743.81,0 z"
397+ inkscape:connector-curvature="0" />
398+ </clipPath>
399+ <clipPath
400+ id="clipPath40"
401+ clipPathUnits="userSpaceOnUse">
402+ <path
403+ id="path42"
404+ d="M 0,500 1024,500 1024,0 0,0 0,500 Z"
405+ inkscape:connector-curvature="0" />
406+ </clipPath>
407+ </defs>
408+ <sodipodi:namedview
409+ id="base"
410+ pagecolor="#ffffff"
411+ bordercolor="#666666"
412+ borderopacity="1.0"
413+ inkscape:pageopacity="1"
414+ inkscape:pageshadow="2"
415+ inkscape:zoom="3.5078125"
416+ inkscape:cx="69.416481"
417+ inkscape:cy="128"
418+ inkscape:document-units="px"
419+ inkscape:current-layer="g2846"
420+ showgrid="false"
421+ inkscape:showpageshadow="false"
422+ inkscape:window-width="1920"
423+ inkscape:window-height="1056"
424+ inkscape:window-x="0"
425+ inkscape:window-y="24"
426+ inkscape:window-maximized="1" />
427+ <metadata
428+ id="metadata7">
429+ <rdf:RDF>
430+ <cc:Work
431+ rdf:about="">
432+ <dc:format>image/svg+xml</dc:format>
433+ <dc:type
434+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
435+ <dc:title></dc:title>
436+ </cc:Work>
437+ </rdf:RDF>
438+ </metadata>
439+ <g
440+ inkscape:label="Layer 1"
441+ inkscape:groupmode="layer"
442+ id="layer1"
443+ transform="translate(0,-796.36218)">
444+ <g
445+ transform="matrix(2.3275333,0,0,-2.3275333,22.502226,1029.8588)"
446+ id="g2846">
447+ <path
448+ d="M 90.652,45.325 C 90.652,20.293 70.359,0 45.326,0 20.293,0 0,20.293 0,45.325 c 0,25.033 20.293,45.326 45.326,45.326 25.033,0 45.326,-20.293 45.326,-45.326"
449+ style="fill:#e13f20"
450+ id="path24"
451+ inkscape:connector-curvature="0" />
452+ <path
453+ d="m 45.326,27.648 c -2.6602,0 -5.1836,0.5918 -7.4453,1.6446 l -4.2051,-7.5352 c 3.5117,-1.7402 7.4668,-2.7226 11.65,-2.7226 2.4336,0 4.7871,0.3378 7.0234,0.957 0.3945,2.4316 1.8379,4.6699 4.1387,6 2.2988,1.3262 4.9551,1.457 7.2558,0.5879 4.4747,4.4004 7.3868,10.385 7.8106,17.051 l -8.625,0.1269 c -0.793,-9.031 -8.37,-16.11 -17.604,-16.11 z m 0,35.354 c 9.2343,0 16.81,-7.08 17.605,-16.109 l 8.6231,0.1269 c -0.4238,6.666 -3.3359,12.65 -7.8106,17.051 -2.3007,-0.8691 -4.9589,-0.7363 -7.2558,0.5879 -2.3008,1.3281 -3.7442,3.5684 -4.1387,6 -2.2363,0.6172 -4.5898,0.9551 -7.0234,0.9551 -4.1836,0 -8.1387,-0.9825 -11.65,-2.7207 l 4.2051,-7.5352 c 2.2617,1.0527 4.7851,1.6445 7.4453,1.6445 z M 27.65,45.325 c 0,5.9805 2.9707,11.264 7.5156,14.463 l -4.4238,7.4102 c -5.2949,-3.5391 -9.2344,-8.9473 -10.871,-15.281 1.9101,-1.5586 3.1328,-3.9316 3.1328,-6.5918 0,-2.6586 -1.2227,-5.0316 -3.1328,-6.5902 1.6348,-6.336 5.5742,-11.744 10.871,-15.283 l 4.4238,7.4121 C 30.6207,34.0615 27.65,39.3448 27.65,45.3253 z"
454+ style="fill:#ffffff"
455+ id="path26"
456+ inkscape:connector-curvature="0"
457+ sodipodi:nodetypes="cccscccccccccccccsccccccccsccccc" />
458+ </g>
459+ <text
460+ xml:space="preserve"
461+ style="font-size:40px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu Medium"
462+ x="151.66147"
463+ y="875.0437"
464+ id="text3170"
465+ sodipodi:linespacing="125%"><tspan
466+ sodipodi:role="line"
467+ id="tspan3172"
468+ x="151.66147"
469+ y="875.0437">£</tspan></text>
470+ <text
471+ xml:space="preserve"
472+ style="font-size:40px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu Medium"
473+ x="152.51984"
474+ y="1002.3396"
475+ id="text3170-1"
476+ sodipodi:linespacing="125%"><tspan
477+ sodipodi:role="line"
478+ id="tspan3172-6"
479+ x="152.51984"
480+ y="1002.3396">¥</tspan></text>
481+ <text
482+ xml:space="preserve"
483+ style="font-size:40px;font-style:normal;font-variant:normal;font-weight:500;font-stretch:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;font-family:Ubuntu;-inkscape-font-specification:Ubuntu Medium"
484+ x="43.905128"
485+ y="937.62695"
486+ id="text3170-5"
487+ sodipodi:linespacing="125%"><tspan
488+ sodipodi:role="line"
489+ id="tspan3172-2"
490+ x="43.905128"
491+ y="937.62695">$</tspan></text>
492+ </g>
493+</svg>
494
495=== added file 'pay-test-app/qtquick2applicationviewer.cpp'
496--- pay-test-app/qtquick2applicationviewer.cpp 1970-01-01 00:00:00 +0000
497+++ pay-test-app/qtquick2applicationviewer.cpp 2014-08-06 15:07:40 +0000
498@@ -0,0 +1,81 @@
499+// checksum 0x4f6f version 0x90005
500+/*
501+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
502+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
503+ code such as screen orientation handling. Also QML paths and debugging are
504+ handled here.
505+ It is recommended not to modify this file, since newer versions of Qt Creator
506+ may offer an updated version of it.
507+*/
508+
509+#include "qtquick2applicationviewer.h"
510+
511+#include <QtCore/QCoreApplication>
512+#include <QtCore/QDir>
513+#include <QtQml/QQmlEngine>
514+
515+class QtQuick2ApplicationViewerPrivate
516+{
517+ QString mainQmlFile;
518+ friend class QtQuick2ApplicationViewer;
519+ static QString adjustPath(const QString &path);
520+};
521+
522+QString QtQuick2ApplicationViewerPrivate::adjustPath(const QString &path)
523+{
524+#if defined(Q_OS_MAC)
525+ if (!QDir::isAbsolutePath(path))
526+ return QString::fromLatin1("%1/../Resources/%2")
527+ .arg(QCoreApplication::applicationDirPath(), path);
528+#elif defined(Q_OS_BLACKBERRY)
529+ if (!QDir::isAbsolutePath(path))
530+ return QString::fromLatin1("app/native/%1").arg(path);
531+#elif !defined(Q_OS_ANDROID)
532+ QString pathInInstallDir =
533+ QString::fromLatin1("%1/../%2").arg(QCoreApplication::applicationDirPath(), path);
534+ if (QFileInfo(pathInInstallDir).exists())
535+ return pathInInstallDir;
536+ pathInInstallDir =
537+ QString::fromLatin1("%1/%2").arg(QCoreApplication::applicationDirPath(), path);
538+ if (QFileInfo(pathInInstallDir).exists())
539+ return pathInInstallDir;
540+#endif
541+ return path;
542+}
543+
544+QtQuick2ApplicationViewer::QtQuick2ApplicationViewer(QWindow *parent)
545+ : QQuickView(parent)
546+ , d(new QtQuick2ApplicationViewerPrivate())
547+{
548+ connect(engine(), SIGNAL(quit()), SLOT(close()));
549+ setResizeMode(QQuickView::SizeRootObjectToView);
550+}
551+
552+QtQuick2ApplicationViewer::~QtQuick2ApplicationViewer()
553+{
554+ delete d;
555+}
556+
557+void QtQuick2ApplicationViewer::setMainQmlFile(const QString &file)
558+{
559+ d->mainQmlFile = QtQuick2ApplicationViewerPrivate::adjustPath(file);
560+#ifdef Q_OS_ANDROID
561+ setSource(QUrl(QLatin1String("assets:/")+d->mainQmlFile));
562+#else
563+ setSource(QUrl::fromLocalFile(d->mainQmlFile));
564+#endif
565+}
566+
567+void QtQuick2ApplicationViewer::addImportPath(const QString &path)
568+{
569+ engine()->addImportPath(QtQuick2ApplicationViewerPrivate::adjustPath(path));
570+}
571+
572+void QtQuick2ApplicationViewer::showExpanded()
573+{
574+#if defined(Q_WS_SIMULATOR) || defined(Q_OS_QNX)
575+ showFullScreen();
576+#else
577+ show();
578+#endif
579+}
580
581=== added file 'pay-test-app/qtquick2applicationviewer.h'
582--- pay-test-app/qtquick2applicationviewer.h 1970-01-01 00:00:00 +0000
583+++ pay-test-app/qtquick2applicationviewer.h 2014-08-06 15:07:40 +0000
584@@ -0,0 +1,33 @@
585+// checksum 0xfde6 version 0x90005
586+/*
587+ This file was generated by the Qt Quick 2 Application wizard of Qt Creator.
588+ QtQuick2ApplicationViewer is a convenience class containing mobile device specific
589+ code such as screen orientation handling. Also QML paths and debugging are
590+ handled here.
591+ It is recommended not to modify this file, since newer versions of Qt Creator
592+ may offer an updated version of it.
593+*/
594+
595+#ifndef QTQUICK2APPLICATIONVIEWER_H
596+#define QTQUICK2APPLICATIONVIEWER_H
597+
598+#include <QtQuick/QQuickView>
599+
600+class QtQuick2ApplicationViewer : public QQuickView
601+{
602+ Q_OBJECT
603+
604+public:
605+ explicit QtQuick2ApplicationViewer(QWindow *parent = 0);
606+ virtual ~QtQuick2ApplicationViewer();
607+
608+ void setMainQmlFile(const QString &file);
609+ void addImportPath(const QString &path);
610+
611+ void showExpanded();
612+
613+private:
614+ class QtQuick2ApplicationViewerPrivate *d;
615+};
616+
617+#endif // QTQUICK2APPLICATIONVIEWER_H

Subscribers

People subscribed via source and target branches