mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-02-02 19:27:38 +08:00
update
This commit is contained in:
parent
5d902dc66e
commit
502044ebd2
@ -8,6 +8,9 @@ if(APPLE)
|
|||||||
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
set(CMAKE_OSX_ARCHITECTURES "arm64;x86_64" CACHE STRING "" FORCE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
#设置插件位置,不然import example有时候会爆红
|
||||||
|
set(QML_IMPORT_PATH ${CMAKE_BINARY_DIR}/example CACHE STRING "Qt Creator extra QML import paths" FORCE)
|
||||||
|
|
||||||
#判断FluentUI库类型
|
#判断FluentUI库类型
|
||||||
if(FLUENTUI_BUILD_STATIC_LIB)
|
if(FLUENTUI_BUILD_STATIC_LIB)
|
||||||
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
|
add_definitions(-DFLUENTUI_BUILD_STATIC_LIB)
|
||||||
@ -87,7 +90,7 @@ endif()
|
|||||||
|
|
||||||
#添加qml模块
|
#添加qml模块
|
||||||
qt_add_qml_module(example
|
qt_add_qml_module(example
|
||||||
URI example
|
URI "example"
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
QML_FILES ${qml_files}
|
QML_FILES ${qml_files}
|
||||||
RESOURCES ${resource_files}
|
RESOURCES ${resource_files}
|
||||||
|
@ -164,6 +164,7 @@ FluScrollablePage{
|
|||||||
Layout.fillWidth: true
|
Layout.fillWidth: true
|
||||||
Layout.topMargin: -1
|
Layout.topMargin: -1
|
||||||
code:'FluSpinBox{
|
code:'FluSpinBox{
|
||||||
|
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,21 +58,16 @@ else()
|
|||||||
set(LIB_TYPE "SHARED")
|
set(LIB_TYPE "SHARED")
|
||||||
endif()
|
endif()
|
||||||
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
qt_add_library(${PROJECT_NAME} ${LIB_TYPE})
|
||||||
|
|
||||||
if (FLUENTUI_BUILD_STATIC_LIB)
|
if (FLUENTUI_BUILD_STATIC_LIB)
|
||||||
qt_add_qml_module(${PROJECT_NAME}
|
set(PLUGIN_TARGET_NAME "")
|
||||||
#在静态库编译中使用PLUGIN_TARGET会导致链接失败
|
|
||||||
OUTPUT_DIRECTORY ${FLUENTUI_QML_PLUGIN_DIRECTORY}
|
|
||||||
VERSION 1.0
|
|
||||||
URI "FluentUI"
|
|
||||||
TYPEINFO "plugins.qmltypes"
|
|
||||||
SOURCES ${sources_files} fluentui.rc
|
|
||||||
QML_FILES ${qml_files}
|
|
||||||
RESOURCES ${resource_files}
|
|
||||||
)
|
|
||||||
else()
|
else()
|
||||||
qt_add_qml_module(${PROJECT_NAME}
|
#如果是动态库,则使用插件目标作为其自己的支持目标来定义 QML 模块,在这种情况下,模块必须在运行时动态加载,并且不能由其他目标直接链接到
|
||||||
#没有下面这行代码就会生成fluentuiplugin.dll与fluentuipluginplugin.dll两个动态库
|
set(PLUGIN_TARGET_NAME ${PROJECT_NAME})
|
||||||
PLUGIN_TARGET fluentuiplugin
|
endif()
|
||||||
|
|
||||||
|
qt_add_qml_module(${PROJECT_NAME}
|
||||||
|
PLUGIN_TARGET ${PLUGIN_TARGET_NAME}
|
||||||
OUTPUT_DIRECTORY ${FLUENTUI_QML_PLUGIN_DIRECTORY}
|
OUTPUT_DIRECTORY ${FLUENTUI_QML_PLUGIN_DIRECTORY}
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
URI "FluentUI"
|
URI "FluentUI"
|
||||||
@ -81,8 +76,7 @@ else()
|
|||||||
SOURCES ${sources_files} fluentui.rc
|
SOURCES ${sources_files} fluentui.rc
|
||||||
QML_FILES ${qml_files}
|
QML_FILES ${qml_files}
|
||||||
RESOURCES ${resource_files}
|
RESOURCES ${resource_files}
|
||||||
)
|
)
|
||||||
endif()
|
|
||||||
|
|
||||||
#链接库
|
#链接库
|
||||||
target_link_libraries(${PROJECT_NAME} PUBLIC
|
target_link_libraries(${PROJECT_NAME} PUBLIC
|
||||||
|
@ -1,160 +1,157 @@
|
|||||||
import QtQuick
|
import QtQuick
|
||||||
import QtQuick.Layouts
|
import QtQuick.Controls.impl
|
||||||
import QtQuick.Controls
|
import QtQuick.Templates as T
|
||||||
import FluentUI
|
import FluentUI
|
||||||
|
|
||||||
Rectangle{
|
T.SpinBox {
|
||||||
readonly property string displayText : d._displayText
|
id: control
|
||||||
property bool disabled: false
|
property bool disabled: false
|
||||||
property int from: 0
|
property color normalColor: FluTheme.dark ? Qt.rgba(56/255,56/255,56/255,1) : Qt.rgba(232/255,232/255,232/255,1)
|
||||||
property int to: 99
|
property color hoverColor: FluTheme.dark ? Qt.rgba(64/255,64/255,64/255,1) : Qt.rgba(224/255,224/255,224/255,1)
|
||||||
property var validator: IntValidator {
|
property color pressedColor: FluTheme.dark ? Qt.rgba(72/255,72/255,72/255,1) : Qt.rgba(216/255,216/255,216/255,1)
|
||||||
|
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
|
||||||
|
contentItem.implicitWidth + leftPadding + rightPadding)
|
||||||
|
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
|
||||||
|
implicitContentHeight + topPadding + bottomPadding,
|
||||||
|
up.implicitIndicatorHeight, down.implicitIndicatorHeight)
|
||||||
|
leftPadding: padding + (control.mirrored ? (up.indicator ? up.indicator.width : 0) : (down.indicator ? down.indicator.width : 0))
|
||||||
|
rightPadding: padding + (control.mirrored ? (down.indicator ? down.indicator.width : 0) : (up.indicator ? up.indicator.width : 0))
|
||||||
|
enabled: !disabled
|
||||||
|
validator: IntValidator {
|
||||||
|
locale: control.locale.name
|
||||||
bottom: Math.min(control.from, control.to)
|
bottom: Math.min(control.from, control.to)
|
||||||
top: Math.max(control.from, control.to)
|
top: Math.max(control.from, control.to)
|
||||||
}
|
}
|
||||||
id:control
|
|
||||||
implicitWidth: 200
|
contentItem: TextInput {
|
||||||
implicitHeight: 34
|
property color normalColor: FluTheme.dark ? Qt.rgba(255/255,255/255,255/255,1) : Qt.rgba(27/255,27/255,27/255,1)
|
||||||
radius: 4
|
property color disableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||||
color: FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(1,1,1,1)
|
property color placeholderNormalColor: FluTheme.dark ? Qt.rgba(210/255,210/255,210/255,1) : Qt.rgba(96/255,96/255,96/255,1)
|
||||||
border.width: 1
|
property color placeholderFocusColor: FluTheme.dark ? Qt.rgba(152/255,152/255,152/255,1) : Qt.rgba(141/255,141/255,141/255,1)
|
||||||
border.color: FluTheme.dark ? Qt.rgba(76/255,76/255,76/255,1) : Qt.rgba(240/255,240/255,240/255,1)
|
property color placeholderDisableColor: FluTheme.dark ? Qt.rgba(131/255,131/255,131/255,1) : Qt.rgba(160/255,160/255,160/255,1)
|
||||||
QtObject{
|
z: 2
|
||||||
id:d
|
|
||||||
property string _displayText: "0"
|
|
||||||
}
|
|
||||||
Component{
|
|
||||||
id:com_edit
|
|
||||||
FluTextBox{
|
|
||||||
rightPadding: 80
|
|
||||||
iconRightMargin: 55
|
|
||||||
disabled: control.disabled
|
|
||||||
validator: control.validator
|
|
||||||
text: d._displayText
|
|
||||||
Component.onCompleted: {
|
|
||||||
forceActiveFocus()
|
|
||||||
}
|
|
||||||
onCommit: {
|
|
||||||
var number = Number(text)
|
|
||||||
if(number>=control.from && number<=control.to){
|
|
||||||
d._displayText = String(number)
|
|
||||||
}
|
|
||||||
edit_loader.sourceComponent = null
|
|
||||||
}
|
|
||||||
onActiveFocusChanged: {
|
|
||||||
if(!activeFocus){
|
|
||||||
edit_loader.sourceComponent = null
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FluTextBox{
|
|
||||||
id:text_number
|
|
||||||
anchors.fill: parent
|
|
||||||
readOnly: true
|
|
||||||
rightPadding: 80
|
|
||||||
disabled: control.disabled
|
|
||||||
text: control.displayText
|
text: control.displayText
|
||||||
MouseArea{
|
clip: width < implicitWidth
|
||||||
anchors.fill: parent
|
padding: 6
|
||||||
onClicked: {
|
font: control.font
|
||||||
edit_loader.sourceComponent = com_edit
|
color: {
|
||||||
|
if(!enabled){
|
||||||
|
return disableColor
|
||||||
}
|
}
|
||||||
|
return normalColor
|
||||||
}
|
}
|
||||||
}
|
selectionColor: Qt.alpha(FluTheme.primaryColor.lightest,0.6)
|
||||||
Loader{
|
selectedTextColor: color
|
||||||
id:edit_loader
|
horizontalAlignment: Qt.AlignHCenter
|
||||||
anchors.fill: parent
|
verticalAlignment: Qt.AlignVCenter
|
||||||
}
|
readOnly: !control.editable
|
||||||
FluIconButton{
|
validator: control.validator
|
||||||
id:btn_up
|
inputMethodHints: control.inputMethodHints
|
||||||
width: 20
|
Rectangle{
|
||||||
height: 20
|
width: parent.width
|
||||||
iconSize: 16
|
height: contentItem.activeFocus ? 3 : 1
|
||||||
disabled: {
|
anchors.bottom: parent.bottom
|
||||||
if(control.disabled===true){
|
visible: contentItem.enabled
|
||||||
return true
|
color: {
|
||||||
}
|
if(FluTheme.dark){
|
||||||
return Number(control.displayText) === control.to
|
contentItem.activeFocus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
|
||||||
}
|
|
||||||
iconSource: FluentIcons.ChevronUp
|
|
||||||
anchors{
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
right: parent.right
|
|
||||||
rightMargin: 30
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
d._displayText = String(Math.min(Number(d._displayText)+1,control.to))
|
|
||||||
}
|
|
||||||
MouseArea{
|
|
||||||
anchors.fill: parent
|
|
||||||
onReleased: {
|
|
||||||
timer.stop()
|
|
||||||
}
|
|
||||||
TapHandler{
|
|
||||||
onTapped: {
|
|
||||||
btn_up.clicked()
|
|
||||||
}
|
|
||||||
onCanceled: {
|
|
||||||
timer.stop()
|
|
||||||
}
|
|
||||||
onLongPressed: {
|
|
||||||
timer.isUp = true
|
|
||||||
timer.start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
FluIconButton{
|
|
||||||
id:btn_down
|
|
||||||
iconSource: FluentIcons.ChevronDown
|
|
||||||
width: 20
|
|
||||||
height: 20
|
|
||||||
disabled: {
|
|
||||||
if(control.disabled === true){
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return Number(control.displayText) === control.from
|
|
||||||
}
|
|
||||||
iconSize: 16
|
|
||||||
anchors{
|
|
||||||
verticalCenter: parent.verticalCenter
|
|
||||||
right: parent.right
|
|
||||||
rightMargin: 5
|
|
||||||
}
|
|
||||||
onClicked: {
|
|
||||||
d._displayText = String(Math.max(Number(d._displayText)-1,control.from))
|
|
||||||
}
|
|
||||||
MouseArea{
|
|
||||||
anchors.fill: parent
|
|
||||||
onReleased: {
|
|
||||||
timer.stop()
|
|
||||||
}
|
|
||||||
TapHandler{
|
|
||||||
onTapped: {
|
|
||||||
btn_down.clicked()
|
|
||||||
}
|
|
||||||
onCanceled: {
|
|
||||||
timer.stop()
|
|
||||||
}
|
|
||||||
onLongPressed: {
|
|
||||||
timer.isUp = false
|
|
||||||
timer.start()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Timer{
|
|
||||||
id:timer
|
|
||||||
property bool isUp : true
|
|
||||||
interval: 50
|
|
||||||
repeat: true
|
|
||||||
onTriggered: {
|
|
||||||
if(isUp){
|
|
||||||
btn_up.clicked()
|
|
||||||
}else{
|
}else{
|
||||||
btn_down.clicked()
|
return contentItem.activeFocus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Behavior on height{
|
||||||
|
enabled: FluTheme.enableAnimation
|
||||||
|
NumberAnimation{
|
||||||
|
duration: 83
|
||||||
|
easing.type: Easing.OutCubic
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
up.indicator: FluItem {
|
||||||
|
x: control.mirrored ? 0 : control.width - width
|
||||||
|
height: control.height
|
||||||
|
implicitWidth: 32
|
||||||
|
implicitHeight: 32
|
||||||
|
radius: [0,4,4,0]
|
||||||
|
Rectangle{
|
||||||
|
anchors.fill: parent
|
||||||
|
color: {
|
||||||
|
if(control.up.pressed){
|
||||||
|
return control.pressedColor
|
||||||
|
}
|
||||||
|
if(control.up.hovered){
|
||||||
|
return control.hoverColor
|
||||||
|
}
|
||||||
|
return control.normalColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
x: (parent.width - width) / 2
|
||||||
|
y: (parent.height - height) / 2
|
||||||
|
width: parent.width / 3
|
||||||
|
height: 2
|
||||||
|
color: enabled ? FluTheme.dark ? Qt.rgba(1,1,1,1) : Qt.rgba(0,0,0,1) : FluColors.Grey90
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
x: (parent.width - width) / 2
|
||||||
|
y: (parent.height - height) / 2
|
||||||
|
width: 2
|
||||||
|
height: parent.width / 3
|
||||||
|
color: enabled ? FluTheme.dark ? Qt.rgba(1,1,1,1) : Qt.rgba(0,0,0,1) : FluColors.Grey90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
down.indicator: FluItem {
|
||||||
|
x: control.mirrored ? parent.width - width : 0
|
||||||
|
height: control.height
|
||||||
|
implicitWidth: 32
|
||||||
|
implicitHeight: 32
|
||||||
|
radius: [4,0,0,4]
|
||||||
|
Rectangle{
|
||||||
|
anchors.fill: parent
|
||||||
|
color: {
|
||||||
|
if(control.down.pressed){
|
||||||
|
return control.pressedColor
|
||||||
|
}
|
||||||
|
if(control.down.hovered){
|
||||||
|
return control.hoverColor
|
||||||
|
}
|
||||||
|
return normalColor
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Rectangle {
|
||||||
|
x: (parent.width - width) / 2
|
||||||
|
y: (parent.height - height) / 2
|
||||||
|
width: parent.width / 3
|
||||||
|
height: 2
|
||||||
|
color: enabled ? FluTheme.dark ? Qt.rgba(1,1,1,1) : Qt.rgba(0,0,0,1) : FluColors.Grey90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
background: Rectangle {
|
||||||
|
implicitWidth: 136
|
||||||
|
radius: 4
|
||||||
|
border.width: 1
|
||||||
|
border.color: {
|
||||||
|
if(contentItem.disabled){
|
||||||
|
return FluTheme.dark ? Qt.rgba(73/255,73/255,73/255,1) : Qt.rgba(237/255,237/255,237/255,1)
|
||||||
|
}
|
||||||
|
return FluTheme.dark ? Qt.rgba(76/255,76/255,76/255,1) : Qt.rgba(240/255,240/255,240/255,1)
|
||||||
|
}
|
||||||
|
color: {
|
||||||
|
if(contentItem.disabled){
|
||||||
|
return FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
|
||||||
|
}
|
||||||
|
if(contentItem.activeFocus){
|
||||||
|
return FluTheme.dark ? Qt.rgba(36/255,36/255,36/255,1) : Qt.rgba(1,1,1,1)
|
||||||
|
}
|
||||||
|
if(contentItem.hovered){
|
||||||
|
return FluTheme.dark ? Qt.rgba(68/255,68/255,68/255,1) : Qt.rgba(251/255,251/255,251/255,1)
|
||||||
|
}
|
||||||
|
return FluTheme.dark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(1,1,1,1)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ Rectangle{
|
|||||||
if(inputItem.disabled){
|
if(inputItem.disabled){
|
||||||
return FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
|
return FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
|
||||||
}
|
}
|
||||||
if(inputItem.focus){
|
if(inputItem.activeFocus){
|
||||||
return FluTheme.dark ? Qt.rgba(36/255,36/255,36/255,1) : Qt.rgba(1,1,1,1)
|
return FluTheme.dark ? Qt.rgba(36/255,36/255,36/255,1) : Qt.rgba(1,1,1,1)
|
||||||
}
|
}
|
||||||
if(inputItem.hovered){
|
if(inputItem.hovered){
|
||||||
@ -36,14 +36,14 @@ Rectangle{
|
|||||||
}
|
}
|
||||||
Rectangle{
|
Rectangle{
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: inputItem.focus ? 3 : 1
|
height: inputItem.activeFocus ? 3 : 1
|
||||||
anchors.bottom: parent.bottom
|
anchors.bottom: parent.bottom
|
||||||
visible: !inputItem.disabled
|
visible: !inputItem.disabled
|
||||||
color: {
|
color: {
|
||||||
if(FluTheme.dark){
|
if(FluTheme.dark){
|
||||||
inputItem.focus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
|
inputItem.activeFocus ? FluTheme.primaryColor.lighter : Qt.rgba(166/255,166/255,166/255,1)
|
||||||
}else{
|
}else{
|
||||||
return inputItem.focus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
|
return inputItem.activeFocus ? FluTheme.primaryColor.dark : Qt.rgba(183/255,183/255,183/255,1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Behavior on height{
|
Behavior on height{
|
||||||
|
Loading…
Reference in New Issue
Block a user