mirror of
https://github.com/zhuzichu520/FluentUI.git
synced 2025-07-03 16:45:24 +08:00
update
This commit is contained in:
@ -33,6 +33,15 @@ void Fluent::registerTypes(const char *uri){
|
||||
qmlRegisterType<WindowHelper>(uri,major,minor,"WindowHelper");
|
||||
qmlRegisterType<FluColorSet>(uri,major,minor,"FluColorSet");
|
||||
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluArea.qml"),uri,major,minor,"FluArea");
|
||||
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluContentPage.qml"),uri,major,minor,"FluContentPage");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluScrollablePage.qml"),uri,major,minor,"FluScrollablePage");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemHeader.qml"),uri,major,minor,"FluPaneItemHeader");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItem.qml"),uri,major,minor,"FluPaneItem");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluPaneItemSeparator.qml"),uri,major,minor,"FluPaneItemSeparator");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluNavigationView.qml"),uri,major,minor,"FluNavigationView");
|
||||
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluAutoSuggestBox.qml"),uri,major,minor,"FluAutoSuggestBox");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluExpander.qml"),uri,major,minor,"FluExpander");
|
||||
qmlRegisterType(QUrl("qrc:/com.zhuzichu/controls/FluTreeView.qml"),uri,major,minor,"FluTreeView");
|
||||
|
@ -14,7 +14,8 @@ Rectangle{
|
||||
return Window.window.active ? borerlessColor : Qt.lighter(borerlessColor,1.1)
|
||||
}
|
||||
visible: FluTheme.isFrameless
|
||||
height: visible ? 50 : 0
|
||||
height: visible ? 34 : 0
|
||||
|
||||
width: {
|
||||
if(parent==null)
|
||||
return 200
|
||||
@ -60,7 +61,7 @@ Rectangle{
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left: parent.left
|
||||
leftMargin: 14
|
||||
leftMargin: 10
|
||||
}
|
||||
color:root.textColor
|
||||
fontStyle: FluText.Title
|
||||
@ -69,14 +70,13 @@ Rectangle{
|
||||
}
|
||||
|
||||
RowLayout{
|
||||
anchors.right: parent.right;
|
||||
anchors.rightMargin: 10
|
||||
height: parent.height
|
||||
spacing: 5
|
||||
anchors.right: parent.right
|
||||
height: 30
|
||||
spacing: 0
|
||||
|
||||
TFpsMonitor{
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
Layout.rightMargin: 12
|
||||
Layout.rightMargin: 20
|
||||
Layout.topMargin: 5
|
||||
color:root.textColor
|
||||
visible: showFps
|
||||
@ -84,8 +84,9 @@ Rectangle{
|
||||
|
||||
RowLayout{
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
spacing: 5
|
||||
Layout.rightMargin: 14
|
||||
visible: showDark
|
||||
spacing: 5
|
||||
FluText{
|
||||
text:"夜间模式"
|
||||
color:root.textColor
|
||||
|
28
src/controls/FluArea.qml
Normal file
28
src/controls/FluArea.qml
Normal file
@ -0,0 +1,28 @@
|
||||
import QtQuick 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Rectangle {
|
||||
radius: 4
|
||||
color: FluTheme.isDark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
|
||||
border.color: FluTheme.isDark ? Qt.rgba(45/255,45/255,45/255,1) : Qt.rgba(226/255,229/255,234/255,1)
|
||||
border.width: 1
|
||||
implicitHeight: height
|
||||
implicitWidth: width
|
||||
|
||||
default property alias content: container.data
|
||||
property int paddings : 0
|
||||
property int leftPadding : 0
|
||||
property int rightPadding : 0
|
||||
property int topPadding : 0
|
||||
property int bottomPadding : 0
|
||||
|
||||
Item {
|
||||
id: container
|
||||
anchors.fill: parent
|
||||
anchors.leftMargin: Math.max(paddings,leftPadding)
|
||||
anchors.rightMargin: Math.max(paddings,rightPadding)
|
||||
anchors.topMargin: Math.max(paddings,topPadding)
|
||||
anchors.bottomMargin: Math.max(paddings,bottomPadding)
|
||||
}
|
||||
|
||||
}
|
29
src/controls/FluContentPage.qml
Normal file
29
src/controls/FluContentPage.qml
Normal file
@ -0,0 +1,29 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
|
||||
id:root
|
||||
|
||||
property alias title: text_title.text
|
||||
default property alias content: container.data
|
||||
|
||||
FluText{
|
||||
id:text_title
|
||||
fontStyle: FluText.TitleLarge
|
||||
}
|
||||
|
||||
Item{
|
||||
clip: true
|
||||
id:container
|
||||
anchors{
|
||||
top: text_title.bottom
|
||||
bottom: parent.bottom
|
||||
}
|
||||
width: parent.width
|
||||
}
|
||||
|
||||
}
|
@ -10,6 +10,8 @@ Item {
|
||||
id:root
|
||||
height: layout_header.height + container.height
|
||||
width: 400
|
||||
implicitWidth: width
|
||||
implicitHeight: height
|
||||
|
||||
property int contentHeight : 300
|
||||
|
||||
|
@ -14,9 +14,9 @@ Rectangle {
|
||||
property bool disabled: false
|
||||
property bool hovered: button_mouse.containsMouse
|
||||
|
||||
property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(244/255,244/255,244/255,1)
|
||||
property color normalColor: FluTheme.isDark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1)
|
||||
property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(1,1,1,1)
|
||||
property color hoverColor: FluTheme.isDark ? Qt.rgba(62/255,62/255,62/255,1) : Qt.rgba(0,0,0,0.03)
|
||||
property color normalColor: FluTheme.isDark ? Qt.rgba(0,0,0,0) : Qt.rgba(0,0,0,0)
|
||||
property color disableColor: FluTheme.isDark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(0,0,0,0)
|
||||
|
||||
property color textColor: {
|
||||
if(FluTheme.isDark){
|
||||
|
341
src/controls/FluNavigationView.qml
Normal file
341
src/controls/FluNavigationView.qml
Normal file
@ -0,0 +1,341 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
|
||||
id:root
|
||||
|
||||
property FluObject items
|
||||
property FluObject footerItems
|
||||
|
||||
property int displayMode: width<=700 ? FluNavigationView.Minimal : FluNavigationView.Open
|
||||
|
||||
property bool displaMinimalNav : false
|
||||
|
||||
onDisplayModeChanged: {
|
||||
if(displayMode === FluNavigationView.Minimal){
|
||||
anim_navi.enabled = false
|
||||
displaMinimalNav = false
|
||||
timer_anim_enable.restart()
|
||||
}
|
||||
}
|
||||
|
||||
Timer{
|
||||
id:timer_anim_enable
|
||||
interval: 150
|
||||
onTriggered: {
|
||||
anim_navi.enabled = true
|
||||
}
|
||||
}
|
||||
|
||||
enum DisplayMode {
|
||||
Minimal,
|
||||
Open,
|
||||
Auto
|
||||
}
|
||||
|
||||
property var window : {
|
||||
if(Window.window == null)
|
||||
return null
|
||||
return Window.window
|
||||
}
|
||||
|
||||
Component{
|
||||
id:com_panel_item_separatorr
|
||||
FluDivider{
|
||||
width: nav_list.width
|
||||
height: 1
|
||||
}
|
||||
}
|
||||
|
||||
Component{
|
||||
id:com_panel_item_header
|
||||
Item{
|
||||
height: 30
|
||||
width: nav_list.width
|
||||
FluText{
|
||||
text:model.title
|
||||
fontStyle: FluText.BodyStrong
|
||||
anchors{
|
||||
bottom: parent.bottom
|
||||
left:parent.left
|
||||
leftMargin: 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Component{
|
||||
id:com_panel_item
|
||||
Item{
|
||||
height: 38
|
||||
width: nav_list.width
|
||||
|
||||
Rectangle{
|
||||
radius: 4
|
||||
anchors{
|
||||
top: parent.top
|
||||
bottom: parent.bottom
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
topMargin: 2
|
||||
bottomMargin: 2
|
||||
leftMargin: 6
|
||||
rightMargin: 6
|
||||
}
|
||||
MouseArea{
|
||||
id:item_mouse
|
||||
hoverEnabled: true
|
||||
anchors.fill: parent
|
||||
onClicked: {
|
||||
if(type===0){
|
||||
model.repTap()
|
||||
if(nav_list.currentIndex !== position){
|
||||
nav_list.currentIndex = position
|
||||
model.tap()
|
||||
}
|
||||
}else{
|
||||
model.tap()
|
||||
}
|
||||
}
|
||||
}
|
||||
color: {
|
||||
if(FluTheme.isDark){
|
||||
if((nav_list.currentIndex === position)&&type===0){
|
||||
return "#2D2D2D"
|
||||
}
|
||||
if(item_mouse.containsMouse){
|
||||
return "#292929"
|
||||
}
|
||||
return Qt.rgba(0,0,0,0)
|
||||
}else{
|
||||
if(item_mouse.containsMouse){
|
||||
return Qt.rgba(0,0,0,0.03)
|
||||
}
|
||||
if(nav_list.currentIndex === position&&type===0){
|
||||
return Qt.rgba(0,0,0,0.06)
|
||||
}
|
||||
return Qt.rgba(0,0,0,0)
|
||||
}
|
||||
}
|
||||
|
||||
FluText{
|
||||
text:model.title
|
||||
anchors{
|
||||
verticalCenter: parent.verticalCenter
|
||||
left:parent.left
|
||||
leftMargin: 14
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Item {
|
||||
id:nav_app_bar
|
||||
width: parent.width
|
||||
height: 38
|
||||
|
||||
RowLayout{
|
||||
height:parent.height
|
||||
spacing: 0
|
||||
FluIconButton{
|
||||
icon: FluentIcons.FA_arrow_left
|
||||
Layout.leftMargin: 5
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
disabled: nav_swipe.depth === 1
|
||||
onClicked: {
|
||||
nav_swipe.pop()
|
||||
nav_list.stackIndex.pop()
|
||||
var index = nav_list.stackIndex[nav_list.stackIndex.length-1]
|
||||
nav_list.enableStack = false
|
||||
nav_list.currentIndex = index
|
||||
nav_list.enableStack = true
|
||||
}
|
||||
}
|
||||
FluIconButton{
|
||||
icon: FluentIcons.FA_navicon
|
||||
Layout.leftMargin: 5
|
||||
visible: displayMode === FluNavigationView.Minimal
|
||||
Layout.alignment: Qt.AlignVCenter
|
||||
onClicked: {
|
||||
displaMinimalNav = !displaMinimalNav
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RowLayout{
|
||||
anchors{
|
||||
right: parent.right
|
||||
rightMargin: 14
|
||||
verticalCenter: parent.verticalCenter
|
||||
}
|
||||
spacing: 5
|
||||
FluText{
|
||||
text:"夜间模式"
|
||||
fontStyle: FluText.Body
|
||||
}
|
||||
FluToggleSwitch{
|
||||
checked: FluTheme.isDark
|
||||
onClickFunc:function(){
|
||||
FluTheme.isDark = !FluTheme.isDark
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Item{
|
||||
anchors{
|
||||
left: displayMode === FluNavigationView.Minimal ? parent.left : layout_list.right
|
||||
leftMargin: 2
|
||||
top: nav_app_bar.bottom
|
||||
right: parent.right
|
||||
rightMargin: 10
|
||||
bottom: parent.bottom
|
||||
bottomMargin: 20
|
||||
}
|
||||
|
||||
StackView{
|
||||
id:nav_swipe
|
||||
anchors.fill: parent
|
||||
clip: true
|
||||
anchors.margins: 10
|
||||
popEnter : Transition{}
|
||||
popExit : Transition{}
|
||||
pushEnter : Transition{}
|
||||
pushExit : Transition{}
|
||||
replaceEnter : Transition{}
|
||||
replaceExit : Transition{}
|
||||
}
|
||||
}
|
||||
|
||||
MouseArea{
|
||||
anchors.fill: parent
|
||||
enabled: (displayMode === FluNavigationView.Minimal && displaMinimalNav)
|
||||
onClicked: {
|
||||
displaMinimalNav = false
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle{
|
||||
id:layout_list
|
||||
width: 300
|
||||
anchors{
|
||||
top: nav_app_bar.bottom
|
||||
bottom: parent.bottom
|
||||
}
|
||||
x: {
|
||||
if(displayMode !== FluNavigationView.Minimal)
|
||||
return 0
|
||||
return (displayMode === FluNavigationView.Minimal && displaMinimalNav) ? 0 : -width
|
||||
}
|
||||
Behavior on x{
|
||||
id:anim_navi
|
||||
NumberAnimation{
|
||||
duration: 150
|
||||
}
|
||||
}
|
||||
color: {
|
||||
if(displayMode === FluNavigationView.Minimal){
|
||||
return FluTheme.isDark ? Qt.rgba(61/255,61/255,61/255,1) : Qt.rgba(243/255,243/255,243/255,1)
|
||||
}
|
||||
if(window && window.active){
|
||||
return FluTheme.isDark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(238/255,244/255,249/255,1)
|
||||
}
|
||||
return FluTheme.isDark ? Qt.rgba(32/255,32/255,32/255,1) : Qt.rgba(243/255,243/255,243/255,1)
|
||||
}
|
||||
Behavior on color{
|
||||
ColorAnimation {
|
||||
duration: 300
|
||||
}
|
||||
}
|
||||
ListView{
|
||||
id:nav_list
|
||||
property bool enableStack: true
|
||||
property var stackIndex: []
|
||||
clip: true
|
||||
anchors{
|
||||
top: parent.top
|
||||
left: parent.left
|
||||
right: parent.right
|
||||
bottom: layout_footer.top
|
||||
}
|
||||
currentIndex: -1
|
||||
onCurrentIndexChanged: {
|
||||
if(enableStack){
|
||||
stackIndex.push(currentIndex)
|
||||
}
|
||||
}
|
||||
model:{
|
||||
if(items){
|
||||
return items.children
|
||||
}
|
||||
}
|
||||
boundsBehavior: ListView.StopAtBounds
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property var position: index
|
||||
property int type: 0
|
||||
sourceComponent: {
|
||||
if(modelData instanceof FluPaneItem){
|
||||
return com_panel_item
|
||||
}
|
||||
if(modelData instanceof FluPaneItemHeader){
|
||||
return com_panel_item_header
|
||||
}
|
||||
if(modelData instanceof FluPaneItemSeparator){
|
||||
return com_panel_item_separatorr
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ListView{
|
||||
id:layout_footer
|
||||
width: layout_list.width
|
||||
height: childrenRect.height
|
||||
anchors.bottom: parent.bottom
|
||||
boundsBehavior: ListView.StopAtBounds
|
||||
model: {
|
||||
if(footerItems){
|
||||
return footerItems.children
|
||||
}
|
||||
}
|
||||
currentIndex: -1
|
||||
delegate: Loader{
|
||||
property var model: modelData
|
||||
property var position: index
|
||||
property int type: 1
|
||||
sourceComponent: {
|
||||
if(modelData instanceof FluPaneItem){
|
||||
return com_panel_item
|
||||
}
|
||||
if(modelData instanceof FluPaneItemHeader){
|
||||
return com_panel_item_header
|
||||
}
|
||||
if(modelData instanceof FluPaneItemSeparator){
|
||||
return com_panel_item_separatorr
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
function push(url){
|
||||
nav_swipe.push(url)
|
||||
}
|
||||
|
||||
function setCurrentIndex(index){
|
||||
nav_list.currentIndex = index
|
||||
}
|
||||
|
||||
}
|
7
src/controls/FluPaneItem.qml
Normal file
7
src/controls/FluPaneItem.qml
Normal file
@ -0,0 +1,7 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
QtObject {
|
||||
property string title
|
||||
signal tap
|
||||
signal repTap
|
||||
}
|
5
src/controls/FluPaneItemHeader.qml
Normal file
5
src/controls/FluPaneItemHeader.qml
Normal file
@ -0,0 +1,5 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
QtObject {
|
||||
property string title
|
||||
}
|
5
src/controls/FluPaneItemSeparator.qml
Normal file
5
src/controls/FluPaneItemSeparator.qml
Normal file
@ -0,0 +1,5 @@
|
||||
import QtQuick 2.15
|
||||
|
||||
QtObject {
|
||||
|
||||
}
|
34
src/controls/FluScrollablePage.qml
Normal file
34
src/controls/FluScrollablePage.qml
Normal file
@ -0,0 +1,34 @@
|
||||
import QtQuick 2.15
|
||||
import QtQuick.Layouts 1.15
|
||||
import QtQuick.Window 2.15
|
||||
import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
|
||||
Item {
|
||||
|
||||
id:root
|
||||
|
||||
property alias title: text_title.text
|
||||
default property alias content: container.data
|
||||
property int spacing : 5
|
||||
|
||||
FluText{
|
||||
id:text_title
|
||||
fontStyle: FluText.TitleLarge
|
||||
}
|
||||
|
||||
ScrollView{
|
||||
clip: true
|
||||
width: parent.width
|
||||
contentWidth: parent.width
|
||||
anchors{
|
||||
top: text_title.bottom
|
||||
bottom: parent.bottom
|
||||
}
|
||||
ColumnLayout{
|
||||
id:container
|
||||
spacing: root.spacing
|
||||
width: parent.width
|
||||
}
|
||||
}
|
||||
}
|
@ -5,9 +5,8 @@ import QtQuick.Controls 2.15
|
||||
import FluentUI 1.0
|
||||
import QtGraphicalEffects 1.15
|
||||
|
||||
Rectangle {
|
||||
Item {
|
||||
id:root
|
||||
color: FluTheme.isDark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(253/255,253/255,253/255,1)
|
||||
|
||||
enum TreeViewSelectionMode {
|
||||
None,
|
||||
@ -101,12 +100,12 @@ Rectangle {
|
||||
if(item_layout.singleSelected && selectionMode === FluTreeView.Single){
|
||||
return Qt.rgba(62/255,62/255,62/255,1)
|
||||
}
|
||||
return (item_layout_mouse.containsMouse || item_layout_expanded.hovered || item_layout_checkbox.hovered)?Qt.rgba(62/255,62/255,62/255,1):Qt.rgba(50/255,50/255,50/255,1)
|
||||
return (item_layout_mouse.containsMouse || item_layout_expanded.hovered || item_layout_checkbox.hovered)?Qt.rgba(62/255,62/255,62/255,1):Qt.rgba(0,0,0,0)
|
||||
}else{
|
||||
if(item_layout.singleSelected && selectionMode === FluTreeView.Single){
|
||||
return Qt.rgba(244/255,244/255,244/255,1)
|
||||
return Qt.rgba(0,0,0,0.06)
|
||||
}
|
||||
return (item_layout_mouse.containsMouse || item_layout_expanded.hovered || item_layout_checkbox.hovered)?Qt.rgba(244/255,244/255,244/255,1):Qt.rgba(253/255,253/255,253/255,1)
|
||||
return (item_layout_mouse.containsMouse || item_layout_expanded.hovered || item_layout_checkbox.hovered)?Qt.rgba(0,0,0,0.03):Qt.rgba(0,0,0,0)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -60,6 +60,7 @@ Item {
|
||||
color:root.color
|
||||
anchors.fill: parent
|
||||
anchors.margins: borderless
|
||||
clip: true
|
||||
Behavior on color{
|
||||
ColorAnimation {
|
||||
duration: 300
|
||||
|
@ -36,5 +36,12 @@
|
||||
<file>controls/FluTreeView.qml</file>
|
||||
<file>controls/FluExpander.qml</file>
|
||||
<file>controls/FluAutoSuggestBox.qml</file>
|
||||
<file>controls/FluNavigationView.qml</file>
|
||||
<file>controls/FluPaneItem.qml</file>
|
||||
<file>controls/FluPaneItemHeader.qml</file>
|
||||
<file>controls/FluPaneItemSeparator.qml</file>
|
||||
<file>controls/FluScrollablePage.qml</file>
|
||||
<file>controls/FluContentPage.qml</file>
|
||||
<file>controls/FluArea.qml</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
Reference in New Issue
Block a user