aboutsummaryrefslogtreecommitdiffstats
path: root/appearance/Field.qml
diff options
context:
space:
mode:
Diffstat (limited to 'appearance/Field.qml')
-rw-r--r--appearance/Field.qml50
1 files changed, 50 insertions, 0 deletions
diff --git a/appearance/Field.qml b/appearance/Field.qml
new file mode 100644
index 0000000..004bda6
--- /dev/null
+++ b/appearance/Field.qml
@@ -0,0 +1,50 @@
+// Copyright (C) 2026 Danilo M. <danix@danix.xyz>
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+
+import QtQuick
+
+Rectangle {
+ id: field
+ property alias value: input.text
+ property string placeholder: ""
+ signal edited
+
+ implicitWidth: 70
+ height: 24
+ radius: 5
+ color: Qt.alpha(Theme.surface, 0.5)
+ border.width: 1
+ border.color: input.activeFocus ? Qt.alpha(Theme.accent, 0.6) : Qt.alpha(Theme.text, 0.12)
+
+ Text {
+ anchors.fill: parent
+ anchors.leftMargin: 6
+ anchors.rightMargin: 6
+ verticalAlignment: Text.AlignVCenter
+ visible: input.text === ""
+ text: field.placeholder
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 4 }
+ color: Theme.overlay
+ }
+
+ TextInput {
+ id: input
+ anchors.fill: parent
+ anchors.leftMargin: 6
+ anchors.rightMargin: 6
+ verticalAlignment: TextInput.AlignVCenter
+ clip: true
+ selectByMouse: true
+ font { family: Theme.fontFamily; pixelSize: Theme.fontSize - 3 }
+ color: Theme.text
+ onEditingFinished: field.edited()
+ }
+}