openBrain wrote: ↑Sun Apr 05, 2020 2:41 pm
Good. I'll give a try to static fromRgba(). Will amend my commit if it's OK so if you're the one that merge, please wait another compilation time before proceeding.
I am not sure that is necessary, as we are not using alpha channel...
This code:
Code: Select all
QIcon TaskSketcherElements::MultIcon::getIcon(bool construction, bool external) const
{
if (construction == external) return Normal;
if (construction) return Construction;
if (external) return External;
return Normal;
}
Saying that when the value of construction equals the value of external, then the normal icon should be used, has IMO code readability problems. It is unclear why having a same value should return Normal...unless you assume that they are never going to be both true at the same time. This impacts code maintenability.
Another argument is these cases is as follows: if the sketcher is modified to allow for external geometry that is construction and external geometry that is not construction, it would be unexpected that the neither the construction, nor the external icons are returned, but the normal icon. However, I do agree that in such a case this function would need to be changed anyway to match the new situation, so this argument is not very relevant to this specific case.
In cases like this, if you want to cover all the bases, it is relevant to think: what if that pesky user is really putting to true both parameters? what is the best behaviour for the user:
a) we make FC crash.
b) we raise an exception.
c) we just prioritise the results and give the one that we think is a better match.
What about something in the lines of:
Code: Select all
QIcon TaskSketcherElements::MultIcon::getIcon(bool construction, bool external) const
{
if (construction)
return Construction;
if (external)
return External;
return Normal;
}