[RFC] Port PlasmaComponents to use QtQuick Controls where applicable

David Edmundson david at davidedmundson.co.uk
Mon Aug 19 00:05:50 UTC 2013


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/plasma-devel/attachments/20130819/4251a11e/attachment.html>


More information about the Plasma-devel mailing list