QML style guide

Sebastian Kügler sebas at kde.org
Tue Oct 30 12:01:37 UTC 2012


Hey,

On Tuesday, October 30, 2012 14:14:05 Dmitry Ashkadov wrote:
> 30.10.2012 13:15, Aaron J. Seigo пишет:
> >> 1. I think you should explain why you have chosen  such style instead of
> >> another one. Your decision should be justified.
> > 
> > this is the death of style guides. for many style decisions there is no
> > justification that can be made; it is simply a matter of custom and
> > personal taste. tabs vs spaces is the classic example.
> 
> I think you are wrong. Any decision has its justification. Fox example,
> if you use spaces it may be due to old code.

I think it's reasonable to extend the coding style we're used to (from writing 
C++) to QML.

> >> Some JS can be an adjunct to QML file and cannot be used
> >> outside of this QML file. Such JS can provide stuff for only one QML. To
> > 
> > should each QML file go into its own directory?
> > 
> > contents/main/main.qml
> > contents/main/main.js
> > contents/itemdelegate/delegate.qml
> > contents/itemdelegate/delegate.js
> 
> No, no, no.
> 
> contents/ui/main.qml
> contents/ui/main.js
> contents/ui/delegate.qml
> contents/ui/delegate.js
> contents/code/statelesslib.js
>
> We see that main.qml and main.js, delegate.qml and delegate.js may be
> considered in pairs. main.qml cannot exist without main.js. At the same
> time there is  statelesslib.js that may be shared between main.qml and
> delegate.qml

There, the JS code should probably be in the QML file itself, as that's the 
only place where it's used. For the shared code, you'd import:

import "plasmapackage:/code/statelesslib.js" as StatelessLib

Cheers,
-- 
sebas

http://www.kde.org | http://vizZzion.org | GPG Key ID: 9119 0EF9


More information about the Plasma-devel mailing list