Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
Regular Contributor
JohnQtQml
Posts: 55
Registered: ‎10-31-2012
My Device: Blackberry 10 Dev Alpha Simulator - VMware
My Carrier: (none)

Conditional inclusion of parts of my qml file.

[ Edited ]

Hi.  I was wondering is there a way that I can have parts of my qml file sometimes included and sometimes not included.  For example, if compiling for a blackerry device that is still on 10.0 os, I can't use titlebar.freeForm, because that is only for blackberry cascades 10.1.  So I would like to do something like this:

 

titleBar: TitleBar {
        id: titleBar
        objectName: "titleBar"
        title: "MY TITLE"       

       

        #if OS >= BB10_1


        kind: TitleBarKind.FreeForm
        kindProperties: FreeFormTitleBarKindProperties {
            content: Container {
                layout: StackLayout { orientation: LayoutOrientation.LeftToRight }
                ImageButton {
                    id: backTitleBar
                    objectName: "BackTitleBar"
                    visible: false
                    defaultImageSource: "asset:///images/back.png"
                    onClicked: app.goBack()
                    minHeight: 100
                    minWidth: 100
                }
                Label {
                    text: "GODEALERSHIP MOBILE"
                }
                ActivityIndicator {
                    id: activityIndicatorTitleBar
                    objectName: "activityIndicatorTitleBar"
                    minWidth: 100
                    minHeight: 100
                }
                leftPadding: 10
                rightPadding: 10
            }

#endif

}

Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: Conditional inclusion of parts of my qml file.

No there is no way to that, besides creating two different projects: one for 10.0 and one for 10.1. But I don't think you'll miss that much clients if you just release for 10.1 these days.

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Developer
simon_hain
Posts: 15,805
Registered: ‎07-29-2008
My Device: Z10 LE
My Carrier: O2 Germany

Re: Conditional inclusion of parts of my qml file.

you could write your own assets selector with a c++ utility, like:
var page;
if (util.version == 10.1){
page = page101def.createObject();
} else {
page = page100def.createObject();
}
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Please use plain text.
Developer
zezke
Posts: 1,004
Registered: ‎12-12-2010
My Device: Z10 (red Limited Edition)
My Carrier: Mobile Vikings

Re: Conditional inclusion of parts of my qml file.

Ha, hadn't though of that. +1 for simon's solution!

-------------------------------------------
BlackBerry Certified Builder for Native Application Development -- Proud member of the Belgian BlackBerry Developer group
Samples: Park in Ghent
Feeling generous? Nominate me for BB Elite member!
Please use plain text.
Regular Contributor
JohnQtQml
Posts: 55
Registered: ‎10-31-2012
My Device: Blackberry 10 Dev Alpha Simulator - VMware
My Carrier: (none)

Re: Conditional inclusion of parts of my qml file.

Ok, I made two different qml files, main.qml and main100.qml.  The main.qml is for blackbbery os version 10.1 or more, and main100.qml is for blackberry os version 10.0.  And then in my C++ code, I have the following precompiled code:

 

#define BB10_0 0
#define BB10_1 1

#define OS BB10_0

#if OS == BB10_0
    #define QML_FILE "main100.qml"
#elif OS == BB10_1
    #define QML_FILE "main.qml"
#endif

 

The issue with this code is that it must be manually changed to compile for blackberry 10.0 vs blackberry >= 10.1.

Are there some predefined macros or some sort of way making this code more automatic based on the os version of the blackberry you are compiling for?

 

Please use plain text.