Contains all significant parameters which control the appearance of a working set icon
| 23 | |
| 24 | /// Contains all significant parameters which control the appearance of a working set icon |
| 25 | struct WorkingSetIconParameters { |
| 26 | explicit WorkingSetIconParameters(const QString& id) |
| 27 | : setId(qHash(id) % 268435459) |
| 28 | , coloredCount((setId % 15 < 4) ? 1 : (setId % 15 < 10) ? 2 : (setId % 15 == 14) ? 4 : 3) |
| 29 | , hue((setId % 273 * 83) % 360) |
| 30 | , swapDiagonal(setId % 31 < 16) |
| 31 | { }; |
| 32 | // calculate layout and colors depending on the working set ID |
| 33 | // modulo it so it's around 2^28, leaving some space before uint overflows |
| 34 | const uint setId; |
| 35 | // amount of colored squares in this icon (the rest is grey or whatever you set as default color) |
| 36 | // use 4-6-4-1 weighting for 1, 2, 3, 4 squares, because that's the number of arrangements for each |
| 37 | const uint coloredCount; |
| 38 | const uint hue; |
| 39 | bool swapDiagonal; |
| 40 | // between 0 and 100, 100 = very similar, 0 = very different |
| 41 | // 20 points should make a significantly different icon. |
| 42 | uint similarity(const WorkingSetIconParameters& other) const { |
| 43 | int sim = 100; |
| 44 | uint hueDiff = qAbs<int>(hue - other.hue); |
| 45 | hueDiff = hueDiff > 180 ? 360 - hueDiff : hueDiff; |
| 46 | sim -= hueDiff > 35 ? 50 : (hueDiff * 50) / 180; |
| 47 | if ( coloredCount != other.coloredCount ) { |
| 48 | sim -= 50; |
| 49 | } |
| 50 | else if ( coloredCount == 2 && swapDiagonal != other.swapDiagonal ) { |
| 51 | sim -= 35; |
| 52 | } |
| 53 | return sim; |
| 54 | }; |
| 55 | }; |
| 56 | |
| 57 | |
| 58 | class WorkingSet : public QObject { |
no outgoing calls
no test coverage detected