[Development] Proposal: expose the OS/platform in QML

Bache-Wiig Jens Jens.Bache-Wiig at digia.com
Wed Jan 16 08:21:16 CET 2013


On Jan 15, 2013, at 6:38 PM, Attila Csipa <qt at csipa.in.rs> wrote:

> On 15/01/13 18:27, Nurmi J-P wrote:
>> What do you think about exposing the underlying operating system and/or platform name in QML?
>> ...
>> Which one of these proposals do you like the most, or are you against the whole idea?
> 
> In my eyes the real question is that comes after this one - once you 
> know it (you can inject it into the context even today), what do you do 
> with it? If it is going to be used for content selection, it seems to be 
> just the underpinning of what also was Alans proposal a little while 
> back. I would be averse to using OS/platform name selector just as a 

True. It is exactly what we would use to implement the platform selector. But it can also be more powerful than that because it makes it possible to implement your own platform selectors if you disagree with whatever mechanism we come up with. (i.e you can create a loader that takes dpi, os, orientation and resolution into account)

I wonder how useful it is to know the platform plugin though. I.e I don't really care if I am on wayland or x11 or when writing QML. If I did, I would probably we writing a C++ extension.

What I primarily care about is if I am on "mac", "windows", "linux", "android" or "iOS". This is information I would use quite often and only exposing that would be a good start.

Second, it would be useful to know if I am on a "phone", "tablet" or "desktop" platform. ( can already guess by the resolution but perhaps it would be convenient to abstract it a bit.

And eventually I might want to know even more. Such as the desktop environment I am using on linux, the version of Windows or Mac OS and If I am on IOS, I might even want to know exactly which device I am running on.

> surogate for testing feature/component availability (as it would work 
> conveniently only as far as there is just "one" device or configuration 
> for that OS/platform).


I don't see this as an argument against exposing such properties. But as suggested above, I think we need even more properties to describe the runtime environment. 

+1 for the idea from me. But not exactly as proposed.

I think we can start with just the "os" part and add other things later. And I think we need might need a different set of attributes from each platform. What if we make it possible to query the platform plugin for platform specific details, i.e like:

I.e  if (Platform.os == "iOS" && 
          Platform.property("deviceType") == "iphone" && 
          Platform.property("deviceVersion") == "3G") ...

This way the platform plugins could add all the platform dependent properties in a clean fashion. There are plenty of things like the current GNOME theme and such that could be added which it would not really make sense to pollute the API with. 

And even if we don't add this to QML now, it would still make sense to add this to our C++ API.

Regards,
Jens




More information about the Development mailing list