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

Samuel Rødal samuel.rodal at digia.com
Wed Jan 16 08:49:16 CET 2013


On 01/16/2013 08:21 AM, Bache-Wiig Jens wrote:
>
> 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.

These days you can't really tell from the resolution :) But I don't 
think Qt currently has a way to distinguish xcb/wayland running on a 
tablet vs a desktop, or eglfs running on a phone vs a tablet. How would 
a typical Android application make the latter distinction?

> 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") ...

Sounds good.

--
Samuel



More information about the Development mailing list