From 8970a0c09a80a8cf38a0e4207445e095c102e39e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=B1=E5=AD=90=E6=A5=9A=5Czhuzi?= Date: Wed, 5 Apr 2023 17:04:12 +0800 Subject: [PATCH] update --- src/controls/FluControl.qml | 13 +++++++ src/controls/FluStandardButton.qml | 55 ++++++++++++++++++++++++++++++ src/controls/FluTextArea.qml | 38 +++++++++++++++++++++ src/controls/FluTextFiled.qml | 46 +++++++++++++++++++++++++ 4 files changed, 152 insertions(+) create mode 100644 src/controls/FluControl.qml create mode 100644 src/controls/FluStandardButton.qml create mode 100644 src/controls/FluTextArea.qml create mode 100644 src/controls/FluTextFiled.qml diff --git a/src/controls/FluControl.qml b/src/controls/FluControl.qml new file mode 100644 index 0000000..bd77b44 --- /dev/null +++ b/src/controls/FluControl.qml @@ -0,0 +1,13 @@ +import QtQuick +import QtQuick.Controls +import QtQuick.Controls.impl +import QtQuick.Templates as T +import FluentUI + +T.Button { + id: control + implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset, + implicitContentWidth + leftPadding + rightPadding) + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + implicitContentHeight + topPadding + bottomPadding) +} diff --git a/src/controls/FluStandardButton.qml b/src/controls/FluStandardButton.qml new file mode 100644 index 0000000..2b4c197 --- /dev/null +++ b/src/controls/FluStandardButton.qml @@ -0,0 +1,55 @@ +import QtQuick +import QtQuick.Controls +import FluentUI + +Button { + + property bool disabled: false + property color normalColor: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(254/255,254/255,254/255,1) + property color hoverColor: FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1) + property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1) + + id: control + topPadding:5 + bottomPadding:5 + leftPadding:15 + rightPadding:15 + enabled: !disabled + focusPolicy:Qt.TabFocus + + Keys.onSpacePressed: control.visualFocus&&clicked() + + background: Rectangle{ + border.color: FluTheme.dark ? "#505050" : "#DFDFDF" + border.width: 1 + radius: 4 + FluFocusRectangle{ + visible: control.visualFocus + radius:8 + } + color:{ + if(disabled){ + return disableColor + } + return hovered ? hoverColor :normalColor + } + } + contentItem: FluText { + text: control.text + horizontalAlignment: Text.AlignHCenter + verticalAlignment: Text.AlignVCenter + color: { + if(FluTheme.dark){ + if(disabled){ + return Qt.rgba(131/255,131/255,131/255,1) + } + return Qt.rgba(1,1,1,1) + }else{ + if(disabled){ + return Qt.rgba(160/255,160/255,160/255,1) + } + return Qt.rgba(0,0,0,1) + } + } + } +} diff --git a/src/controls/FluTextArea.qml b/src/controls/FluTextArea.qml new file mode 100644 index 0000000..bcadff0 --- /dev/null +++ b/src/controls/FluTextArea.qml @@ -0,0 +1,38 @@ +import QtQuick +import QtQuick.Controls.impl +import QtQuick.Templates as T + +T.TextArea { + id: control + + implicitWidth: Math.max(contentWidth + leftPadding + rightPadding, + implicitBackgroundWidth + leftInset + rightInset, + placeholder.implicitWidth + leftPadding + rightPadding) + implicitHeight: Math.max(contentHeight + topPadding + bottomPadding, + implicitBackgroundHeight + topInset + bottomInset, + placeholder.implicitHeight + topPadding + bottomPadding) + + padding: 6 + leftPadding: padding + 4 + + color: control.palette.text + placeholderTextColor: control.palette.placeholderText + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + + PlaceholderText { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + + text: control.placeholderText + font: control.font + color: control.placeholderTextColor + verticalAlignment: control.verticalAlignment + visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + elide: Text.ElideRight + renderType: control.renderType + } +} diff --git a/src/controls/FluTextFiled.qml b/src/controls/FluTextFiled.qml new file mode 100644 index 0000000..3d6d5c1 --- /dev/null +++ b/src/controls/FluTextFiled.qml @@ -0,0 +1,46 @@ +import QtQuick +import QtQuick.Controls.impl +import QtQuick.Templates as T + +T.TextField { + id: control + + implicitWidth: implicitBackgroundWidth + leftInset + rightInset + || Math.max(contentWidth, placeholder.implicitWidth) + leftPadding + rightPadding + implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset, + contentHeight + topPadding + bottomPadding, + placeholder.implicitHeight + topPadding + bottomPadding) + + padding: 6 + leftPadding: padding + 4 + + color: control.palette.text + selectionColor: control.palette.highlight + selectedTextColor: control.palette.highlightedText + placeholderTextColor: control.palette.placeholderText + verticalAlignment: TextInput.AlignVCenter + + PlaceholderText { + id: placeholder + x: control.leftPadding + y: control.topPadding + width: control.width - (control.leftPadding + control.rightPadding) + height: control.height - (control.topPadding + control.bottomPadding) + + text: control.placeholderText + font: control.font + color: control.placeholderTextColor + verticalAlignment: control.verticalAlignment + visible: !control.length && !control.preeditText && (!control.activeFocus || control.horizontalAlignment !== Qt.AlignHCenter) + elide: Text.ElideRight + renderType: control.renderType + } + + background: Rectangle { + implicitWidth: 200 + implicitHeight: 40 + border.width: control.activeFocus ? 2 : 1 + color: control.palette.base + border.color: control.activeFocus ? control.palette.highlight : control.palette.mid + } +}