[SailfishDevel] App own C++ plugin equivalent to Silica Theme
th.perl at gmail.com
Tue Jan 28 20:27:50 UTC 2014
On 2014-01-28 10:59, christopher.lamb at thurweb.ch wrote:
> I would like to create a C++ plugin for my app to export common UX
> settings as constants to the QML side (Things like font sizes, margin
> sizes that reoccur throughout the app.)
> In essence I want something very similar to the functionality offered
> by by the Silica Theme.
> After some experimentation I have hit on a solution that both compiles
> and works. This is pasted at the bottom of this mail.
> I have 2 questions:
> 1) Is there a more elegant solution to achieve the same goal?
Not sure if it's more elegant, but back in the Harmattan days with
gPodder, I just collected all constants in a "config.js" file and
imported that in QML:
From QML (assuming it's in the same folder), you can then do:
import "config.js" as Config
And if you have "var blubb = 123" in your config.js file, and you have
imported it like above, you can then use "Config.blubb" to access that
> 2) From the C++ side, can I access the Silica them UX constants? e.g
> to set some of my constants based on Silica constants?
class and use it in your JS, you can do this with something like:
More information about the Devel