<div dir="ltr"><div>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.</div>
<div><br></div><div>This is pushed in the plasma-frameworks branch davidedmundson/controls</div><div><br></div><div>Advantages:</div><div> - 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</div>
<div> - consistent API with the configuration controls and other QML users</div><div> - more code sharing is better</div><div> - we get some features for "free". For buttons we get action support, exclusiveGroups, tooltips</div>
<div><br></div><div>Downsides:</div><div> - Source breakage</div><div>Although the API is very very similar, there are some differences.</div><div>For just button; icon -> iconName/iconSource, no font property</div><div>
We /could/ bodge it with alias's. For other components this may be more difficult</div><div> - More work.<br></div><div>As a rough guide I ported Button in about 1 hour. It's not a perfect 1-1 port, but it's 90% there.</div>
<div><br></div><div>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.</div>
<div><br></div><div>Effectively the code for the new Button.qml is simply:</div><div><br></div><div>QtControls.Button</div><div>{</div><div>    style: QtControlsStyle.ButtonStyle {</div><div>        background: PlasmaCore.SvgItem {</div>
<div>                imagePath: "widgets/button"</div><div>        }</div><div>    }</div><div>}</div><div><br></div><div>but with a few more animations and hints to match the original.</div><div><br></div><div>
Do we think it is worth porting all the items which can use controls to do so?<br></div><div><br></div><div>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.</div>
<div><br></div><div>Thoughts?</div><div><br></div><div>David Edmundson</div><div><br></div><div>[1] <a href="http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qmlmodule-qtquick-controls1-qtquick-controls-1-0.html">http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrols/qmlmodule-qtquick-controls1-qtquick-controls-1-0.html</a></div>
<div>[2] <a href="http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrolsstyles/qmlmodule-qtquick-controls-styles1-qtquick-controls-styles-1-0.html">http://doc-snapshot.qt-project.org/qt5-stable/qtquickcontrolsstyles/qmlmodule-qtquick-controls-styles1-qtquick-controls-styles-1-0.html</a></div>
</div>