on 551c708 help sign in
69 lines 2.0 kB history raw
1/*
2 * Copyright 2013 Canonical Ltd.
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; version 3.
7 *
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 Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * Authors:
17 * Renato Araujo Oliveira Filho <renato@canonical.com>
18 * Olivier Tilloy <olivier.tilloy@canonical.com>
19 */
21import QtQuick 2.0
22import Ubuntu.Components 0.1
24Item {
25 id: textField
26 property alias text: replyField.text
27 property alias buttonText: sendButton.text
28 property bool activateEnabled: false
30 signal activate(var value)
32 TextField {
33 id: replyField
35 anchors {
36 top: parent.top
37 bottom: parent.bottom
38 left: parent.left
39 right: sendButton.left
40 rightMargin: units.gu(1)
41 }
42 placeholderText: "Reply"
43 hasClearButton: false
45 onEnabledChanged: {
46 //Make sure that the component lost focus when enabled = false,
47 //otherwise it will get focus again when enable = true
48 if (!enabled) {
49 focus = false;
50 }
51 }
52 }
54 Button {
55 id: sendButton
56 anchors {
57 top: parent.top
58 bottom: parent.bottom
59 right: parent.right
60 }
61 width: units.gu(9)
62 enabled: replyField.text !== "" && textField.activateEnabled
63 color: enabled ? "#c94212" : "#bababa"
65 onClicked: {
66 textField.activate(replyField.text);
67 }
68 }