Lomiri
Loading...
Searching...
No Matches
ButtonPrompt.qml
1/*
2 * Copyright (C) 2021 Capsia
3 * Copyright (C) 2016 Canonical, Ltd.
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; version 3.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18import QtQuick 2.12
19import Lomiri.Components 1.3
20import "../Components"
21
22FocusScope {
23 id: root
24 objectName: "promptButton"
25
26 property alias text: buttonLabel.text
27 property alias interactive: root.enabled
28 property bool isSecret
29 property bool loginError: false
30 property bool hasKeyboard: false
31 property string enteredText: ""
32
33 signal clicked()
34 signal canceled()
35 signal accepted(string response)
36
37 Keys.onSpacePressed: clicked();
38 Keys.onReturnPressed: clicked();
39 Keys.onEnterPressed: clicked();
40
41 anchors.fill: parent
42
43 activeFocusOnTab: true
44
45 Rectangle {
46 anchors.fill: parent
47 radius: units.gu(0.5)
48 color: "#7A111111"
49 Behavior on border.color {
50 ColorAnimation{}
51 }
52 border {
53 color: root.loginError ? theme.palette.normal.negative : theme.palette.normal.raisedSecondaryText
54 width: root.loginError ? units.dp(2): units.dp(1)
55 }
56 }
57
58 MouseArea {
59 anchors.fill: parent
60 onClicked: parent.clicked();
61 }
62
63 Label {
64 id: buttonLabel
65 anchors.centerIn: parent
66 color: theme.palette.normal.raisedSecondaryText
67 }
68}