[vlc-commits] [Git][videolan/vlc][master] 6 commits: qt: introduce option `qt-accent-color`
Steve Lhomme (@robUx4)
gitlab at videolan.org
Thu May 14 11:49:00 UTC 2026
Steve Lhomme pushed to branch master at VideoLAN / VLC
Commits:
259c7b86 by Fatih Uzunoglu at 2026-05-14T10:48:30+00:00
qt: introduce option `qt-accent-color`
- - - - -
cca5b6d0 by Fatih Uzunoglu at 2026-05-14T10:48:30+00:00
qt: depend on qt in libqt_gtktheme_plugin
This allows us to use `QColor`, and get the
application palette.
- - - - -
102101cf by Fatih Uzunoglu at 2026-05-14T10:48:30+00:00
qt: respect `qt-accent-color` in `qt-themeprovider-gtk`
- - - - -
1eca7552 by Fatih Uzunoglu at 2026-05-14T10:48:30+00:00
qt: respect `qt-accent-color` in `qt-themeprovider-systempalette`
- - - - -
e9469809 by Fatih Uzunoglu at 2026-05-14T10:48:30+00:00
qt: respect `qt-accent-color` in `SystemPalette`
- - - - -
da88dc3f by Fatih Uzunoglu at 2026-05-14T10:48:30+00:00
qml: do not colorize the cone icon
- - - - -
10 changed files:
- modules/gui/qt/Makefile.am
- modules/gui/qt/maininterface/qml/NoMedialibHome.qml
- modules/gui/qt/meson.build
- modules/gui/qt/player/qml/MinimalView.qml
- modules/gui/qt/qt.cpp
- modules/gui/qt/style/gtkthemeprovider/gtkthemeprovider.cpp
- modules/gui/qt/style/systempalette.cpp
- modules/gui/qt/style/systempalette.hpp
- modules/gui/qt/style/systempalettethemeprovider.cpp
- modules/gui/qt/widgets/qml/BannerCone.qml
Changes:
=====================================
modules/gui/qt/Makefile.am
=====================================
@@ -1591,10 +1591,10 @@ assets.cpp: assets.qrc
if HAVE_QT_GTK
-libqt_gtktheme_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(GTK3_CFLAGS)
+libqt_gtktheme_plugin_la_CXXFLAGS = $(AM_CXXFLAGS) $(GTK3_CFLAGS) $(QT_CFLAGS)
libqt_gtktheme_CPPFLAGS = $(AM_CPPFLAGS)
libqt_gtktheme_plugin_la_LDFLAGS = $(AM_LDFLAGS)
-libqt_gtktheme_plugin_la_LIBADD = $(GTK3_LIBS)
+libqt_gtktheme_plugin_la_LIBADD = $(GTK3_LIBS) $(QT_LIBS)
libqt_gtktheme_plugin_la_SOURCES = \
style/gtkthemeprovider/gtk_compat.cpp \
style/gtkthemeprovider/gtk_compat.h \
=====================================
modules/gui/qt/maininterface/qml/NoMedialibHome.qml
=====================================
@@ -109,7 +109,7 @@ FocusScope {
: buttons.implicitHeight * 1.618 * _eDPR) // 1.618 = golden ratio approximation
source: MainCtx.useXmasCone() ? "qrc:///logo/vlc48-xmas.png" // TODO: new xmas cone designs
- : SVGColorImage.colorize("qrc:///misc/cone.svg").accent(theme.accent).uri()
+ : "qrc:///misc/cone.svg"
Connections {
target: MainCtx
=====================================
modules/gui/qt/meson.build
=====================================
@@ -1117,7 +1117,7 @@ if qt6_dep.found()
'style/gtkthemeprovider/nav_button_provider_gtk.h',
'style/gtkthemeprovider/scoped_gobject.h'
),
- 'dependencies' : [gtk_dep],
+ 'dependencies' : [gtk_dep, qt6_dep],
'enabled' : gtk_dep.found()
}
=====================================
modules/gui/qt/player/qml/MinimalView.qml
=====================================
@@ -97,7 +97,7 @@ FocusScope {
source: MainCtx.useXmasCone()
? "qrc:///logo/vlc48-xmas.png"
- : SVGColorImage.colorize("qrc:///misc/cone.svg").accent(theme.accent).uri()
+ : "qrc:///misc/cone.svg"
anchors.centerIn: parent
width: Math.min(parent.width / 2, sourceSize.width)
=====================================
modules/gui/qt/qt.cpp
=====================================
@@ -278,6 +278,9 @@ static void ShowDialog ( intf_thread_t *, int, int, intf_dialog_args_t * );
#define PIP_MODE_TEXT N_( "Enable picture-in-picture (PiP) mode" )
#define PIP_MODE_LONGTEXT N_( "Picture-in-picture mode allows playing video contained in a smaller area so that the interface remains usable." )
+#define ACCENT_COLOR_TEXT N_( "Accent color" )
+#define ACCENT_COLOR_LONGTEXT N_( "Adjusts the accent color, special values are 'default' and 'system' (requires Qt 6.6) ." )
+
static const int initial_prefs_view_list[] = { 0, 1, 2 };
static const char *const initial_prefs_view_list_texts[] =
{ N_("Simple"), N_("Advanced"), N_("Expert") };
@@ -458,6 +461,8 @@ vlc_module_begin ()
add_float_with_range( "qt-safe-area", 0, 0, 100.0, SAFE_AREA_TEXT, SAFE_AREA_LONGTEXT )
+ add_string( "qt-accent-color", "default", ACCENT_COLOR_TEXT, ACCENT_COLOR_LONGTEXT )
+
cannot_unload_broken_library()
add_submodule ()
=====================================
modules/gui/qt/style/gtkthemeprovider/gtkthemeprovider.cpp
=====================================
@@ -20,6 +20,12 @@
#include "config.h"
#endif
+#include <QColor>
+#include <QPalette>
+#include <QApplication>
+
+#undef signals
+
#include <vlc_common.h>
#include <vlc_plugin.h>
#include "../qtthemeprovider.hpp"
@@ -188,10 +194,35 @@ static int updatePalette(vlc_qt_theme_provider_t* obj)
bool isDark = isThemeDark(obj);
GdkRGBA accent;
- if (isDark)
- gdk_rgba_parse(&accent, "#FF8800");
- else
- gdk_rgba_parse(&accent, "#FF610A");
+
+ {
+ QColor qcAccent;
+
+ char* accentColor = var_InheritString(obj, "qt-accent-color");
+ assert(accentColor);
+
+ if (!strcmp(accentColor, "default"))
+ {
+ qcAccent = QColor( isDark ? "#FF8800" : "#FF610A" );
+ }
+#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
+ else if (!strcmp(accentColor, "system"))
+ {
+ assert(qApp);
+ const auto palette = qApp->palette();
+ qcAccent = palette.color(QPalette::Normal, QPalette::Accent);
+ }
+#endif
+ else
+ {
+ qcAccent = QColor(accentColor);
+ }
+
+ free(accentColor);
+
+ gdk_rgba_parse(&accent, qcAccent.name(QColor::HexRgb).toLatin1().constData());
+ }
+
//IDK how to retreive the shadow color from GTK, using a black like in our theme is good enough
GdkRGBA shadow;
=====================================
modules/gui/qt/style/systempalette.cpp
=====================================
@@ -299,6 +299,39 @@ void ExternalPaletteImpl::updateMetrics(vlc_qt_theme_image_type type)
SystemPalette::SystemPalette(QObject* parent)
: QObject(parent)
{
+
+}
+
+void SystemPalette::componentComplete()
+{
+ {
+ assert(m_ctx);
+ char* accentColor = var_InheritString(m_ctx->getIntf(), "qt-accent-color");
+ assert(accentColor);
+
+ if (!strcmp(accentColor, "default"))
+ {
+ // Use default
+ }
+#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
+ else if (!strcmp(accentColor, "system"))
+ {
+ assert(qApp);
+ const auto palette = qApp->palette();
+
+ orange500 = palette.color(QPalette::Normal, QPalette::Accent);
+ orange800 = orange500.lighter(150);
+ }
+#endif
+ else
+ {
+ orange500 = QColor(accentColor);
+ orange800 = orange500.lighter(150);
+ }
+
+ free(accentColor);
+ }
+
updatePalette();
}
=====================================
modules/gui/qt/style/systempalette.hpp
=====================================
@@ -99,9 +99,10 @@ private: \
-class SystemPalette : public QObject
+class SystemPalette : public QObject, public QQmlParserStatus
{
Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
public:
Q_PROPERTY(MainCtx* ctx READ getCtx WRITE setCtx NOTIFY ctxChanged FINAL)
Q_PROPERTY(ColorSchemeModel::ColorScheme source READ source WRITE setSource NOTIFY sourceChanged FINAL)
@@ -149,6 +150,9 @@ public:
QColor getColor(ColorContext::ColorSet colorSet, ColorContext::ColorSection section,
ColorContext::ColorName name, ColorContext::ColorState state) const;
+ void classBegin() override { }
+ void componentComplete() override;
+
public slots:
void setSource(ColorSchemeModel::ColorScheme source);
void setCtx(MainCtx* ctx);
=====================================
modules/gui/qt/style/systempalettethemeprovider.cpp
=====================================
@@ -22,6 +22,7 @@
#include <QGuiApplication>
#include <QPalette>
+#include <QColor>
namespace {
@@ -136,8 +137,33 @@ static int updatePalette(vlc_qt_theme_provider_t* obj)
QPalette& palette = sys->m_palette;
- QColor accent = QColor( sys->m_isDark ? "#FF8800" : "#FF610A" );
- QColor accentPressed = QColor( sys->m_isDark ? "#e67a30" : "#e65609" );
+ QColor accent;
+ QColor accentPressed;
+ {
+ char* accentColor = var_InheritString(obj, "qt-accent-color");
+ assert(accentColor);
+
+ if (!strcmp(accentColor, "default"))
+ {
+ accent = QColor( sys->m_isDark ? "#FF8800" : "#FF610A" );
+ accentPressed = QColor( sys->m_isDark ? "#e67a30" : "#e65609" );
+ }
+#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
+ else if (!strcmp(accentColor, "system"))
+ {
+ accent = palette.color(QPalette::Normal, QPalette::Accent);
+ accentPressed = accent.lighter(150);
+ }
+#endif
+ else
+ {
+ accent = QColor(accentColor);
+ accentPressed = accent.lighter(150);
+ }
+
+ free(accentColor);
+ }
+
QColor textOnAccent = Qt::white;
QColor visualFocus = sys->m_isDark ? Qt::white : Qt::black;
QColor shadow = palette.color(QPalette::Normal, QPalette::Shadow);
=====================================
modules/gui/qt/widgets/qml/BannerCone.qml
=====================================
@@ -34,7 +34,7 @@ Image {
mipmap: MainCtx.useXmasCone()
source: MainCtx.useXmasCone() ? "qrc:///logo/vlc48-xmas.png" // TODO: new xmas cone for designs?
- : SVGColorImage.colorize("qrc:///misc/cone.svg").accent(root.color).uri()
+ : "qrc:///misc/cone.svg"
focus: false
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2a679fe52d87aeca53b2fa41a0cde4329c93d6dd...da88dc3f66331e965303f26d5a9d60b63c98f0ad
--
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/2a679fe52d87aeca53b2fa41a0cde4329c93d6dd...da88dc3f66331e965303f26d5a9d60b63c98f0ad
You're receiving this email because of your account on code.videolan.org.
More information about the vlc-commits
mailing list