Skip to content

Commit

Permalink
fix #264
Browse files Browse the repository at this point in the history
  • Loading branch information
朱子楚\zhuzi committed Aug 27, 2023
1 parent e30db25 commit 56a62f0
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 31 deletions.
3 changes: 2 additions & 1 deletion example/qml-Qt6/component/CodeExpander.qml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ FluExpander{
"FluTour",
"FluQRCode",
"FluTimeline",
"FluChart"
"FluChart",
"FluRangeSlider"
];
code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;");
Expand Down
37 changes: 23 additions & 14 deletions example/qml-Qt6/page/T_Slider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,18 @@ FluScrollablePage{

FluArea{
Layout.fillWidth: true
height: 100
paddings: 10
Layout.preferredHeight: 200
Layout.topMargin: 20
FluSlider{
anchors.verticalCenter: parent.verticalCenter
paddings: 10

Row{
spacing: 30
FluSlider{
}
FluSlider{
orientation: Qt.Vertical
anchors.verticalCenter: parent.verticalCenter
}
}
}
CodeExpander{
Expand All @@ -26,25 +33,27 @@ FluScrollablePage{
}'
}


FluArea{
Layout.fillWidth: true
height: 200
paddings: 10
Layout.preferredHeight: 200
Layout.topMargin: 20
FluSlider{
orientation: Qt.Vertical
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
paddings: 10
Row{
spacing: 30
FluRangeSlider{
}
FluRangeSlider{
orientation: Qt.Vertical
anchors.verticalCenter: parent.verticalCenter
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluSlider{
code:'FluRangeSlider{
orientation: Qt.Vertical
value:50
}'
}


}
3 changes: 2 additions & 1 deletion example/qml/component/CodeExpander.qml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ FluExpander{
"FluTour",
"FluQRCode",
"FluTimeline",
"FluChart"
"FluChart",
"FluRangeSlider"
];
code = code.replace(/\n/g, "<br>");
code = code.replace(/ /g, "&nbsp;");
Expand Down
38 changes: 24 additions & 14 deletions example/qml/page/T_Slider.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,18 @@ FluScrollablePage{

FluArea{
Layout.fillWidth: true
height: 100
paddings: 10
Layout.preferredHeight: 200
Layout.topMargin: 20
FluSlider{
anchors.verticalCenter: parent.verticalCenter
paddings: 10

Row{
spacing: 30
FluSlider{
}
FluSlider{
orientation: Qt.Vertical
anchors.verticalCenter: parent.verticalCenter
}
}
}
CodeExpander{
Expand All @@ -27,25 +34,28 @@ FluScrollablePage{
}'
}


FluArea{
Layout.fillWidth: true
height: 200
paddings: 10
Layout.preferredHeight: 200
Layout.topMargin: 20
FluSlider{
orientation: Qt.Vertical
anchors.left: parent.left
anchors.verticalCenter: parent.verticalCenter
paddings: 10
Row{
spacing: 30
FluRangeSlider{
}
FluRangeSlider{
orientation: Qt.Vertical
anchors.verticalCenter: parent.verticalCenter
}
}
}
CodeExpander{
Layout.fillWidth: true
Layout.topMargin: -1
code:'FluSlider{
code:'FluRangeSlider{
orientation: Qt.Vertical
value:50
}'
}


}

2 changes: 1 addition & 1 deletion example/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(int argc, char *argv[])
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow);
#ifdef Q_OS_WIN // 此设置仅在Windows下生效
FramelessConfig::instance()->set(Global::Option::ForceHideWindowFrameBorder);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,true);
FramelessConfig::instance()->set(Global::Option::EnableBlurBehindWindow,false);
#endif
#ifdef Q_OS_MACOS
FramelessConfig::instance()->set(Global::Option::ForceNonNativeBackgroundBlur,false);
Expand Down
120 changes: 120 additions & 0 deletions src/Qt5/imports/FluentUI/Controls/FluRangeSlider.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import QtQuick 2.15
import QtQuick.Controls 2.15
import QtQuick.Templates 2.15 as T
import FluentUI 1.0

T.RangeSlider {
id: control
property bool tooltipEnabled: true
property bool isTipInt: true
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
first.implicitHandleWidth + leftPadding + rightPadding,
second.implicitHandleWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
first.implicitHandleHeight + topPadding + bottomPadding,
second.implicitHandleHeight + topPadding + bottomPadding)
padding: 6
first.value: 0
second.value: 100
stepSize: 1
from: 0
to:100
snapMode: RangeSlider.SnapAlways
first.handle: Rectangle {
x: control.leftPadding + (control.horizontal ? control.first.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)
y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.first.visualPosition * (control.availableHeight - height))
implicitWidth: 24
implicitHeight: 24
radius: width / 2
color:FluTheme.dark ? Qt.rgba(69/255,69/255,69/255,1) :Qt.rgba(1,1,1,1)
FluShadow{
radius: 12
}
Rectangle{
width: 24
height: 24
radius: 12
color:FluTheme.dark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
anchors.centerIn: parent
scale: {
if(control.first.pressed){
return 4/10
}
return control.first.hovered ? 6/10 : 5/10
}
Behavior on scale {
enabled: FluTheme.enableAnimation
NumberAnimation{
duration: 167
easing.type: Easing.OutCubic
}
}
}
}

second.handle: Rectangle {
x: control.leftPadding + (control.horizontal ? control.second.visualPosition * (control.availableWidth - width) : (control.availableWidth - width) / 2)
y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : control.second.visualPosition * (control.availableHeight - height))
implicitWidth: 24
implicitHeight: 24
radius: width / 2
color:FluTheme.dark ? Qt.rgba(69/255,69/255,69/255,1) :Qt.rgba(1,1,1,1)
FluShadow{
radius: 12
}
Rectangle{
width: 24
height: 24
radius: 12
color:FluTheme.dark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
anchors.centerIn: parent
scale: {
if(control.second.pressed){
return 4/10
}
return control.second.hovered ? 6/10 : 5/10
}
Behavior on scale {
enabled: FluTheme.enableAnimation
NumberAnimation{
duration: 167
easing.type: Easing.OutCubic
}
}
}
}

background: Item {
x: control.leftPadding + (control.horizontal ? 0 : (control.availableWidth - width) / 2)
y: control.topPadding + (control.horizontal ? (control.availableHeight - height) / 2 : 0)
implicitWidth: control.horizontal ? 180 : 6
implicitHeight: control.horizontal ? 6 : 180
width: control.horizontal ? control.availableWidth : implicitWidth
height: control.horizontal ? implicitHeight : control.availableHeight
scale: control.horizontal && control.mirrored ? -1 : 1
Rectangle{
anchors.fill: parent
anchors.margins: 1
radius: 2
color:FluTheme.dark ? Qt.rgba(162/255,162/255,162/255,1) : Qt.rgba(138/255,138/255,138/255,1)
}
Rectangle {
x: control.horizontal ? control.first.position * parent.width + 3 : 0
y: control.horizontal ? 0 : control.second.visualPosition * parent.height + 3
width: control.horizontal ? control.second.position * parent.width - control.first.position * parent.width - 6 : 6
height: control.horizontal ? 6 : control.second.position * parent.height - control.first.position * parent.height - 6
color:FluTheme.dark ? FluTheme.primaryColor.lighter :FluTheme.primaryColor.dark
}
}
FluTooltip{
parent: control.first.handle
visible: control.tooltipEnabled && (control.first.pressed || control.first.hovered)
text:String(isTipInt?Math.round(control.first.value):control.first.value)
}
FluTooltip{
parent: control.second.handle
visible: control.tooltipEnabled && (control.second.pressed || control.second.hovered)
text:String(isTipInt?Math.round(control.second.value):control.second.value)
}
}

1 change: 1 addition & 0 deletions src/Qt5/imports/FluentUI/Controls/FluStatusView.qml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.15
import QtQuick.Layouts 1.15
import FluentUI 1.0
Expand Down
1 change: 1 addition & 0 deletions src/Qt5/imports/FluentUI/qmldir
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,5 @@ FluTooltip 1.0 Controls/FluTooltip.qml
FluTour 1.0 Controls/FluTour.qml
FluTreeView 1.0 Controls/FluTreeView.qml
FluWindow 1.0 Controls/FluWindow.qml
FluRangeSlider 1.0 Controls/FluRangeSlider.qml
plugin fluentuiplugin
Loading

0 comments on commit 56a62f0

Please sign in to comment.