~pieq/checkbox/fix-1484872-env-variables-forced-to-non-international

« back to all changes in this revision

Viewing changes to checkbox-touch/components/QmlConfinedPage.qml

  • Committer: Zygmunt Krynicki
  • Date: 2014-12-19 12:11:52 UTC
  • mto: This revision was merged to the branch mainline in revision 3516.
  • Revision ID: zygmunt.krynicki@canonical.com-20141219121152-y9vtxajhrd6e1c3l
cep: merge CEPs in to trunk

This patch merges CEPs (aka Checkbox Enhancement Proposals) into trunk.
Those lived on separately for a while as lp:checkbox/cep but in
retrospective nobody knows about them and this should give them some
more exposure. In addition, the move allows new features to land a CEP
document along, making review of complex new features easier to make as
their specification can be seen alongside the patches that implement it.

Due to bazaar limitations in merging separate repositories together I've
discarded history entries (not that there were many) and just added
those files in directly.

Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * This file is part of Checkbox
3
 
 *
4
 
 * Copyright 2015 Canonical Ltd.
5
 
 *
6
 
 * Authors:
7
 
 * - Maciej Kisielewski <maciej.kisielewski@canonical.com>
8
 
 *
9
 
 * This program is free software; you can redistribute it and/or modify
10
 
 * it under the terms of the GNU General Public License as published by
11
 
 * the Free Software Foundation; version 3.
12
 
 *
13
 
 * This program is distributed in the hope that it will be useful,
14
 
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 
 * GNU General Public License for more details.
17
 
 *
18
 
 * You should have received a copy of the GNU General Public License
19
 
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 
 */
21
 
 
22
 
/*! \brief Page for Qml native test
23
 
*/
24
 
 
25
 
import QtQuick 2.0
26
 
import Ubuntu.Components 1.1
27
 
import Ubuntu.Components.Popups 0.1
28
 
import QtQuick.Layouts 1.1
29
 
import "ConfirmationLogic.js" as ConfirmationLogic
30
 
import Ubuntu.Content 1.1
31
 
 
32
 
Page {
33
 
    id: qmlNativePage
34
 
    property var test: { "name": "", "description": "", "test_number": 0, "tests_count": 0}
35
 
    property var applicationVersion: ""
36
 
 
37
 
    signal testDone(var test);
38
 
 
39
 
    objectName: "qmlNativePage"
40
 
    title: i18n.tr("Test Description")
41
 
 
42
 
    /* testingShell serves as the interface to the external world from the
43
 
     * qml-test. */
44
 
    Object {
45
 
        id: testingShell
46
 
        property string name: "Checkbox-touch qml confined shell"
47
 
        property alias pageStack: qmlNativePage.pageStack
48
 
        property string sessionDir: app.sessionDir
49
 
        function getTest() {
50
 
            return test;
51
 
        }
52
 
    }
53
 
 
54
 
    Connections {
55
 
        target: ContentHub
56
 
        onImportRequested: {
57
 
            var resultFile = String(transfer.items[0].url).replace(
58
 
                'file://', '');
59
 
            var xhr = new XMLHttpRequest;
60
 
            xhr.open("GET", resultFile);
61
 
            xhr.onreadystatechange = function() {
62
 
                if (xhr.readyState === XMLHttpRequest.DONE) {
63
 
                    try {
64
 
                        var result = JSON.parse(xhr.responseText);
65
 
                        test["outcome"] = result["outcome"];
66
 
                        testDone(test);
67
 
                    } catch (x) {
68
 
                        console.error("ERROR when parsing result json obj.")
69
 
                    }
70
 
                }
71
 
            }
72
 
            xhr.send();
73
 
            transfer.finalize();
74
 
        }
75
 
    }
76
 
 
77
 
    head {
78
 
        actions: [
79
 
            Action {
80
 
                id: addCommentAction
81
 
                iconName: "document-new-symbolic"
82
 
                text: i18n.tr("Add comment")
83
 
                onTriggered: {
84
 
                    commentsDialog.commentDefaultText = test["comments"] || "";
85
 
                    commentsDialog.commentAdded.connect(function(comment) {
86
 
                        test["comments"] = comment;
87
 
                    });
88
 
                    PopupUtils.open(commentsDialog.dialogComponent);
89
 
                }
90
 
            },
91
 
            Action {
92
 
                id: skipAction
93
 
                iconName: "media-seek-forward"
94
 
                text: i18n.tr("Skip")
95
 
                onTriggered: {
96
 
                    var confirmationOptions = {
97
 
                        question : i18n.tr("Do you really want to skip this test?"),
98
 
                        remember : true,
99
 
                    }
100
 
                    ConfirmationLogic.confirmRequest(qmlNativePage,
101
 
                        confirmationOptions, function(res) {
102
 
                            if (res) {
103
 
                                test["outcome"] = "skip";
104
 
                                testDone(test);
105
 
                            }
106
 
                    });
107
 
                }
108
 
            }
109
 
        ]
110
 
    }
111
 
 
112
 
    ColumnLayout {
113
 
        id: body
114
 
        spacing: units.gu(3)
115
 
        anchors {
116
 
            fill: parent
117
 
            topMargin: units.gu(3)
118
 
            bottomMargin: units.gu(3)
119
 
            leftMargin: units.gu(1)
120
 
            rightMargin: units.gu(1)
121
 
        }
122
 
 
123
 
        Label {
124
 
            fontSize: "large"
125
 
            Layout.fillWidth: true
126
 
            wrapMode: Text.WrapAtWordBoundaryOrAnywhere
127
 
            text: test["name"]
128
 
            font.bold: true
129
 
        }
130
 
 
131
 
        Flickable {
132
 
            Layout.fillWidth: true
133
 
            Layout.fillHeight: true
134
 
            contentHeight: childrenRect.height
135
 
            flickableDirection: Flickable.VerticalFlick
136
 
            clip: true
137
 
            Label {
138
 
                fontSize: "medium"
139
 
                anchors.fill: parent
140
 
                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
141
 
                text: test["description"]
142
 
            }
143
 
        }
144
 
 
145
 
        ColumnLayout {
146
 
            id: busyIndicatorGroup
147
 
            visible: false
148
 
            Layout.fillWidth: true
149
 
            Layout.fillHeight: true
150
 
 
151
 
            Label {
152
 
                fontSize: "large"
153
 
                Layout.fillWidth: true
154
 
                wrapMode: Text.WrapAtWordBoundaryOrAnywhere
155
 
                text: i18n.tr("Waiting for the test to finish")
156
 
                font.bold: true
157
 
            }
158
 
        }
159
 
 
160
 
        LatchButton {
161
 
            objectName: "continueButton"
162
 
            color: UbuntuColors.green
163
 
            Layout.fillWidth: true
164
 
            text: i18n.tr("Continue")
165
 
            onClicked: {
166
 
                busyIndicatorGroup.visible = true;
167
 
                var appName = "com.ubuntu.checkbox_" + test["partial_id"] + "_" + applicationVersion + ".desktop";
168
 
                console.log("Launching " + appName);
169
 
                Qt.openUrlExternally("application:///" + appName);
170
 
            }
171
 
        }
172
 
    }
173
 
}