Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Commit

Permalink
sync FluentUI 1.6.6
Browse files Browse the repository at this point in the history
  • Loading branch information
朱子楚\zhuzi committed Dec 31, 2023
1 parent 1559cbd commit f82c337
Show file tree
Hide file tree
Showing 46 changed files with 15,955 additions and 15,366 deletions.
107 changes: 95 additions & 12 deletions FluentUI/qml/FluentUI/Controls/FluAppBar.qml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,17 @@ Rectangle{
property bool isMac: FluTools.isMacos()
property color borerlessColor : FluTheme.primaryColor
property var maxClickListener : function(){
if (d.win.visibility === Window.Maximized)
d.win.visibility = Window.Windowed
else
d.win.visibility = Window.Maximized
if(FluTools.isMacos()){
if (d.win.visibility === Window.FullScreen)
d.win.visibility = Window.Windowed
else
d.win.visibility = Window.FullScreen
}else{
if (d.win.visibility === Window.Maximized)
d.win.visibility = Window.Windowed
else
d.win.visibility = Window.Maximized
}
}
property var minClickListener: function(){
d.win.visibility = Window.Minimized
Expand All @@ -57,13 +64,19 @@ Rectangle{
FluTheme.darkMode = FluThemeType.Dark
}
}
property var systemMenuListener: function(){
if(d.win instanceof FluWindow){
d.win.showSystemMenu()
}
}
id:control
color: Qt.rgba(0,0,0,0)
height: visible ? 30 : 0
opacity: visible
z: 65535
Item{
id:d
property bool hoverMaxBtn: false
property var win: Window.window
property bool stayTop: {
if(d.win instanceof FluWindow){
Expand All @@ -74,14 +87,25 @@ Rectangle{
property bool isRestore: win && Window.Maximized === win.visibility
property bool resizable: win && !(win.height === win.maximumHeight && win.height === win.minimumHeight && win.width === win.maximumWidth && win.width === win.minimumWidth)
}
TapHandler {
onTapped: if (tapCount === 2 && d.resizable) btn_maximize.clicked()
gesturePolicy: TapHandler.DragThreshold
}
DragHandler {
target: null
grabPermissions: TapHandler.CanTakeOverFromAnything
onActiveChanged: if (active) { d.win.startSystemMove(); }
MouseArea{
anchors.fill: parent
onPositionChanged:
(mouse)=>{
d.win.startSystemMove()
}
onDoubleClicked:
(mouse)=>{
if(d.resizable && Qt.LeftButton){
btn_maximize.clicked()
}
}
acceptedButtons: Qt.LeftButton|Qt.RightButton
onClicked:
(mouse)=>{
if (mouse.button === Qt.RightButton){
control.systemMenuListener()
}
}
}
Row{
anchors{
Expand All @@ -105,6 +129,49 @@ Rectangle{
anchors.verticalCenter: parent.verticalCenter
}
}

Component{
id:com_mac_buttons
RowLayout{
FluImageButton{
Layout.preferredHeight: 12
Layout.preferredWidth: 12
normalImage: "../Image/btn_close_normal.png"
hoveredImage: "../Image/btn_close_hovered.png"
pushedImage: "../Image/btn_close_pushed.png"
visible: showClose
onClicked: closeClickListener()
}
FluImageButton{
Layout.preferredHeight: 12
Layout.preferredWidth: 12
normalImage: "../Image/btn_min_normal.png"
hoveredImage: "../Image/btn_min_hovered.png"
pushedImage: "../Image/btn_min_pushed.png"
onClicked: minClickListener()
visible: showMinimize
}
FluImageButton{
Layout.preferredHeight: 12
Layout.preferredWidth: 12
normalImage: "../Image/btn_max_normal.png"
hoveredImage: "../Image/btn_max_hovered.png"
pushedImage: "../Image/btn_max_pushed.png"
onClicked: maxClickListener()
visible: d.resizable && showMaximize
}
}
}

FluLoader{
anchors{
verticalCenter: parent.verticalCenter
left: parent.left
leftMargin: 10
}
sourceComponent: isMac ? com_mac_buttons : undefined
}

RowLayout{
anchors.right: parent.right
height: control.height
Expand Down Expand Up @@ -166,6 +233,9 @@ Rectangle{
if(pressed){
return maximizePressColor
}
if(FluTools.isWindows11OrGreater()){
return d.hoverMaxBtn ? maximizeHoverColor : maximizeNormalColor
}
return hovered ? maximizeHoverColor : maximizeNormalColor
}
Layout.alignment: Qt.AlignVCenter
Expand Down Expand Up @@ -211,4 +281,17 @@ Rectangle{
function darkButton(){
return btn_dark
}
function maximizeButtonHover(){
var hover = false;
var pos = btn_maximize.mapToGlobal(0,0)
if(btn_maximize.visible){
var rect = Qt.rect(pos.x,pos.y,btn_maximize.width,btn_maximize.height)
pos = FluTools.cursorPos()
if(pos.x>rect.x && pos.x<(rect.x+rect.width) && pos.y>rect.y && pos.y<(rect.y+rect.height)){
hover = true;
}
}
d.hoverMaxBtn = hover
return hover;
}
}
77 changes: 36 additions & 41 deletions FluentUI/qml/FluentUI/Controls/FluChart.qml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,27 @@ import "./../JS/Chart.js" as Chart

Canvas {
id: control
property var window: Window.window
property var jsChart: undefined
property string chartType
property var chartData
property var chartOptions
property double chartAnimationProgress: 0.1
property int animationEasingType: Easing.InOutExpo
property double animationDuration: 0
property var memorizedContext
property var memorizedData
property var memorizedOptions
property double animationDuration: 300
property alias animationRunning: chartAnimator.running
signal animationFinished()
function animateToNewData()
{
chartAnimationProgress = 0.1;
jsChart.update();
d.jsChart.update();
chartAnimator.restart();
}
QtObject{
id:d
property var jsChart: undefined
property var memorizedContext
property var memorizedData
property var memorizedOptions
}
MouseArea {
id: event
anchors.fill: control
Expand All @@ -47,31 +49,33 @@ Canvas {
mouseEvent.left = 0;
mouseEvent.top = 0;
mouseEvent.target = control;

if(handler) {
handler(mouseEvent);
}

control.requestPaint();
}
onClicked:(mouse)=> {
submitEvent(mouse, "click");
}
onPositionChanged:(mouse)=> {
submitEvent(mouse, "mousemove");
}
onClicked:
(mouse)=> {
submitEvent(mouse, "click");
}
onPositionChanged:
(mouse)=> {
submitEvent(mouse, "mousemove");
}
onExited: {
submitEvent(undefined, "mouseout");
}
onEntered: {
submitEvent(undefined, "mouseenter");
}
onPressed:(mouse)=> {
submitEvent(mouse, "mousedown");
}
onReleased:(mouse)=> {
submitEvent(mouse, "mouseup");
}
onPressed:
(mouse)=> {
submitEvent(mouse, "mousedown");
}
onReleased:
(mouse)=> {
submitEvent(mouse, "mouseup");
}
}
PropertyAnimation {
id: chartAnimator
Expand All @@ -89,34 +93,25 @@ Canvas {
control.requestPaint();
}
onPaint: {
if(control.getContext('2d') !== null && memorizedContext !== control.getContext('2d') || memorizedData !== control.chartData || memorizedOptions !== control.chartOptions) {
if(control.getContext('2d') !== null && d.memorizedContext !== control.getContext('2d') || d.memorizedData !== control.chartData || d.memorizedOptions !== control.chartOptions) {
var ctx = control.getContext('2d');

jsChart = Chart.build(ctx, {
type: control.chartType,
data: control.chartData,
options: control.chartOptions
});

memorizedData = control.chartData ;
memorizedContext = control.getContext('2d');
memorizedOptions = control.chartOptions;

control.jsChart.bindEvents(function(newHandler) {event.handler = newHandler;});

d.jsChart = Chart.build(ctx, {type: control.chartType,data: control.chartData,options: control.chartOptions});
d.memorizedData = control.chartData ;
d.memorizedContext = control.getContext('2d');
d.memorizedOptions = control.chartOptions;
d.jsChart.bindEvents(function(newHandler) {event.handler = newHandler;});
chartAnimator.start();
}

jsChart.draw(chartAnimationProgress);
d.jsChart.draw(chartAnimationProgress);
}
onWidthChanged: {
if(jsChart) {
jsChart.resize();
if(d.jsChart) {
d.jsChart.resize();
}
}
onHeightChanged: {
if(jsChart) {
jsChart.resize();
if(d.jsChart) {
d.jsChart.resize();
}
}
}
2 changes: 1 addition & 1 deletion FluentUI/qml/FluentUI/Controls/FluContentDialog.qml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ FluPopup {
clip: true
boundsBehavior:Flickable.StopAtBounds
width: parent.width
height: Math.min(text_message.height,300)
height: message === "" ? 0 : Math.min(text_message.height,300)
ScrollBar.vertical: FluScrollBar {}
FluText{
id:text_message
Expand Down
18 changes: 18 additions & 0 deletions FluentUI/qml/FluentUI/Controls/FluImageButton.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import QtQuick
import QtQuick.Controls
import FluentUI

Button{
id:control
property string normalImage: ""
property string hoveredImage: ""
property string pushedImage: ""
background: Item{
implicitHeight: 12
implicitWidth: 12
BorderImage {
anchors.fill: parent
source: control.hovered ? (control.pressed ? control.pushedImage : control.hoveredImage ) : control.normalImage
}
}
}
1 change: 1 addition & 0 deletions FluentUI/qml/FluentUI/Controls/FluMultilineTextBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ TextArea{
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.RightButton
visible: !readOnly
onClicked: control.echoMode !== TextInput.Password && menu.popup()
}
FluTextBoxMenu{
Expand Down
6 changes: 1 addition & 5 deletions FluentUI/qml/FluentUI/Controls/FluPaneItem.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,17 @@ QtObject {
property var _ext
property var _parent
property string title
property int order : 0
property var url
property bool disabled: false
property int icon
property bool iconVisible: true
property Component infoBadge
property bool recentlyAdded: false
property bool recentlyUpdated: false
property string desc
property var image
property int count: 0
property var onTapListener
property Component iconDelegate
property Component menuDelegate
property Component editDelegate
property var extra
property bool showEdit
signal tap
}
5 changes: 0 additions & 5 deletions FluentUI/qml/FluentUI/Controls/FluTableModelColumn.qml

This file was deleted.

24 changes: 11 additions & 13 deletions FluentUI/qml/FluentUI/Controls/FluTableView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,17 @@ Rectangle {
color: FluTheme.dark ? Qt.rgba(39/255,39/255,39/255,1) : Qt.rgba(251/255,251/255,253/255,1)
onColumnSourceChanged: {
if(columnSource.length!==0){
var com_column = Qt.createComponent("FluTableModelColumn.qml")
if (com_column.status === Component.Ready) {
var columns= []
var header_rows = {}
columnSource.forEach(function(item){
var column = com_column.createObject(table_model,{display:item.dataIndex});
columns.push(column)
header_rows[item.dataIndex] = item.title
})
table_model.columns = columns
header_model.columns = columns
d.header_rows = [header_rows]
}
var columns= []
var header_rows = {}
columnSource.forEach(function(item){
var column = Qt.createQmlObject('import Qt.labs.qmlmodels;TableModelColumn{}',table_model);
column.display = item.dataIndex
columns.push(column)
header_rows[item.dataIndex] = item.title
})
table_model.columns = columns
header_model.columns = columns
d.header_rows = [header_rows]
}
}
QtObject{
Expand Down
1 change: 1 addition & 0 deletions FluentUI/qml/FluentUI/Controls/FluTextBox.qml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ TextField{
anchors.fill: parent
cursorShape: Qt.IBeamCursor
acceptedButtons: Qt.RightButton
visible: !readOnly
onClicked: control.echoMode !== TextInput.Password && menu.popup()
}
RowLayout{
Expand Down
Loading

0 comments on commit f82c337

Please sign in to comment.