diff --git a/src/controls/ActionTextField.qml b/src/controls/ActionTextField.qml new file mode 100644 index 0000000..0e26a37 --- /dev/null +++ b/src/controls/ActionTextField.qml @@ -0,0 +1,41 @@ +import QtQuick 2.12 +import QtQuick.Layouts 1.12 +import QtQuick.Controls 2.12 +import FishUI 1.0 as FishUI + +TextField { + id: control + + property list rightActions + + rightPadding: FishUI.Units.smallSpacing + rightActionsRow.width + Row { + id: rightActionsRow + padding: FishUI.Units.smallSpacing + layoutDirection: Qt.RightToLeft + anchors.right: parent.right + anchors.rightMargin: FishUI.Units.smallSpacing + anchors.verticalCenter: parent.verticalCenter + height: control.implicitHeight - 2 * FishUI.Units.smallSpacing + Repeater { + model: control.rightActions + Icon { + implicitWidth: FishUI.Units.iconSizes.small + implicitHeight: FishUI.Units.iconSizes.small + + anchors.verticalCenter: parent.verticalCenter + + source: modelData.icon.name.length > 0 ? modelData.icon.name : modelData.icon.source + visible: modelData.visible + enabled: modelData.enabled + MouseArea { + id: actionArea + anchors.fill: parent + onClicked: modelData.trigger() + cursorShape: Qt.PointingHandCursor + } + } + } + } + +} diff --git a/src/controls/qmldir b/src/controls/qmldir index a998f27..f9d0107 100644 --- a/src/controls/qmldir +++ b/src/controls/qmldir @@ -12,6 +12,7 @@ typeinfo plugins.qmltypes singleton Theme 1.0 Theme.qml singleton Units 1.0 Units.qml +ActionTextField 1.0 ActionTextField BusyIndicator 1.0 BusyIndicator.qml Icon 1.0 Icon.qml PopupTips 1.0 PopupTips.qml diff --git a/src/fishui.cpp b/src/fishui.cpp index c6a937b..7f77e8c 100644 --- a/src/fishui.cpp +++ b/src/fishui.cpp @@ -64,6 +64,7 @@ void FishUI::registerTypes(const char *uri) qmlRegisterSingletonType(componentUrl(QStringLiteral("Theme.qml")), uri, 1, 0, "Theme"); qmlRegisterSingletonType(componentUrl(QStringLiteral("Units.qml")), uri, 1, 0, "Units"); + qmlRegisterType(componentUrl(QStringLiteral("ActionTextField.qml")), uri, 1, 0, "ActionTextField"); qmlRegisterType(componentUrl(QStringLiteral("BusyIndicator.qml")), uri, 1, 0, "BusyIndicator"); qmlRegisterType(componentUrl(QStringLiteral("Icon.qml")), uri, 1, 0, "Icon"); qmlRegisterType(componentUrl(QStringLiteral("PopupTips.qml")), uri, 1, 0, "PopupTips"); diff --git a/src/fishui.qrc b/src/fishui.qrc index 16c9f63..ae2272c 100644 --- a/src/fishui.qrc +++ b/src/fishui.qrc @@ -24,6 +24,7 @@ images/toast/info.svg images/toast/success.svg images/toast/warn.svg + controls/ActionTextField.qml