RibbonProgressBar: Added more position choice.

This commit is contained in:
Mentalflow 2024-06-28 14:45:18 +08:00
parent c9600ecb3c
commit 406bf535bf
Signed by: Mentalflow
GPG Key ID: 5AE68D4401A2EE71
3 changed files with 7 additions and 6 deletions

View File

@ -6,10 +6,11 @@ import RibbonUI 1.0
Item{ Item{
id: control id: control
implicitHeight: (textLabelPosition === RibbonProgressBar.LabelPosition.Top || textLabelPosition === RibbonProgressBar.LabelPosition.Bottom && showText ? implicitHeight: (textLabelPosition === RibbonProgressBar.LabelPosition.Top || textLabelPosition === RibbonProgressBar.LabelPosition.Bottom && showText ?
(text_label.contentHeight + textLabelMargin + bar.implicitHeight) : showText ? Math.max(bar.implicitHeight, text_label.contentHeight) : bar.implicitHeight) (text_label.contentHeight + textLabelMargin + bar.implicitHeight) : showText && textLabelPosition !== RibbonProgressBar.LabelPosition.None ? Math.max(bar.implicitHeight, text_label.contentHeight) : bar.implicitHeight)
implicitWidth: bar.implicitWidth + (textLabelPosition === RibbonProgressBar.LabelPosition.Left || textLabelPosition === RibbonProgressBar.LabelPosition.Right && showText ? implicitWidth: bar.implicitWidth + (textLabelPosition === RibbonProgressBar.LabelPosition.Left || textLabelPosition === RibbonProgressBar.LabelPosition.Right && showText ?
(text_label.contentWidth + textLabelMargin) : 0) (text_label.contentWidth + textLabelMargin) : 0)
enum LabelPosition { enum LabelPosition {
None,
Top, Top,
Left, Left,
Right, Right,
@ -30,6 +31,7 @@ Item{
property alias position: bar.position property alias position: bar.position
property alias indeterminate: bar.indeterminate property alias indeterminate: bar.indeterminate
property alias bar: bar property alias bar: bar
property alias textLabel: text_label
ProgressBar { ProgressBar {
id: bar id: bar
@ -56,7 +58,6 @@ Item{
implicitHeight: barHeight implicitHeight: barHeight
implicitWidth: barWidth implicitWidth: barWidth
height: implicitHeight height: implicitHeight
anchors.verticalCenter: bar.verticalCenter
clip: true clip: true
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {
@ -96,7 +97,6 @@ Item{
implicitHeight: barHeight implicitHeight: barHeight
height: barHeight height: barHeight
radius: height / 2 radius: height / 2
anchors.verticalCenter: bar.verticalCenter
color: bgColor color: bgColor
} }
} }

View File

@ -286,6 +286,7 @@ Item{
} }
Component.onCompleted: Window.window.tabBar = root Component.onCompleted: Window.window.tabBar = root
//onModern_styleChanged: refresh() //onModern_styleChanged: refresh()
function addPage(content, is_highlight) function addPage(content, is_highlight)

View File

@ -6,10 +6,11 @@ import RibbonUI
Item{ Item{
id: control id: control
implicitHeight: (textLabelPosition === RibbonProgressBar.LabelPosition.Top || textLabelPosition === RibbonProgressBar.LabelPosition.Bottom && showText ? implicitHeight: (textLabelPosition === RibbonProgressBar.LabelPosition.Top || textLabelPosition === RibbonProgressBar.LabelPosition.Bottom && showText ?
(text_label.contentHeight + textLabelMargin + bar.implicitHeight) : showText ? Math.max(bar.implicitHeight, text_label.contentHeight) : bar.implicitHeight) (text_label.contentHeight + textLabelMargin + bar.implicitHeight) : showText && textLabelPosition !== RibbonProgressBar.LabelPosition.None ? Math.max(bar.implicitHeight, text_label.contentHeight) : bar.implicitHeight)
implicitWidth: bar.implicitWidth + (textLabelPosition === RibbonProgressBar.LabelPosition.Left || textLabelPosition === RibbonProgressBar.LabelPosition.Right && showText ? implicitWidth: bar.implicitWidth + (textLabelPosition === RibbonProgressBar.LabelPosition.Left || textLabelPosition === RibbonProgressBar.LabelPosition.Right && showText ?
(text_label.contentWidth + textLabelMargin) : 0) (text_label.contentWidth + textLabelMargin) : 0)
enum LabelPosition { enum LabelPosition {
None,
Top, Top,
Left, Left,
Right, Right,
@ -30,6 +31,7 @@ Item{
property alias position: bar.position property alias position: bar.position
property alias indeterminate: bar.indeterminate property alias indeterminate: bar.indeterminate
property alias bar: bar property alias bar: bar
property alias textLabel: text_label
ProgressBar { ProgressBar {
id: bar id: bar
@ -56,7 +58,6 @@ Item{
implicitHeight: barHeight implicitHeight: barHeight
implicitWidth: barWidth implicitWidth: barWidth
height: implicitHeight height: implicitHeight
anchors.verticalCenter: bar.verticalCenter
clip: true clip: true
layer.enabled: true layer.enabled: true
layer.effect: OpacityMask { layer.effect: OpacityMask {
@ -96,7 +97,6 @@ Item{
implicitHeight: barHeight implicitHeight: barHeight
height: barHeight height: barHeight
radius: height / 2 radius: height / 2
anchors.verticalCenter: bar.verticalCenter
color: bgColor color: bgColor
} }
} }