main
zhuzihcu 2023-05-31 15:39:59 +08:00
parent 52174b7e24
commit 5f2f127623
10 changed files with 88 additions and 310 deletions

View File

@ -30,17 +30,14 @@ FluScrollablePage{
Repeater{ Repeater{
model: [{title:"System",mode:FluDarkMode.System},{title:"Light",mode:FluDarkMode.Light},{title:"Dark",mode:FluDarkMode.Dark}] model: [{title:"System",mode:FluDarkMode.System},{title:"Light",mode:FluDarkMode.Light},{title:"Dark",mode:FluDarkMode.Dark}]
delegate: FluRadioButton{ delegate: FluRadioButton{
selected : FluTheme.darkMode === modelData.mode checked : FluTheme.darkMode === modelData.mode
text:modelData.title text:modelData.title
onClicked:{ clickListener:function(){
FluTheme.darkMode = modelData.mode FluTheme.darkMode = modelData.mode
} }
} }
} }
} }
} }
FluArea{ FluArea{
@ -64,9 +61,9 @@ FluScrollablePage{
Repeater{ Repeater{
model: [{title:"Open",mode:FluNavigationView.Open},{title:"Compact",mode:FluNavigationView.Compact},{title:"Minimal",mode:FluNavigationView.Minimal},{title:"Auto",mode:FluNavigationView.Auto}] model: [{title:"Open",mode:FluNavigationView.Open},{title:"Compact",mode:FluNavigationView.Compact},{title:"Minimal",mode:FluNavigationView.Minimal},{title:"Auto",mode:FluNavigationView.Auto}]
delegate: FluRadioButton{ delegate: FluRadioButton{
selected : MainEvent.displayMode===modelData.mode checked : MainEvent.displayMode===modelData.mode
text:modelData.title text:modelData.title
onClicked:{ clickListener:function(){
MainEvent.displayMode = modelData.mode MainEvent.displayMode = modelData.mode
} }
} }
@ -98,9 +95,9 @@ FluScrollablePage{
Repeater{ Repeater{
model: ["Zh","En"] model: ["Zh","En"]
delegate: FluRadioButton{ delegate: FluRadioButton{
selected : appInfo.lang.objectName === modelData checked: appInfo.lang.objectName === modelData
text:modelData text:modelData
onClicked:{ clickListener:function(){
appInfo.changeLang(modelData) appInfo.changeLang(modelData)
} }
} }

View File

@ -63,4 +63,6 @@ bool FluTools::isWin(){
#endif #endif
} }
void FluTools::setQuitOnLastWindowClosed(bool val){
qApp->setQuitOnLastWindowClosed(val);
}

View File

@ -48,6 +48,8 @@ public:
Q_INVOKABLE bool isWin(); Q_INVOKABLE bool isWin();
Q_INVOKABLE void setQuitOnLastWindowClosed(bool val);
}; };
#endif // FLUTOOLS_H #endif // FLUTOOLS_H

View File

@ -8,6 +8,25 @@ Button {
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 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 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) property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
property color textColor: {
if(FluTheme.dark){
if(disabled){
return Qt.rgba(131/255,131/255,131/255,1)
}
if(pressed){
return Qt.rgba(162/255,162/255,162/255,1)
}
return Qt.rgba(1,1,1,1)
}else{
if(disabled){
return Qt.rgba(160/255,160/255,160/255,1)
}
if(pressed){
return Qt.rgba(96/255,96/255,96/255,1)
}
return Qt.rgba(0,0,0,1)
}
}
id: control id: control
enabled: !disabled enabled: !disabled
focusPolicy:Qt.TabFocus focusPolicy:Qt.TabFocus
@ -36,24 +55,6 @@ Button {
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
font: control.font font: control.font
color: { color: control.textColor
if(FluTheme.dark){
if(disabled){
return Qt.rgba(131/255,131/255,131/255,1)
}
if(pressed){
return Qt.rgba(162/255,162/255,162/255,1)
}
return Qt.rgba(1,1,1,1)
}else{
if(disabled){
return Qt.rgba(160/255,160/255,160/255,1)
}
if(pressed){
return Qt.rgba(96/255,96/255,96/255,1)
}
return Qt.rgba(0,0,0,1)
}
}
} }
} }

View File

@ -9,6 +9,25 @@ Button {
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 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 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) property color disableColor: FluTheme.dark ? Qt.rgba(59/255,59/255,59/255,1) : Qt.rgba(252/255,252/255,252/255,1)
property color textColor: {
if(FluTheme.dark){
if(disabled){
return Qt.rgba(131/255,131/255,131/255,1)
}
if(pressed){
return Qt.rgba(162/255,162/255,162/255,1)
}
return Qt.rgba(1,1,1,1)
}else{
if(disabled){
return Qt.rgba(160/255,160/255,160/255,1)
}
if(pressed){
return Qt.rgba(96/255,96/255,96/255,1)
}
return Qt.rgba(0,0,0,1)
}
}
property var window : Window.window property var window : Window.window
property alias items: menu.content property alias items: menu.content
id: control id: control
@ -49,25 +68,7 @@ Button {
text: control.text text: control.text
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: { color: control.textColor
if(FluTheme.dark){
if(disabled){
return Qt.rgba(131/255,131/255,131/255,1)
}
if(pressed){
return Qt.rgba(162/255,162/255,162/255,1)
}
return Qt.rgba(1,1,1,1)
}else{
if(disabled){
return Qt.rgba(160/255,160/255,160/255,1)
}
if(pressed){
return Qt.rgba(96/255,96/255,96/255,1)
}
return Qt.rgba(0,0,0,1)
}
}
} }
onClicked: { onClicked: {
if(items && menu.getContainerCount()!==0){ if(items && menu.getContainerCount()!==0){

View File

@ -9,6 +9,16 @@ Button {
property color hoverColor: FluTheme.dark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1) property color hoverColor: FluTheme.dark ? Qt.darker(normalColor,1.1) : Qt.lighter(normalColor,1.1)
property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
property color pressedColor: FluTheme.dark ? Qt.darker(normalColor,1.2) : Qt.lighter(normalColor,1.2) property color pressedColor: FluTheme.dark ? Qt.darker(normalColor,1.2) : Qt.lighter(normalColor,1.2)
property color textColor: {
if(FluTheme.dark){
if(disabled){
return Qt.rgba(173/255,173/255,173/255,1)
}
return Qt.rgba(0,0,0,1)
}else{
return Qt.rgba(1,1,1,1)
}
}
id: control id: control
enabled: !disabled enabled: !disabled
Keys.onSpacePressed: control.visualFocus&&clicked() Keys.onSpacePressed: control.visualFocus&&clicked()
@ -38,15 +48,6 @@ Button {
font: control.font font: control.font
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
color: { color: control.textColor
if(FluTheme.dark){
if(disabled){
return Qt.rgba(173/255,173/255,173/255,1)
}
return Qt.rgba(0,0,0,1)
}else{
return Qt.rgba(1,1,1,1)
}
}
} }
} }

View File

@ -352,8 +352,6 @@ Item {
if(model.tapFunc){ if(model.tapFunc){
model.tapFunc() model.tapFunc()
}else{ }else{
model.tap()
d.stackItems.push(model)
nav_list.currentIndex = nav_list.count-layout_footer.count+idx nav_list.currentIndex = nav_list.count-layout_footer.count+idx
layout_footer.currentIndex = idx layout_footer.currentIndex = idx
if(d.isMinimal || d.isCompact){ if(d.isMinimal || d.isCompact){
@ -769,6 +767,15 @@ Item {
return footerItems.children return footerItems.children
} }
} }
onCurrentIndexChanged: {
if(d.enableStack){
var item = model[currentIndex]
if(item instanceof FluPaneItem){
item.tap()
d.stackItems.push(item)
}
}
}
highlightMoveDuration: 150 highlightMoveDuration: 150
highlight: Item{ highlight: Item{
clip: true clip: true

View File

@ -11,6 +11,7 @@ Button {
property color normalColor: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1) property color normalColor: FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1)
property color hoverColor: checked ? FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1) property color hoverColor: checked ? FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(1,1,1,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1)
property color disableColor: checked ? FluTheme.dark ? Qt.rgba(159/255,159/255,159/255,1) : Qt.rgba(159/255,159/255,159/255,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1) property color disableColor: checked ? FluTheme.dark ? Qt.rgba(159/255,159/255,159/255,1) : Qt.rgba(159/255,159/255,159/255,1) : FluTheme.dark ? Qt.rgba(43/255,43/255,43/255,1) : Qt.rgba(222/255,222/255,222/255,1)
property alias textColor: btn_text.textColor
property var clickListener : function(){ property var clickListener : function(){
checked = !checked checked = !checked
} }
@ -34,7 +35,7 @@ Button {
radius: 10 radius: 10
border.width: { border.width: {
if(checked&&disabled){ if(checked&&disabled){
return 3 return 4
} }
if(pressed){ if(pressed){
if(checked){ if(checked){
@ -44,7 +45,7 @@ Button {
} }
if(hovered){ if(hovered){
if(checked){ if(checked){
return 3 return 4
} }
return 1 return 1
} }
@ -74,6 +75,7 @@ Button {
} }
} }
FluText{ FluText{
id:btn_text
text: control.text text: control.text
Layout.alignment: Qt.AlignVCenter Layout.alignment: Qt.AlignVCenter
font: control.font font: control.font

View File

@ -1,235 +0,0 @@
import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic
import QtQuick.Layouts
import FluentUI
Item {
property var columns : []
property var dataSource : []
property int pageCurrent: 1
property int itemCount: 1000
property int pageCount: 10
property int itemHeight: 56
property bool pageVisible: true
signal requestPage(int page,int count)
id:control
implicitHeight: layout_table.height
QtObject{
id:d
property int coumnsWidth: parent.width
}
MouseArea{
anchors.fill: parent
preventStealing: true
}
ListModel{
id:model_coumns
}
ListModel{
id:model_data_source
}
onColumnsChanged: {
model_coumns.clear()
model_coumns.append(columns)
var w = 0
for(var i=0;i<model_coumns.count;i++){
var item = model_coumns.get(i)
w=w+item.width
}
d.coumnsWidth = w
}
onDataSourceChanged: {
model_data_source.clear()
model_data_source.append(dataSource)
}
Flickable{
id:layout_flickable
height: layout_table.height
anchors{
top: parent.top
left: parent.left
right: parent.right
}
contentWidth: layout_table.width
clip:true
ScrollBar.horizontal: FluScrollBar {
}
Rectangle{
anchors.fill: layout_table
radius: 5
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
}
ListView{
id:layout_table
height: contentHeight
width: Math.max(layout_flickable.width,d.coumnsWidth)
clip:true
interactive: false
header: FluRectangle{
id:layout_coumns
height: control.itemHeight
width: parent.width
color:FluTheme.dark ? Qt.rgba(50/255,50/255,50/255,1) : Qt.rgba(247/255,247/255,247/255,1)
radius: [5,5,0,0]
Row{
id:list_coumns
spacing: 0
anchors.fill: parent
Repeater{
model: model_coumns
delegate: Item{
height: list_coumns.height
width: model.width
FluText{
text:model.title
wrapMode: Text.WordWrap
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 14
}
font: FluTextStyle.BodyStrong
}
FluDivider{
width: 1
height: 40
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
visible: index !== model_coumns.count-1
}
}
}
}
}
footer: Item{
height: pageVisible ? 50 : 0
clip: true
width: layout_table.width
FluPagination{
id:pagination
height: 40
pageCurrent: control.pageCurrent
onPageCurrentChanged: control.pageCurrent = pageCurrent
itemCount: control.itemCount
pageCount: control.pageCount
onRequestPage:
(page,count)=> {
control.requestPage(page,count)
}
anchors{
top: parent.top
right: parent.right
}
Connections{
target: control
function onPageCurrentChanged(){
if (control.pageCurrent!==pagination.pageCurrent)
{
pagination.calcNewPage(control.pageCurrent)
}
}
}
}
}
model:model_data_source
delegate: Control{
id:item_control
height: table_row.maxHeight
width: layout_table.width
property var model_values : getObjectValues(index)
property var itemObject: getObject(index)
property var listModel: model
Rectangle{
anchors.fill: parent
color: {
if(item_control.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)
}
}
Row{
id: table_row
spacing: 0
anchors.fill: parent
property int maxHeight: itemHeight
Repeater{
model: model_values
delegate:Item{
height: table_row.maxHeight
width: modelData.width
Loader{
property var model : modelData
property var dataModel : listModel
property var dataObject : itemObject
anchors.fill: parent
sourceComponent: {
if(model.itemData instanceof Component){
return model.itemData
}
return com_text
}
onHeightChanged:
{
table_row.maxHeight = Math.max(table_row.maxHeight,height,itemHeight)
parent.height = table_row.maxHeight
table_row.parent.height = table_row.maxHeight
}
}
}
}
}
FluDivider{
width: parent.width
height: 1
anchors.right: parent.right
anchors.bottom: parent.bottom
}
}
}
}
Component{
id:com_text
Item{
FluCopyableText{
id:table_value
text:String(model.itemData)
width: Math.min(parent.width - 14,implicitWidth)
wrapMode: Text.WordWrap
onImplicitHeightChanged: parent.parent.parent.height = Math.max(implicitHeight + 20,itemHeight)
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 14
}
MouseArea{
id:item_mouse
hoverEnabled: true
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.NoButton
}
FluTooltip{
visible: item_mouse.containsMouse
text:parent.text
delay: 1000
}
}
}
}
function getObject(index){
return model_data_source.get(index)
}
function getObjectValues(index) {
var obj = model_data_source.get(index)
if(!obj)
return
var data = []
for(var i=0;i<model_coumns.count;i++){
var item = model_coumns.get(i)
data.push({itemData:obj[item.dataIndex],width:item.width})
}
return data;
}
}

View File

@ -10,6 +10,15 @@ Button {
property color pressedColor: FluTheme.dark ? Qt.darker(normalColor,1.3) : Qt.lighter(normalColor,1.3) property color pressedColor: FluTheme.dark ? Qt.darker(normalColor,1.3) : Qt.lighter(normalColor,1.3)
property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1) property color disableColor: FluTheme.dark ? Qt.rgba(82/255,82/255,82/255,1) : Qt.rgba(199/255,199/255,199/255,1)
property bool textBold: true property bool textBold: true
property color textColor: {
if(disabled){
return disableColor
}
if(pressed){
return pressedColor
}
return hovered ? hoverColor :normalColor
}
id: control id: control
topPadding:0 topPadding:0
bottomPadding:0 bottomPadding:0
@ -25,20 +34,11 @@ Button {
} }
} }
contentItem: FluText { contentItem: FluText {
id:btn_text
text: control.text text: control.text
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
font.bold: control.textBold font.bold: control.textBold
color: { color: control.textColor
color:{
if(disabled){
return disableColor
}
if(pressed){
return pressedColor
}
return hovered ? hoverColor :normalColor
}
}
} }
} }