Yash Bavadiya

Week 6: Gradient Widget Wired to Qt-Color-Widgets

This is a weekly update from my Google Summer of Code 2026 project with KDE, improving effect widgets in Kdenlive, a free and open source video editor.

Gradient widget: switched to Qt-Color-Widgets

Julius Künzel suggested last week that the Gradient widget be built with an eye toward upstreaming to KDE Frameworks, pointing to Qt-Color-Widgets's GradientEditor class as a reference. It's already vendored inside MLT's Glaxnimate module, so this week I wired it in directly instead of maintaining a fully custom-painted widget.

The vendored color_widgets::GradientEditor gives a native-styled gradient bar with checkerboard alpha preview, drag-and-drop stop reordering, and its own color dialog, all for free.

Fixing undo-stack behavior

The library only emits stopsChanged on completed actions (mouse release, menu add/remove, dialog accept), not per-pixel during drags. That meant two bugs: every plain click created a junk undo-stack entry, and drags had no live preview on the monitor at all.

Fixed with three pieces:

32-stop cap

MLT's gradientmap filter supports stop.1 through stop.32. The library has no pre-add hook to reject a 33rd stop, so commitStops() rejects after the fact: the just-added stop gets removed and the editor reset under a signal blocker, with no undo entry created. gradientStopsFromString() also truncates at 32 on load, so an over-long saved value can't smuggle in extra stops. Exposed as GradientEditWidget::MaxStops.

Build: configurable vendor path

The path to Qt-Color-Widgets was previously hardcoded assuming a sibling MLT checkout. Replaced with a KDENLIVE_QTCOLORWIDGETS_PATH CMake cache variable; same default, overridable with -D, and a missing path is now a fatal configure error instead of a silent skip that only surfaced at compile time.

Tests

gradienteditwidgettest.cpp now covers a full widget-interaction path with a real timeline document and synthesized mouse events: a plain click produces zero undo entries, a drag produces two preview emissions plus exactly one committed undo entry, and adding a 33rd stop is rejected with the editor staying at 32. All 5 test cases pass, 62 assertions.

What's next

Four commits are done locally (gradient widget + CMake + tests, plus two unrelated Qt 6.10 compat fixes found along the way), but nothing's pushed yet. Waiting on Jean-Baptiste to confirm this is the direction to commit to before opening an MR.