1/****************************************************************************
2**
3** Copyright (C) 2021 The Qt Company Ltd.
4** Contact: https://www.qt.io/licensing/
5**
6** This file is part of Qt Creator.
7**
8** Commercial License Usage
9** Licensees holding valid commercial Qt licenses may use this file in
10** accordance with the commercial license agreement provided with the
11** Software or, alternatively, in accordance with the terms contained in
12** a written agreement between you and The Qt Company. For licensing terms
13** and conditions see https://www.qt.io/terms-conditions. For further
14** information use the contact form at https://www.qt.io/contact-us.
15**
16** GNU General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU
18** General Public License version 3 as published by the Free Software
19** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20** included in the packaging of this file. Please review the following
21** information to ensure the GNU General Public License requirements will
22** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23**
24****************************************************************************/
25
26import QtQuick 2.15
27import QtQuick.Layouts 1.15
28import HelperWidgets 2.0
29import StudioTheme 1.0 as StudioTheme
30
31Section {
32    id: textInputSection
33    anchors.left: parent.left
34    anchors.right: parent.right
35    caption: qsTr("Text Input")
36
37    property bool isTextInput: false
38
39    SectionLayout {
40        PropertyLabel { text: qsTr("Selection color") }
41
42        ColorEditor {
43            backendValue: backendValues.selectionColor
44            supportGradient: false
45        }
46
47        PropertyLabel { text: qsTr("Selected text color") }
48
49        ColorEditor {
50            backendValue: backendValues.selectedTextColor
51            supportGradient: false
52        }
53
54        PropertyLabel { text: qsTr("Selection mode") }
55
56        SecondColumnLayout {
57            ComboBox {
58                implicitWidth: StudioTheme.Values.singleControlColumnWidth
59                               + StudioTheme.Values.actionIndicatorWidth
60                width: implicitWidth
61                backendValue: backendValues.mouseSelectionMode
62                scope: "TextInput"
63                model: ["SelectCharacters", "SelectWords"]
64            }
65
66            ExpandingSpacer {}
67        }
68
69        PropertyLabel {
70            visible: textInputSection.isTextInput
71            text: qsTr("Input mask")
72        }
73
74        SecondColumnLayout {
75            visible: textInputSection.isTextInput
76
77            LineEdit {
78                backendValue: backendValues.inputMask
79                implicitWidth: StudioTheme.Values.singleControlColumnWidth
80                               + StudioTheme.Values.actionIndicatorWidth
81                width: implicitWidth
82                showTranslateCheckBox: false
83            }
84
85            ExpandingSpacer {}
86        }
87
88        PropertyLabel {
89            visible: textInputSection.isTextInput
90            text: qsTr("Echo mode")
91        }
92
93        SecondColumnLayout {
94            visible: textInputSection.isTextInput
95
96            ComboBox {
97                implicitWidth: StudioTheme.Values.singleControlColumnWidth
98                               + StudioTheme.Values.actionIndicatorWidth
99                width: implicitWidth
100                backendValue: backendValues.echoMode
101                scope: "TextInput"
102                model: ["Normal", "Password", "PasswordEchoOnEdit", "NoEcho"]
103            }
104
105            ExpandingSpacer {}
106        }
107
108        PropertyLabel {
109            visible: textInputSection.isTextInput
110            text: qsTr("Password character")
111            tooltip: qsTr("Character displayed when users enter passwords.")
112        }
113
114        SecondColumnLayout {
115            visible: textInputSection.isTextInput
116
117            LineEdit {
118                backendValue: backendValues.passwordCharacter
119                implicitWidth: StudioTheme.Values.singleControlColumnWidth
120                               + StudioTheme.Values.actionIndicatorWidth
121                width: implicitWidth
122                showTranslateCheckBox: false
123            }
124
125            ExpandingSpacer {}
126        }
127
128        PropertyLabel {
129            visible: !textInputSection.isTextInput
130            text: qsTr("Tab stop distance")
131            tooltip: qsTr("Default distance between tab stops in device units.")
132        }
133
134        SecondColumnLayout {
135            visible: !textInputSection.isTextInput
136
137            SpinBox {
138                implicitWidth: StudioTheme.Values.twoControlColumnWidth
139                               + StudioTheme.Values.actionIndicatorWidth
140                backendValue: backendValues.tabStopDistance
141                maximumValue: 200
142                minimumValue: 0
143            }
144
145            Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
146
147            ControlLabel { text: "px" }
148
149            ExpandingSpacer {}
150        }
151
152        PropertyLabel {
153            visible: !textInputSection.isTextInput
154            text: qsTr("Text margin")
155            tooltip: qsTr("Margin around the text in the Text Edit in pixels.")
156        }
157
158        SecondColumnLayout {
159            visible: !textInputSection.isTextInput
160
161            SpinBox {
162                implicitWidth: StudioTheme.Values.twoControlColumnWidth
163                               + StudioTheme.Values.actionIndicatorWidth
164                backendValue: backendValues.textMargin
165                maximumValue: 200
166                minimumValue: -200
167            }
168
169            Spacer { implicitWidth: StudioTheme.Values.controlLabelGap }
170
171            ControlLabel { text: "px" }
172
173            ExpandingSpacer {}
174        }
175
176        PropertyLabel {
177            visible: textInputSection.isTextInput
178            text: qsTr("Maximum length")
179            tooltip: qsTr("Maximum permitted length of the text in the Text Input.")
180        }
181
182        SecondColumnLayout {
183            visible: textInputSection.isTextInput
184
185            SpinBox {
186                implicitWidth: StudioTheme.Values.singleControlColumnWidth
187                               + StudioTheme.Values.actionIndicatorWidth
188                backendValue: backendValues.maximumLength
189                minimumValue: 0
190                maximumValue: 32767
191            }
192
193            ExpandingSpacer {}
194        }
195
196        component FlagItem : SecondColumnLayout {
197            property alias backendValue: checkBox.backendValue
198            CheckBox {
199                id: checkBox
200                implicitWidth: StudioTheme.Values.twoControlColumnWidth
201                               + StudioTheme.Values.actionIndicatorWidth
202                text: backendValue.valueToString
203            }
204
205            ExpandingSpacer {}
206        }
207
208        PropertyLabel { text: qsTr("Read only") }
209
210        FlagItem { backendValue: backendValues.readOnly }
211
212        PropertyLabel { text: qsTr("Cursor visible") }
213
214        FlagItem { backendValue: backendValues.cursorVisible }
215
216        PropertyLabel { text: qsTr("Focus on press") }
217
218        FlagItem { backendValue: backendValues.activeFocusOnPress }
219
220        PropertyLabel {
221            visible: textInputSection.isTextInput
222            text: qsTr("Auto scroll")
223        }
224
225        FlagItem {
226            visible: textInputSection.isTextInput
227            backendValue: backendValues.autoScroll
228        }
229
230        PropertyLabel { text: qsTr("Overwrite mode") }
231
232        FlagItem { backendValue: backendValues.overwriteMode }
233
234        PropertyLabel { text: qsTr("Persistent selection") }
235
236        FlagItem { backendValue: backendValues.persistentSelection }
237
238        PropertyLabel { text: qsTr("Select by mouse") }
239
240        FlagItem { backendValue: backendValues.selectByMouse }
241
242        PropertyLabel {
243            visible: !textInputSection.isTextInput
244            text: qsTr("Select by keyboard")
245        }
246
247        FlagItem {
248            visible: !textInputSection.isTextInput
249            backendValue: backendValues.selectByKeyboard
250        }
251    }
252}
253