[vlc-commits] [Git][videolan/vlc][master] qml: fix broken customized round button
Steve Lhomme (@robUx4)
gitlab at videolan.org
Sun Apr 27 13:48:37 UTC 2025
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
96853486 by Fatih Uzunoglu at 2025-04-27T11:56:29+00:00
qml: fix broken customized round button
This customization has been broken for a while, I
have not previously tried to fix it because there
were plans of getting rid of it (at least, the
case with horizontal list view). However, not only
the buttons still remain there, but it is now also
used in more places (be87f3ea).
Customization is not worth it if the control is
never or barely used as in these cases we can simply
rely on Qt Quick Basic style directly, and adjust
the palette and sizes and be done with it.
Note that, we can expect Qt Quick Controls Basic
style to be available as long as Qt Quick Controls
itself is available (which we require). This means
that we should be able to freely import the
`QtQuick.Controls.Basic` QML module.
- - - - -
5 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/meson.build
- modules/gui/qt/player/qml/Bookmarks.qml
- modules/gui/qt/widgets/qml/ListViewExt.qml
- modules/gui/qt/widgets/qml/RoundButton.qml → modules/gui/qt/widgets/qml/RoundButtonExt.qml
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -1273,7 +1273,7 @@ libqml_module_widgets_a_QML = \
widgets/qml/NavigableCol.qml \
widgets/qml/NavigableRow.qml \
widgets/qml/PlayCover.qml \
- widgets/qml/RoundButton.qml \
+ widgets/qml/RoundButtonExt.qml \
widgets/qml/ScaledImage.qml \
widgets/qml/ScanProgressBar.qml \
widgets/qml/TextAutoScroller.qml \
=====================================
modules/gui/qt/meson.build
=====================================
@@ -871,7 +871,7 @@ qml_modules += {
'widgets/qml/NavigableCol.qml',
'widgets/qml/NavigableRow.qml',
'widgets/qml/PlayCover.qml',
- 'widgets/qml/RoundButton.qml',
+ 'widgets/qml/RoundButtonExt.qml',
'widgets/qml/ScaledImage.qml',
'widgets/qml/ScanProgressBar.qml',
'widgets/qml/TextAutoScroller.qml',
=====================================
modules/gui/qt/player/qml/Bookmarks.qml
=====================================
@@ -96,12 +96,11 @@ Item {
ml: MediaLib
}
- Widgets.RoundButton {
+ Widgets.RoundButtonExt {
id: bookmarkButton
- size: control.barHeight
-
- backgroundColor: bookmarkButton.colorContext.fg.primary
+ height: control.barHeight
+ width: height
x: control.width * model.position - width/2
focusPolicy: Qt.NoFocus
=====================================
modules/gui/qt/widgets/qml/ListViewExt.qml
=====================================
@@ -693,7 +693,7 @@ ListView {
// FIXME: We probably need to upgrade these RoundButton(s) eventually. And we probably need
// to have some kind of animation when switching pages.
- RoundButton {
+ RoundButtonExt {
id: buttonLeft
anchors.left: parent.left
@@ -710,7 +710,7 @@ ListView {
activeFocusOnTab: false
}
- RoundButton {
+ RoundButtonExt {
id: buttonRight
anchors.right: parent.right
=====================================
modules/gui/qt/widgets/qml/RoundButton.qml → modules/gui/qt/widgets/qml/RoundButtonExt.qml
=====================================
@@ -1,5 +1,6 @@
/*****************************************************************************
- * Copyright (C) 2019 VLC authors and VideoLAN
+ * Copyright (C) 2025 VLC authors and VideoLAN
+ * Copyright (C) 2017 The Qt Company Ltd.
*
* 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
@@ -16,27 +17,38 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
import QtQuick
-import QtQuick.Controls
+import QtQuick.Templates as T
import VLC.Widgets as Widgets
import VLC.Style
-Button{
+T.RoundButton {
id: control
+
+ implicitWidth: text.length !== 1 ? Math.max(implicitBackgroundWidth + leftInset + rightInset,
+ implicitContentWidth + leftPadding + rightPadding)
+ : implicitHeight // special case for single letter/icon to make it perfectly round. This should be safe due to `Text.HorizontalFit`
+ implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
+ implicitContentHeight + topPadding + bottomPadding)
+
hoverEnabled: true
- property real size: VLCStyle.icon_normal
- property color backgroundColor: theme.bg.primary
+
+ padding: VLCStyle.dp(6, VLCStyle.scale)
+ spacing: VLCStyle.dp(6, VLCStyle.scale)
+
+ font.pixelSize: VLCStyle.icon_small
//Accessible
Accessible.onPressAction: control.clicked()
readonly property ColorContext colorContext: ColorContext {
id: theme
- colorSet: ColorContext.View
+ colorSet: ColorContext.ToolButton // ###
enabled: control.enabled
focused: control.visualFocus
hovered: control.hovered
+ pressed: control.down
}
contentItem: Text {
@@ -46,14 +58,15 @@ Button{
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
+ fontSizeMode: (text.length !== 1) ? Text.FixedSize : Text.HorizontalFit
Accessible.ignored: true
}
- background: Rectangle {
- width: control.size
- height: control.size
- opacity: control.hovered ? 1 : 0.5
- color: control.backgroundColor
- radius: control.size/2
+ background: Widgets.AnimatedBackground {
+ radius: control.radius
+ enabled: control.enabled
+ visible: !control.flat || control.down || control.checked || control.highlighted
+ color: theme.bg.secondary // ###
+ border.color: theme.border
}
}
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/968534864a2ce22fa44442d0dfb69fd2bd4298eb
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/968534864a2ce22fa44442d0dfb69fd2bd4298eb
You're receiving this email because of your account on code.videolan.org.
VideoLAN code repository instance
More information about the vlc-commits
mailing list