~ubuntu-testcase/checkbox/community-testing-cbt

« back to all changes in this revision

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

  • Committer: Brendan Donegan
  • Date: 2015-08-19 08:21:53 UTC
  • mfrom: (3921.18.12 checkbox)
  • Revision ID: brendan.donegan@canonical.com-20150819082153-2mzxd6il17w3mz2h
MergedĀ fromĀ trunk

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
 
import QtQuick 2.0
22
 
import Ubuntu.Components 1.1
23
 
import Ubuntu.Components.Popups 0.1
24
 
 
25
 
/*! \brief Comment addition dialog.
26
 
    \inherits Item
27
 
 
28
 
    This component is a prompt for user comments regarding test.
29
 
*/
30
 
 
31
 
Item {
32
 
    id: commentsDialog
33
 
    property alias dialogComponent: component
34
 
    property var commentDefaultText: ""
35
 
    signal commentAdded(string comment)
36
 
 
37
 
    Component {
38
 
        id: component
39
 
        Dialog {
40
 
            id: dialog
41
 
            title: i18n.tr("Add comment")
42
 
 
43
 
            modal: true
44
 
 
45
 
            TextArea {
46
 
                id: commentText
47
 
            }
48
 
 
49
 
            Button {
50
 
                id: doneButton
51
 
                text: i18n.tr("Done")
52
 
                color: UbuntuColors.green
53
 
                onClicked: {
54
 
                    PopupUtils.close(dialog);
55
 
                    commentAdded(commentText.text);
56
 
                    commentText.text = "";
57
 
                }
58
 
            }
59
 
 
60
 
            Component.onCompleted: {
61
 
                commentText.text = commentDefaultText
62
 
                commentText.cursorPosition = commentText.text.length;
63
 
                commentText.forceActiveFocus();
64
 
            }
65
 
        }
66
 
    }
67
 
}
68