PDA

View Full Version : Is it good or else?



umnbr
31st January 2016, 13:02
make a javascript file for style
like


var colors =
{
applicatonRoot : "transparent",
itemIntro : "green",
rectangleIntro : "#c5dedd"
};


var widths =
{
applicatonRoot : 770,
itemIntro : 770,
rectangleIntro : "#c5dedd"
};



and javascript file for all texts
like




var texts =
{
applicatonRoot : "Welcome to my page",
ButtonIntro : "Click"
};



and javascript file for all functions and so one
and include it into qml?
Is it good or some thing else?

anda_skoa
31st January 2016, 13:22
The strings should better be in the places where they are used, is this allows to easier disambiguate for translations when necessary.

For the colors this looks ok, though you probably want to use


.pragma libary

so it only gets loaded once.

You can also do this with a QML element, either as a global object or as a singleton.

Cheers,
_

umnbr
31st January 2016, 18:52
thank you anda_skoa,
- i aim to use all varibles in javascript: color, font, width, heigh, x, y, border, image, etc what about memory?
- i have 30 pages of qml which is better:
1- add all pages in one qml file seperated with Item
ApplicationWindow{ Item{ id: intro } Item{ id: page1 } Item{ id: page2 } Item{ id: page30 } }
and use show and hide etch item.

2- open intro.qml and hide it and open page1.qml and hide page1.qml etc
3- open intro.qml and when i click next button load page1.qml into intro.qml
4- open intro.qml and when i click next button open page1.qml into as dialuog
5- something else?

anda_skoa
31st January 2016, 21:21
thank you anda_skoa,
- i aim to use all varibles in javascript: color, font, width, heigh, x, y, border, image, etc what about memory?

I am afraid I don't understand what you want to know.



- i have 30 pages of qml which is better:
1- add all pages in one qml file seperated with Item
ApplicationWindow{ Item{ id: intro } Item{ id: page1 } Item{ id: page2 } Item{ id: page30 } }
and use show and hide etch item.

2- open intro.qml and hide it and open page1.qml and hide page1.qml etc
3- open intro.qml and when i click next button load page1.qml into intro.qml
4- open intro.qml and when i click next button open page1.qml into as dialuog
5- something else?

There is not "best" way since some aspects depend on the requirements.

For example instantiating everything at startup increases the startup time but makes switching between screens basically instant.
Loading on demand reduces startup time and memory consumption, but also means switching might not be instant and it is more complicated.

It also depends on how you are navigating through the screens, e.g. if all are equal or if some are sub screens of another, etc.

Independent it is usually a good idea to separate different screens into different files, so each screen can potentially be tested stand-alone and it also keeps each file small and easy to read and understand.

Cheers,
_