From 53f1baac885e82b8333737a3127582420b0a739d Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Mon, 26 Jul 2021 14:57:30 +0200 Subject: [PATCH] feat(StatusBaseInput): add icon support Usage: ```qml StatusBaseInput { icon.name: "..." } ``` Closes #242 --- ui/StatusQ/sandbox/StatusInputPage.qml | 7 +++++ .../src/StatusQ/Controls/StatusBaseInput.qml | 28 +++++++++++++++++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/ui/StatusQ/sandbox/StatusInputPage.qml b/ui/StatusQ/sandbox/StatusInputPage.qml index 167197ee39..e868ddf780 100644 --- a/ui/StatusQ/sandbox/StatusInputPage.qml +++ b/ui/StatusQ/sandbox/StatusInputPage.qml @@ -30,6 +30,13 @@ Column { input.valid: false } + StatusInput { + label: "Label" + + input.icon.name: "search" + input.placeholderText: "Input with icon" + } + StatusInput { label: "Label" input.placeholderText: "Placeholder" diff --git a/ui/StatusQ/src/StatusQ/Controls/StatusBaseInput.qml b/ui/StatusQ/src/StatusQ/Controls/StatusBaseInput.qml index 962b9d570c..38934452b8 100644 --- a/ui/StatusQ/src/StatusQ/Controls/StatusBaseInput.qml +++ b/ui/StatusQ/src/StatusQ/Controls/StatusBaseInput.qml @@ -42,6 +42,12 @@ Item { property bool valid: true + property StatusIconSettings icon: StatusIconSettings { + width: 24 + height: 24 + name: "" + } + implicitWidth: 448 implicitHeight: multiline ? Math.max(edit.implicitHeight + topPadding + bottomPadding, 44) : 44 @@ -74,11 +80,29 @@ Item { anchors.fill: parent cursorShape: Qt.IBeamCursor onClicked: edit.forceActiveFocus() + + StatusIcon { + id: statusIcon + anchors.verticalCenter: parent.verticalCenter + anchors.left: parent.left + anchors.leftMargin: 10 + anchors.topMargin: 10 + + icon: statusBaseInput.icon.name + width: statusBaseInput.icon.width + height: statusBaseInput.icon.height + color: Theme.palette.baseColor1 + visible: !!statusBaseInput.icon.name + } + Flickable { id: flick - anchors.fill: parent - anchors.leftMargin: statusBaseInput.leftPadding + anchors.top: parent.top + anchors.bottom: parent.bottom + anchors.left: statusIcon.visible ? statusIcon.right : parent.left + anchors.right: parent.right + anchors.leftMargin: statusIcon.visible ? 8 : statusBaseInput.leftPadding anchors.rightMargin: statusBaseInput.rightPadding + clearable ? clearButtton.width : 0 anchors.topMargin: statusBaseInput.topPadding anchors.bottomMargin: statusBaseInput.bottomPadding