Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
1b7a6170 by Fatih Uzunoglu at 2025-08-15T14:24:21+00:00
qml: various fixes in `ButtonExt.qml`
This is inspired from a6f0f676.
The important thing is that the control must be
flexible, and adjust itself properly for any
reasonable size given to it.
This means making sure that when there is not
enough size, text elision is done, and when
there is more than enough size, proper alignment
is done.
I was hesitant about introducing `showText`, as
I initially thought we could automatically show
the text with `text.length > 0` and set the text
empty when we don't want text displayed instead,
but that meant the tool tip would be empty too
(which we don't want).
I also deprecated `selected` in favor of `checked`,
and made the icon not displayed when busy indicator
is shown.
- - - - -
56013494 by Fatih Uzunoglu at 2025-08-15T14:24:21+00:00
qml: only show icons in buttons without enough width in `ArtistTopBanner.qml`
"Enough width" in this case does not refer to the implicit width, but
rather
a reasonable width. I would like to use the implicit width here, but that is
not worth the maintenance at the moment (considering the player control bar).
- - - - -
2 changed files:
- modules/gui/qt/medialibrary/qml/ArtistTopBanner.qml
- modules/gui/qt/widgets/qml/ButtonExt.qml
Changes:
=====================================
modules/gui/qt/medialibrary/qml/ArtistTopBanner.qml
=====================================
@@ -205,6 +205,8 @@ FocusScope {
//we probably want to keep this button like the other
action buttons
colorContext.palette: VLCStyle.palette
+ showText: actionButtons.width > VLCStyle.colWidth(2)
+
onClicked: MediaLib.addAndPlay( artist.id )
}
@@ -213,6 +215,8 @@ FocusScope {
iconTxt: VLCIcons.enqueue
text: qsTr("Enqueue all")
onClicked: MediaLib.addToPlaylist( artist.id )
+
+ showText: actionButtons.width > VLCStyle.colWidth(2)
}
}
}
=====================================
modules/gui/qt/widgets/qml/ButtonExt.qml
=====================================
@@ -1,5 +1,5 @@
/*****************************************************************************
- * Copyright (C) 2019 VLC authors and VideoLAN
+ * Copyright (C) 2025 VLC authors and VideoLAN
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -31,7 +31,10 @@ T.Button {
// Properties
- property bool selected: false
+ property bool showText: (text.length > 0)
+
+ property bool selected: false // WARNING: This property is deprecated. Use
`checked` instead.
+ checked: selected
property bool busy: false
@@ -46,7 +49,7 @@ T.Button {
property bool extBackgroundAnimation: false
// Aliases
- property alias iconRotation: icon.rotation
+ property real iconRotation
// Settings
@@ -71,6 +74,14 @@ T.Button {
Accessible.onPressAction: control.clicked()
+ // Tooltip
+
+ T.ToolTip.visible: (T.ToolTip.text && (!showText || label.implicitWidth >
label.width) && (hovered || visualFocus))
+
+ T.ToolTip.delay: VLCStyle.delayToolTipAppear
+
+ T.ToolTip.text: text
+
// Childs
@@ -78,100 +89,103 @@ T.Button {
id: theme
colorSet: ColorContext.ButtonStandard
- focused: control.activeFocus
+ focused: control.visualFocus
hovered: control.hovered
enabled: control.enabled
pressed: control.down
}
background: Widgets.AnimatedBackground {
- id: background
-
- height: control.height
- width: control.width
-
enabled: theme.initialized && !control.extBackgroundAnimation
color: theme.bg.primary
- border.color: control.visualFocus ? control.colorFocus : theme.border
- }
+ border.color: control.visualFocus ? control.colorFocus
+ : (theme.border.a > 0.0 ?
theme.border : color)
- contentItem: Item {
- implicitWidth: tabRow.implicitWidth
- implicitHeight: tabRow.implicitHeight
+ Rectangle {
+ anchors {
+ bottom: parent.bottom
+ bottomMargin: VLCStyle.margin_xxxsmall
+ horizontalCenter: parent.horizontalCenter
+ }
- RowLayout {
- id: tabRow
+ implicitWidth: (parent.width - VLCStyle.margin_xsmall)
+ implicitHeight: VLCStyle.heightBar_xxxsmall
- anchors.fill: parent
+ width: control.contentItem?.implicitWidth ?? implicitWidth
- spacing: control.spacing
+ visible: (width > 0 && control.checked)
+ }
+ }
- Item {
- Layout.fillHeight: true
+ contentItem: RowLayout {
+ spacing: 0
- implicitWidth: VLCStyle.fontHeight_normal
- implicitHeight: VLCStyle.fontHeight_normal
+ Item {
+ Layout.fillWidth: true
+ }
- visible: (control.iconTxt !== "") || control.busy
+ Widgets.IconLabel {
+ id: iconLabel
- Widgets.IconLabel {
- id: icon
+ visible: text.length > 0
- anchors.fill: parent
+ rotation: control.iconRotation
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
+ text: control.iconTxt
- visible: (!control.busy)
+ horizontalAlignment: Text.AlignHCenter
+ verticalAlignment: Text.AlignVCenter
- text: control.iconTxt
+ color: Qt.alpha(control.color, control.busy ? 0.0 : 1.0)
- color: control.color
+ font.pixelSize: control.iconSize
- font.pixelSize: control.iconSize
- }
+ Layout.fillWidth: !label.visible
+ Layout.fillHeight: true
- // FIXME: use Control.Templates
- BusyIndicator {
- anchors.fill: parent
+ // FIXME: use `BusyIndicatorExt` when it is ready (!7180)
+ BusyIndicator {
+ anchors.fill: parent
- padding: 0
+ padding: 0
- running: control.busy
+ running: control.busy
- palette.text: theme.fg.primary
- }
+ palette.text: control.color
+ palette.dark: control.color
}
+ }
- Widgets.ListLabel {
- Layout.fillWidth: true
- Layout.fillHeight: true
+ T.Label {
+ id: label
- horizontalAlignment: Text.AlignHCenter
- verticalAlignment: Text.AlignVCenter
+ visible: control.showText
- text: control.text
+ text: control.text
- //button text is already exposed
- Accessible.ignored: true
+ verticalAlignment: Text.AlignVCenter
- color: theme.fg.primary
- }
- }
+ color: control.color
- Rectangle {
- anchors.left: tabRow.left
- anchors.right: tabRow.right
- anchors.bottom: tabRow.bottom
+ elide: Text.ElideRight
- height: 2
+ font.pixelSize: VLCStyle.fontSize_normal
+ font.weight: Font.DemiBold
- visible: control.selected
+ textFormat: Text.PlainText
- color: "transparent"
+ //button text is already exposed
+ Accessible.ignored: true
+
+ Layout.fillWidth: true
+ Layout.fillHeight: true
+ Layout.maximumWidth: implicitWidth + 1
+ Layout.leftMargin: iconLabel.visible ? VLCStyle.margin_xsmall : 0
+ }
- border.color: theme.accent
+ Item {
+ Layout.fillWidth: true
}
}
}
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/0ad660d9f8a2ae388af9b6cbf82bddb7acf5c53b...560134941dfcd56b060d96f082eab5d6e5f4c25d
--
View it on GitLab:
https://code.videolan.org/videolan/vlc/-/compare/0ad660d9f8a2ae388af9b6cbf82bddb7acf5c53b...560134941dfcd56b060d96f082eab5d6e5f4c25d
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
_______________________________________________
vlc-commits mailing list
vlc-commits@videolan.org
https://mailman.videolan.org/listinfo/vlc-commits