Conversion functions for RgbColor#2518
Conversion functions for RgbColor#2518Holzhaus merged 10 commits intomixxxdj:masterfrom uklotzde:trackcolor-fix
Conversation
|
Anything else to do? Because these extensions will be needed for the cue color work. |
|
@Holzhaus Switching the typedef of the internal code from quint32 to QRgb will hopefully improve compatibility with Qt code. |
|
To avoid spreading the control value conversions all over the place I have added the required functions and tests. Not sure about the placement and naming of the corresponding header file, but this can easily be adjusted later as needed. |
Holzhaus
left a comment
There was a problem hiding this comment.
Builds find and tests pass. Waiting for CI builds.
|
|
||
| namespace control { | ||
|
|
||
| typedef double value_t; |
There was a problem hiding this comment.
Why the typedef? Is this supposed to replace all occurrences of double for CO signals/slots? If not I'd remove this and and rename the functions below to doubleFromRgbColor, because this would be confusing IMHO.
There was a problem hiding this comment.
No, you don't need to use it.
I was aiming for clean code, at least within this header file. Hard-coding primitive types into the domain layer is usually not desirable. Type aliases don't provide any type safety, so this is just a zero-cost semantic abstraction on the source code level.
But if it is confusing in contrast to the large amount of legacy code I will remove it.
There was a problem hiding this comment.
These are not arbitrary double values, they have a special semantic in the context of control values. The standalone function name doubleFromRgbColor() is therefore slightly misleading. But if it is invoked as control::doubleFromRgbColor() the correlation might be obvious enough.
|
@Holzhaus Ready |
Holzhaus
left a comment
There was a problem hiding this comment.
Thank you. Very handy indeed. Code looks good and tests pass. LGTM.
|
CI builds pass, I'll merge this. |
Add reusable functions for formatting colors as strings.
The tests verify that an optional/invalid color produces an empty null string which is not the case for
QColor().name().Update: