[RFC] Port PlasmaComponents to use QtQuick Controls where applicable

Aleix Pol aleixpol at kde.org
Mon Aug 19 08:50:15 UTC 2013


On Mon, Aug 19, 2013 at 2:05 AM, David Edmundson <david at davidedmundson.co.uk
> wrote:

> After discussions with a few people, I decided for an experiment to port
> PlasmaComponents Button to use QtQuickControls [1] internally but use the
> styles API [2] to make it look like the original PlasmaComponents button.
>
> This is pushed in the plasma-frameworks branch davidedmundson/controls
>
> Advantages:
>  - considerably simpler code. We don't have to do our own mousearea and
> key handling. It's all done for us. I reduced Button.qml to about 1/2 the
> original size
>  - consistent API with the configuration controls and other QML users
>  - more code sharing is better
>  - we get some features for "free". For buttons we get action support,
> exclusiveGroups, tooltips
>
> Downsides:
>  - Source breakage
> Although the API is very very similar, there are some differences.
> For just button; icon -> iconName/iconSource, no font property
> We /could/ bodge it with alias's. For other components this may be more
> difficult
>  - More work.
> As a rough guide I ported Button in about 1 hour. It's not a perfect 1-1
> port, but it's 90% there.
>
> The approach I took was to make the PlasmaComponents.Button subclass the
> QtQuickControls.Button and then set a style on it rather than make a full
> plasma style for all QtQuickControls. This should allow us to make plasma
> extensions to the API as well as keep most source compatibility as well as
> keep the workload realistic.
>
> Effectively the code for the new Button.qml is simply:
>
> QtControls.Button
> {
>     style: QtControlsStyle.ButtonStyle {
>         background: PlasmaCore.SvgItem {
>                 imagePath: "widgets/button"
>         }
>     }
> }
>
> but with a few more animations and hints to match the original.
>
> Do we think it is worth porting all the items which can use controls to do
> so?
>
> I think given the current API changes it makes sense to use this
> opportunity to make this change. I believe we will get better more stable
> code for it. I can do most the changes.
>
> Thoughts?
>
> David Edmundson
>
> [1]
> http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qmlmodule-qtquick-controls1-qtquick-controls-1-0.html
> [2]
> http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrolsstyles/qmlmodule-qtquick-controls-styles1-qtquick-controls-styles-1-0.html
>
> _______________________________________________
> Plasma-devel mailing list
> Plasma-devel at kde.org
> https://mail.kde.org/mailman/listinfo/plasma-devel
>
>
Hi David!
I'm so happy to see you working on this! Actually to be honest, I think
it's not really something up to discussion, Qt Controls is something we
want Plasma to be part of. The question is if it should be the official way
to write applets and stuff, but I'd rather look into it the other way
around.

For applications, we want to be able to write them in Qt Controls. For
instance, I'd really like to see Muon Discover working properly on PA, or
at least sharing most of the code base with the desktop version and Qt
Controls is the (only?) way to go for this. Furthermore, we'll want Ubuntu
apps to integrate with us. We want to support Qt Controls.

I'd say that whether it's the official API for writing plasmoids, will be
seen in the future, but it already is the official API for writing
applications in Qt Quick that can target more than 1 operating system or
even 1 Look&Feel.

Cheers!
Aleix
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20130819/54d76cd1/attachment.html>


More information about the Plasma-devel mailing list