[vlc-commits] [Git][videolan/vlc][master] 5 commits: qml: do not expect `handle` is available in `SliderExt`
Felix Paul Kühne (@fkuehne)
gitlab at videolan.org
Mon Nov 16 14:03:22 UTC 2026
Felix Paul Kühne pushed to branch master at VideoLAN / VLC
Commits:
6405d398 by Fatih Uzunoglu at 2026-11-16T14:22:30+01:00
qml: do not expect `handle` is available in `SliderExt`
- - - - -
0b7dd583 by Fatih Uzunoglu at 2026-11-16T14:22:30+01:00
qml: do not early return in tool tip text assignment in `SliderExt`
Consumers may use text when the tool tip is not visible.
- - - - -
5bd73d6b by Fatih Uzunoglu at 2026-11-16T14:22:30+01:00
Revert "qt: mark qt-slider-colours as obsolete"
This reverts commit b54b8d254295b12c2db717e3a70374df1e024d9d.
The patch also adds the "legacy" mark to the setting,
so that the user is not confused that it is not respected
in the new design version.
- - - - -
7a7af999 by Fatih Uzunoglu at 2026-11-16T14:22:30+01:00
qml: enable partial customization in `VolumeWidget`
- - - - -
289ac2b8 by Fatih Uzunoglu at 2026-11-16T14:22:30+01:00
qt: restore VLC 3.0's volume slider
It is currently a TODO to make use of shader here
instead of relying on image. However, this is also
acceptable since the image is generated depending
on mutedness, and not every time the slider is
adjusted. We instead clip in the scene graph the
gradient image, which is acceptable since we don't
expect multiple volume widgets to be present on
the scene (since clipping breaks batch rendering).
Qt is going to cache the image used, but if player
gets muted/unmuted after a certain amount of time,
the other gradient image may be released from the
cache and it may need to be re-generated. One way
to enforce cache at all times would be using two
`Image`s, but currently it is not done. As noted
above, we should rather use shader for this purpose
rather than optimizing it for old school image
based solution.
- - - - -
16 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/assets.qrc
- modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp
- modules/gui/qt/maininterface/mainctx.cpp
- modules/gui/qt/maininterface/mainctx.hpp
- modules/gui/qt/meson.build
- + modules/gui/qt/pixmaps/misc/volume-slider-inside.svg
- + modules/gui/qt/pixmaps/misc/volume-slider-outside.svg
- modules/gui/qt/player/control_list_model.hpp
- modules/gui/qt/player/qml/PlayerControlbarControls.qml
- modules/gui/qt/player/qml/controlbarcontrols/VolumeWidget.qml
- + modules/gui/qt/player/qml/controlbarcontrols/VolumeWidgetLegacy.qml
- modules/gui/qt/qt.cpp
- modules/gui/qt/util/effects_image_provider.cpp
- modules/gui/qt/util/effects_image_provider.hpp
- modules/gui/qt/widgets/qml/SliderExt.qml
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -942,6 +942,8 @@ libqt_plugin_la_RES = \
pixmaps/misc/wait2.svg \
pixmaps/misc/wait3.svg \
pixmaps/misc/wait4.svg \
+ pixmaps/misc/volume-slider-inside.svg \
+ pixmaps/misc/volume-slider-outside.svg \
pixmaps/placeholder/add_service.svg \
pixmaps/placeholder/noart.png \
pixmaps/placeholder/noart_album.svg \
@@ -1242,6 +1244,7 @@ libqml_module_playercontrols_a_QML = \
player/qml/controlbarcontrols/TeletextColorButton.qml \
player/qml/controlbarcontrols/TeletextWidget.qml \
player/qml/controlbarcontrols/VolumeWidget.qml \
+ player/qml/controlbarcontrols/VolumeWidgetLegacy.qml \
player/qml/controlbarcontrols/Fallback.qml
libqml_module_playercontrols_a_Singleton_QML =
libqml_module_playercontrols_a_SOURCES = $(QML_MODULE_playercontrols_SRC)
=====================================
modules/gui/qt/assets.qrc
=====================================
@@ -69,6 +69,8 @@
<file alias="wait2.svg">pixmaps/misc/wait2.svg</file>
<file alias="wait3.svg">pixmaps/misc/wait3.svg</file>
<file alias="wait4.svg">pixmaps/misc/wait4.svg</file>
+ <file alias="volume-slider-inside.svg">pixmaps/misc/volume-slider-inside.svg</file>
+ <file alias="volume-slider-outside.svg">pixmaps/misc/volume-slider-outside.svg</file>
</qresource>
<qresource prefix="/sd">
<file alias="capture-card.svg">pixmaps/sd/capture-card.svg</file>
=====================================
modules/gui/qt/dialogs/toolbar/controlbar_profile_model.cpp
=====================================
@@ -396,7 +396,7 @@ decltype (ControlbarProfileModel::m_defaults)
},
{},
{
- ControlListModel::VOLUME
+ ControlListModel::VOLUME_LEGACY
}
}
}
@@ -421,7 +421,7 @@ decltype (ControlbarProfileModel::m_defaults)
},
{},
{
- ControlListModel::VOLUME
+ ControlListModel::VOLUME_LEGACY
}
}
}
@@ -448,7 +448,7 @@ decltype (ControlbarProfileModel::m_defaults)
ControlListModel::RANDOM_BUTTON
},
{
- ControlListModel::VOLUME
+ ControlListModel::VOLUME_LEGACY
}
}
}
=====================================
modules/gui/qt/maininterface/mainctx.cpp
=====================================
@@ -1073,6 +1073,16 @@ void MainCtx::setAttachedToolTip(QObject *toolTip)
#endif
}
+QString MainCtx::volumeSliderColors() const
+{
+ const auto sliderColors = var_InheritString(p_intf, "qt-slider-colours");
+
+ if (Q_UNLIKELY(!sliderColors))
+ return {};
+
+ return QString::fromUtf8(vlc::wrap_cptr(sliderColors).get());
+}
+
MainCtx::MainInterfaceMode MainCtx::getEffectiveMainInterfaceMode() const {
//priority applies across modes
if (m_mainInterfaceModes & MainCtx::MAININTERFACE_MODE_MINIMAL)
=====================================
modules/gui/qt/maininterface/mainctx.hpp
=====================================
@@ -139,6 +139,7 @@ class MainCtx : public QObject
Q_PROPERTY(MainInterfaceModes mainInterfaceModes READ getMainInterfaceModes NOTIFY mainInterfaceModesChanged FINAL)
Q_PROPERTY(MainInterfaceMode effectiveMainInterfaceMode READ getEffectiveMainInterfaceMode NOTIFY mainInterfaceModesChanged FINAL)
Q_PROPERTY(MainInterfaceMode initialEffectiveMainInterfaceMode READ getInitialEffectiveMainInterfaceMode CONSTANT FINAL)
+ Q_PROPERTY(QString volumeSliderColors READ volumeSliderColors CONSTANT FINAL)
//Property to get Operating System info
Q_PROPERTY(OsType osName READ getOSName CONSTANT)
@@ -395,6 +396,8 @@ public:
MainInterfaceMode getInitialEffectiveMainInterfaceMode() const { return m_initialEffectiveMainInterfaceMode; }
+ Q_INVOKABLE QString volumeSliderColors() const;
+
Q_INVOKABLE static double dp(const double px, const double scale);
Q_INVOKABLE double dp(const double px) const;
=====================================
modules/gui/qt/meson.build
=====================================
@@ -808,6 +808,7 @@ qml_modules += {
'player/qml/controlbarcontrols/TeletextColorButton.qml',
'player/qml/controlbarcontrols/TeletextWidget.qml',
'player/qml/controlbarcontrols/VolumeWidget.qml',
+ 'player/qml/controlbarcontrols/VolumeWidgetLegacy.qml',
'player/qml/controlbarcontrols/Fallback.qml',
),
}
=====================================
modules/gui/qt/pixmaps/misc/volume-slider-inside.svg
=====================================
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ width="45.508335mm"
+ height="13.758332mm"
+ viewBox="0 0 45.508335 13.758332"
+ version="1.1"
+ id="svg2792"
+ inkscape:version="1.4.4 (dcaf3e7d9e, 2026-05-05)"
+ sodipodi:docname="volume-slider-inside.svg"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <defs
+ id="defs2786" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="5.7850875"
+ inkscape:cx="112.70357"
+ inkscape:cy="18.236544"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0"
+ inkscape:window-width="2048"
+ inkscape:window-height="1208"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:showpageshadow="2"
+ inkscape:pagecheckerboard="0"
+ inkscape:deskcolor="#d1d1d1" />
+ <metadata
+ id="metadata2789">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <rect
+ width="100%"
+ height="100%"
+ fill="#00FFFF"
+ id="rect1" />
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-23.36347,-25.535099)">
+ <path
+ id="path5485"
+ d="m 67.993244,26.473943 c -0.03901,6.24e-4 -0.07644,0.005 -0.112075,0.01403 a 0.93563019,0.93803033 0 0 1 -0.0212,0.0044 L 24.119342,37.735287 a 0.93563019,0.93803033 0 0 1 -0.01403,0.0038 c -0.144665,0.03473 -0.238155,0.1539 -0.238747,0.302876 0,0.183288 0.128227,0.312033 0.311217,0.312033 h 43.814315 c 0.26943,0 0.46776,-0.19885 0.46776,-0.468969 V 26.942302 c 0,-0.269613 -0.197892,-0.467614 -0.466545,-0.468359 z"
+ style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ff00cc;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.53373;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4.2;stroke-opacity:1;marker:none;enable-background:accumulate"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
=====================================
modules/gui/qt/pixmaps/misc/volume-slider-outside.svg
=====================================
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ width="45.508335mm"
+ height="13.758332mm"
+ viewBox="0 0 45.508335 13.758332"
+ version="1.1"
+ id="svg2792"
+ inkscape:version="1.4.4 (dcaf3e7d9e, 2026-05-05)"
+ sodipodi:docname="volume-slider-outside.svg"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:dc="http://purl.org/dc/elements/1.1/">
+ <defs
+ id="defs2786" />
+ <sodipodi:namedview
+ id="base"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="16"
+ inkscape:cx="136.375"
+ inkscape:cy="23.65625"
+ inkscape:document-units="mm"
+ inkscape:current-layer="layer1"
+ showgrid="false"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0"
+ inkscape:window-width="2048"
+ inkscape:window-height="1208"
+ inkscape:window-x="0"
+ inkscape:window-y="0"
+ inkscape:window-maximized="1"
+ inkscape:showpageshadow="2"
+ inkscape:pagecheckerboard="0"
+ inkscape:deskcolor="#d1d1d1" />
+ <metadata
+ id="metadata2789">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title />
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-23.358932,-25.5375)">
+ <path
+ style="color:#000000;display:inline;overflow:visible;visibility:visible;opacity:1;fill:#ff00ff;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:1.50022;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:4.2;stroke-opacity:1;marker:none;enable-background:accumulate"
+ d="m 67.492534,25.697528 c -0.113935,6.1e-4 -0.227327,0.01508 -0.337648,0.04354 v -0.0012 L 24.296094,36.727657 c -0.548999,0.131472 -0.936435,0.621964 -0.937162,1.186471 0,0.674707 0.546979,1.221666 1.221688,1.221666 h 42.911914 c 0.759069,0 1.374398,-0.615328 1.374398,-1.374372 V 27.071873 c 0,-0.759045 -0.615329,-1.374373 -1.374398,-1.374373 z m 0,0.916844 c 0.263124,6.11e-4 0.456939,0.194153 0.456939,0.457529 v 10.689571 c 0,0.263871 -0.194243,0.458125 -0.458128,0.458125 H 24.58062 c -0.179226,0 -0.304807,-0.12577 -0.304807,-0.30482 0,-0.14553 0.09211,-0.261945 0.233826,-0.295874 a 0.91636021,0.9163406 0 0 0 0.01374,-0.0036 l 42.83974,-10.983027 a 0.91636021,0.9163406 0 0 0 0.02079,-0.0042 c 0.03486,-0.009 0.07157,-0.01311 0.10978,-0.01371 z"
+ id="path6770"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
=====================================
modules/gui/qt/player/control_list_model.hpp
=====================================
@@ -82,7 +82,7 @@ public:
NAVIGATION_BUTTONS,
PROGRAM_BUTTON,
NAVIGATION_BOX,
- RESERVED_0X2B,
+ VOLUME_LEGACY,
RESERVED_0X2C,
RESERVED_0X2D,
RESERVED_0X2E,
@@ -111,7 +111,7 @@ public:
Q_ENUM(ControlType)
static_assert(RESERVED_0X1F == 0x1F, "missaligned");
- static_assert(RESERVED_0X2B == 0x2B, "missaligned");
+ static_assert(RESERVED_0X2C == 0x2C, "missaligned");
static_assert(RESERVED_0X3F == 0x3F, "missaligned");
// Basic functionality:
=====================================
modules/gui/qt/player/qml/PlayerControlbarControls.qml
=====================================
@@ -57,6 +57,7 @@ QtObject {
{ id: ControlListModel.CHAPTER_PREVIOUS_BUTTON, file: "ChapterPreviousButton.qml", label: VLCIcons.dvd_prev, text: qsTr("Previous chapter") },
{ id: ControlListModel.CHAPTER_NEXT_BUTTON, file: "ChapterNextButton.qml", label: VLCIcons.dvd_next, text: qsTr("Next chapter") },
{ id: ControlListModel.VOLUME, file: "VolumeWidget.qml", label: VLCIcons.volume_high, text: qsTr("Volume Widget") },
+ { id: ControlListModel.VOLUME_LEGACY, file: "VolumeWidgetLegacy.qml", label: VLCIcons.volume_high, text: qsTr("Volume Widget (Legacy)") },
{ id: ControlListModel.NAVIGATION_BOX, file: "NavigationBoxButton.qml", label: VLCIcons.ic_fluent_arrow_move, text: qsTr("Navigation Box") },
{ id: ControlListModel.NAVIGATION_BUTTONS, file: "NavigationWidget.qml", label: VLCIcons.dvd_menu, text: qsTr("Navigation") },
{ id: ControlListModel.DVD_MENUS_BUTTON, file: "DvdMenuButton.qml", label: VLCIcons.dvd_menu, text: qsTr("DVD menus") },
=====================================
modules/gui/qt/player/qml/controlbarcontrols/VolumeWidget.qml
=====================================
@@ -40,6 +40,15 @@ T.Pane {
readonly property real _fullvolpos: 100 / _maxvol
readonly property real _maxvolpos: _maxvol / 100
+ property alias slider: volControl
+ property alias button: volumeBtn
+ property alias tickMark: tickmark
+ property alias mouseArea: sliderMouseArea
+ property alias toolTipVisibilityBinding: toolTipVisibilityBinding
+
+ // TODO: Check if with Qt 7, it is access it via `slider.PointingToolTipAttached`:
+ readonly property Widgets.PointingToolTipAttached sliderPointingToolTip: volControl.Widgets.PointingToolTipAttached
+
implicitWidth: Math.max(implicitBackgroundWidth + leftInset + rightInset,
implicitContentWidth + leftPadding + rightPadding)
implicitHeight: Math.max(implicitBackgroundHeight + topInset + bottomInset,
@@ -202,6 +211,8 @@ T.Pane {
}
Binding on Widgets.PointingToolTipAttached.visible {
+ id: toolTipVisibilityBinding
+
when: sliderMouseArea.pressed
value: true
}
=====================================
modules/gui/qt/player/qml/controlbarcontrols/VolumeWidgetLegacy.qml
=====================================
@@ -0,0 +1,158 @@
+/*****************************************************************************
+ * Copyright (C) 2026 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
+ * the Free Software Foundation; either version 2 of the License, or
+ * ( at your option ) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+import QtQuick
+
+import VLC.PlayerControls
+import VLC.MainInterface
+import VLC.Util
+import VLC.Style
+import VLC.Player
+import VLC.Widgets as Widgets
+
+VolumeWidget {
+ id: root
+
+ slider.implicitWidth: VLCStyle.dp(64, VLCStyle.scale)
+ slider.opacity: 1.0
+ slider.toolTipFollowsMouse: true
+ slider.toolTipTextProvider: function (value) {
+ return Math.round(value * 100) + "%"
+ }
+ slider.handle: null
+
+ toolTipVisibilityBinding.when: false
+
+ tickMark.visible: false
+
+ sliderPointingToolTip.onTextChanged: {
+ if ((sliderPointingToolTip.text !== volumeText.text) && !sliderPointingToolTip.visible && _hovered && !_pressed)
+ toolTipVisibilityTimer.restart()
+ }
+ sliderPointingToolTip.visible: false
+
+ // TODO: Implement `PointingToolTipAttached::delay`.
+ Timer {
+ id: toolTipVisibilityTimer
+
+ interval: VLCStyle.delayToolTipAppear
+
+ onTriggered: {
+ root.slider.Widgets.PointingToolTipAttached.visible = true
+ }
+ }
+
+ readonly property bool _hovered: (slider.hovered || mouseArea.containsMouse)
+
+ on_HoveredChanged: {
+ if (_hovered) {
+ if (!_pressed) {
+ toolTipVisibilityTimer.restart()
+ }
+ } else {
+ toolTipVisibilityTimer.stop()
+ slider.Widgets.PointingToolTipAttached.visible = false
+ }
+ }
+
+ readonly property bool _pressed: (slider.pressed || mouseArea.pressed)
+ on_PressedChanged: {
+ if (_pressed) {
+ toolTipVisibilityTimer.stop()
+ sliderPointingToolTip.visible = false
+ }
+ }
+
+ slider.background: Image {
+ id: backgroundImage
+
+ x: root.slider.leftPadding
+ y: root.slider.topPadding + root.slider.availableHeight / 2 - height / 2
+
+ width: root.slider.availableWidth
+ height: root.button.height * 0.85 // Using `Slider`'s height causes polish loop
+
+ cache: true
+ fillMode: Image.Pad
+ horizontalAlignment: Image.AlignLeft
+ sourceSize: Qt.size(width, height)
+
+ // WARNING: SVG does not support RGBA color.
+ readonly property color opaqueBorder: (root.slider.colorContext.border.a < 1.0) ? (root.slider.colorContext.palette.isDark ? "darkgray"
+ : "gray")
+ : root.slider.colorContext.border
+
+ source: SVGColorImage.colorize("qrc:///misc/volume-slider-outside.svg")
+ .color1(opaqueBorder).uri() // foreground
+
+ Widgets.AnimatedBackground {
+ anchors.fill: parent
+ anchors.margins: -VLCStyle.margin_xxsmall
+
+ visible: (border.color.a > 0.0)
+ enabled: root.slider.colorContext.initialized
+
+ color: "transparent"
+
+ border.color: root.slider.visualFocus ? root.slider.colorContext.visualFocus
+ : Qt.alpha(root.slider.colorContext.visualFocus, 0.0)
+ }
+
+ Image {
+ z: -1 // Gradient is below parent
+
+ anchors.top: parent.top
+ anchors.bottom: parent.bottom
+ anchors.left: parent.left
+
+ width: (parent.width * root.slider.position)
+
+ clip: (root.slider.position < root.slider.to)
+
+ cache: true
+ fillMode: Image.Pad
+ horizontalAlignment: Image.AlignLeft
+ sourceSize: Qt.size(parent.width, height)
+
+ source: Effects.url(Effects.VolumeSliderGradient, { "maximum": (root.slider.to * 100),
+ "sliderColors": MainCtx.volumeSliderColors,
+ "muted": root._player.muted })
+ }
+
+ Text {
+ id: volumeText
+
+ font.pixelSize: VLCStyle.fontSize_small
+ textFormat: Text.PlainText
+
+ x: 0
+ y: -VLCStyle.margin_xxxsmall
+
+ horizontalAlignment: Text.AlignRight
+
+ text: {
+ // the real value i.e 'Player.volume' bounds can be different
+ // from bounds of this widget and we want to show the current
+ // volume here, so directly use Player.volume instead of "value"
+
+ return Math.round(Player.volume * 100) + "%"
+ }
+
+ color: backgroundImage.opaqueBorder // ###
+ }
+ }
+}
=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -195,6 +195,12 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define RECENTPLAY_FILTER_LONGTEXT N_( "Regular expression used to filter " \
"the recent items played in the player." )
+#define SLIDERCOL_TEXT N_( "Define the colors of the legacy volume slider" )
+#define SLIDERCOL_LONGTEXT N_( "Define the colors of the legacy volume slider\n" \
+ "By specifying the 12 numbers separated by a ';'\n" \
+ "Default is '255;255;255;20;226;20;255;176;15;235;30;20'\n" \
+ "An alternative can be '30;30;50;40;40;100;50;50;160;150;150;255'")
+
#define QT_MODE_TEXT N_( "Selection of the starting mode and look" )
#define QT_MODE_LONGTEXT N_( "Start VLC with:\n" \
" - normal mode\n" \
@@ -427,7 +433,8 @@ vlc_module_begin ()
add_bool( "qt-error-dialogs", true, ERROR_TEXT,
nullptr )
- add_obsolete_string( "qt-slider-colours")
+ add_string( "qt-slider-colours", "153;210;153;20;210;20;255;199;15;245;39;29",
+ SLIDERCOL_TEXT, SLIDERCOL_LONGTEXT )
add_bool( "qt-privacy-ask", true, PRIVACY_TEXT, nullptr )
change_private ()
=====================================
modules/gui/qt/util/effects_image_provider.cpp
=====================================
@@ -22,6 +22,10 @@
#include <QUrl>
#include <QUrlQuery>
#include <QPainterPath>
+#include <QImageReader>
+#include <QBitmap>
+#include <QPixmap>
+#include <QLinearGradient>
#include <memory>
@@ -36,6 +40,102 @@ public:
virtual ~IEffect() = default;
};
+class VolumeSliderGradientEffect : public IEffect
+{
+/* This work is derived from Amarok's work under GPLv2+
+ - Mark Kretschmann
+ - Gábor Lehel
+ */
+
+ static constexpr int PADDINGL = 0; // px
+ static constexpr int PADDINGR = 0; // px
+ static constexpr int SOUNDMIN = 0; // %
+
+ const int maximum; // %
+ const QString sliderColors;
+ const bool muted;
+
+public:
+ explicit VolumeSliderGradientEffect(const QVariantMap& setting)
+ : maximum(setting[QStringLiteral("maximum")].toInt())
+ , sliderColors(setting[QStringLiteral("sliderColors")].toString())
+ , muted(setting[QStringLiteral("muted")].toBool())
+ {
+
+ }
+
+ QImage generate(const QSize& size) const override
+ {
+ // This is carried over from VLC 3.0's `SoundSlider`, in file
+ // `input_slider.cpp`, only with minor changes applied:
+
+ QImage insideImage;
+
+ {
+ QImageReader insideImageReader(QStringLiteral(":/misc/volume-slider-inside.svg"));
+ insideImageReader.setScaledSize(size);
+ insideImage = insideImageReader.read();
+ }
+ assert(!insideImage.isNull());
+
+ const QBitmap mask = QPixmap::fromImage(insideImage).createMaskFromColor(QColor(0, 255, 255) /* Cyan */,
+ Qt::MaskInColor);
+
+ QPixmap pixGradient( size );
+
+ /* Gradient building from the preferences */
+ QLinearGradient gradient( PADDINGL, 2, size.width() - PADDINGR, 2 );
+
+ QStringList colorList = sliderColors.split( ';' );
+
+ /* Fill with 255 if the list is too short */
+ if( colorList.count() < 12 )
+ for( int i = colorList.count(); i < 12; i++)
+ colorList.append( "255" );
+
+ /* Regular colors */
+#define c(i) colorList.at(i).toInt()
+
+#define add_color(gradient, range, c1, c2, c3) \
+ gradient.setColorAt( range, QColor( c(c1), c(c2), c(c3) ) );
+
+ /* Desaturated colors */
+#define desaturate(c) c.setHsvF( c.hueF(), 0.2 , 0.5, 1.0 )
+#define add_desaturated_color(gradient, range, c1, c2, c3) \
+ foo = QColor( c(c1), c(c2), c(c3) );\
+ desaturate( foo ); gradient.setColorAt( range, foo );\
+
+#define add_colors(gradient, range, c1, c2, c3) \
+ if (!muted) { \
+ add_color( gradient, range, c1, c2, c3 ) \
+ } else { \
+ add_desaturated_color( gradient, range, c1, c2, c3 ) \
+ }
+
+ float f_mid_point = ( 100.0 / maximum );
+ QColor foo;
+ add_colors( gradient, 0.0, 0, 1, 2 );
+ add_colors( gradient, f_mid_point - 0.05, 3, 4, 5 );
+ add_colors( gradient, f_mid_point + 0.05, 6, 7, 8 );
+ add_colors( gradient, 1.0, 9, 10, 11 );
+
+ {
+ QPainter painter;
+
+ painter.begin( &pixGradient );
+ painter.setPen( Qt::NoPen );
+ painter.setBrush( gradient );
+ painter.drawRect( pixGradient.rect() );
+
+ painter.end();
+
+ pixGradient.setMask( mask );
+ }
+
+ return pixGradient.toImage();
+ }
+};
+
class RectDropShadowEffect : public IEffect
{
@@ -243,6 +343,10 @@ QImage EffectsImageProvider::requestImage(const QString &id, QSize *size, const
effect = std::make_unique<DoubleShadowEffect>(queryToVariantMap(query));
break;
+ case EffectsImageProvider::VolumeSliderGradient:
+ effect = std::make_unique<VolumeSliderGradientEffect>(queryToVariantMap(query));
+ break;
+
default:
return {};
}
=====================================
modules/gui/qt/util/effects_image_provider.hpp
=====================================
@@ -35,7 +35,8 @@ public:
{
RectDropShadow = 1,
RoundedRectDropShadow,
- DoubleRoundedRectDropShadow
+ DoubleRoundedRectDropShadow,
+ VolumeSliderGradient
};
Q_ENUM(Effect)
=====================================
modules/gui/qt/widgets/qml/SliderExt.qml
=====================================
@@ -64,7 +64,7 @@ T.Slider {
if (toolTipFollowsMouse && hoverHandler.hovered)
return hoverHandler.point.position.x
- return (handle.x + handle.width / 2) // handle center
+ return handle ? (handle.x + handle.width / 2) : 0.0 // handle center
}
// find position under given x, can be used with Slider::valueAt()
@@ -72,7 +72,7 @@ T.Slider {
function positionAt(x) {
// taken from qt sources QQuickSlider.cpp
// TODO: support vertical slider
- const hw = control.handle.width
+ const hw = control.handle?.width ?? 0
const offset = control.leftPadding + hw / 2
const extend = control.availableWidth - hw
return (x - offset) / extend
@@ -136,12 +136,9 @@ T.Slider {
target: background
}
- Widgets.PointingToolTipAttached.pos: Qt.point(control._tooltipX, control.handle.height / 2)
+ Widgets.PointingToolTipAttached.pos: Qt.point(control._tooltipX, (control.handle?.height ?? 0) / 2)
Widgets.PointingToolTipAttached.visible: (hoverHandler.hovered || control.visualFocus || control.pressed)
Widgets.PointingToolTipAttached.text: {
- if (!Widgets.PointingToolTipAttached.instance?.visible)
- return ""
-
// position is only measured till half of handle width
// pos.x may go beyond the position at the edges
const p = Helpers.clamp(control.positionAt(Widgets.PointingToolTipAttached.instance.pos.x), 0.0, 1.0)
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8db76b85b82cea4a1dc9426d1bd06273c6763605...289ac2b8ee3255e9fb9a9f29c9f48804ccf9d659
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/8db76b85b82cea4a1dc9426d1bd06273c6763605...289ac2b8ee3255e9fb9a9f29c9f48804ccf9d659
You're receiving this email because of your account on code.videolan.org. Manage all notifications: https://code.videolan.org/-/profile/notifications | Help: https://code.videolan.org/help
More information about the vlc-commits
mailing list