| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qpalette.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | static int qt_palette_count = 1; | - | ||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | class QPalettePrivate { | - | ||||||||||||||||||
| 7 | public: | - | ||||||||||||||||||
| 8 | QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { } never executed: end of block | 0 | ||||||||||||||||||
| 9 | QAtomicInt ref; | - | ||||||||||||||||||
| 10 | QBrush br[QPalette::NColorGroups][QPalette::NColorRoles]; | - | ||||||||||||||||||
| 11 | int ser_no; | - | ||||||||||||||||||
| 12 | int detach_no; | - | ||||||||||||||||||
| 13 | }; | - | ||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | static QColor qt_mix_colors(QColor a, QColor b) | - | ||||||||||||||||||
| 16 | { | - | ||||||||||||||||||
| 17 | return never executed: QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2, (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);never executed: return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2, (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2); | 0 | ||||||||||||||||||
| 18 | (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2); never executed: return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2, (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2); | 0 | ||||||||||||||||||
| 19 | } | - | ||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | static void qt_palette_from_color(QPalette &pal, const QColor &button) | - | ||||||||||||||||||
| 22 | { | - | ||||||||||||||||||
| 23 | int h, s, v; | - | ||||||||||||||||||
| 24 | button.getHsv(&h, &s, &v); | - | ||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | const QBrush whiteBrush = QBrush(Qt::white); | - | ||||||||||||||||||
| 27 | const QBrush blackBrush = QBrush(Qt::black); | - | ||||||||||||||||||
| 28 | const QBrush baseBrush = v > 128
| 0 | ||||||||||||||||||
| 29 | const QBrush foregroundBrush = v > 128
| 0 | ||||||||||||||||||
| 30 | const QBrush buttonBrush = QBrush(button); | - | ||||||||||||||||||
| 31 | const QBrush buttonBrushDark = QBrush(button.darker()); | - | ||||||||||||||||||
| 32 | const QBrush buttonBrushDark150 = QBrush(button.darker(150)); | - | ||||||||||||||||||
| 33 | const QBrush buttonBrushLight150 = QBrush(button.lighter(150)); | - | ||||||||||||||||||
| 34 | pal.setColorGroup(QPalette::Active, foregroundBrush, buttonBrush, buttonBrushLight150, | - | ||||||||||||||||||
| 35 | buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush, | - | ||||||||||||||||||
| 36 | baseBrush, buttonBrush); | - | ||||||||||||||||||
| 37 | pal.setColorGroup(QPalette::Inactive, foregroundBrush, buttonBrush, buttonBrushLight150, | - | ||||||||||||||||||
| 38 | buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush, | - | ||||||||||||||||||
| 39 | baseBrush, buttonBrush); | - | ||||||||||||||||||
| 40 | pal.setColorGroup(QPalette::Disabled, buttonBrushDark, buttonBrush, buttonBrushLight150, | - | ||||||||||||||||||
| 41 | buttonBrushDark, buttonBrushDark150, buttonBrushDark, | - | ||||||||||||||||||
| 42 | whiteBrush, buttonBrush, buttonBrush); | - | ||||||||||||||||||
| 43 | } never executed: end of block | 0 | ||||||||||||||||||
| 44 | QPalette::QPalette() | - | ||||||||||||||||||
| 45 | : d(0) | - | ||||||||||||||||||
| 46 | { | - | ||||||||||||||||||
| 47 | data.current_group = Active; | - | ||||||||||||||||||
| 48 | data.resolve_mask = 0; | - | ||||||||||||||||||
| 49 | - | |||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | - | |||||||||||||||||||
| 52 | if (QGuiApplicationPrivate::app_pal
| 0 | ||||||||||||||||||
| 53 | d = QGuiApplicationPrivate::app_pal->d; | - | ||||||||||||||||||
| 54 | d->ref.ref(); | - | ||||||||||||||||||
| 55 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 56 | init(); | - | ||||||||||||||||||
| 57 | qt_palette_from_color(*this, Qt::black); | - | ||||||||||||||||||
| 58 | data.resolve_mask = 0; | - | ||||||||||||||||||
| 59 | } never executed: end of block | 0 | ||||||||||||||||||
| 60 | } | - | ||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | - | |||||||||||||||||||
| 65 | - | |||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | QPalette::QPalette(const QColor &button) | - | ||||||||||||||||||
| 68 | { | - | ||||||||||||||||||
| 69 | init(); | - | ||||||||||||||||||
| 70 | qt_palette_from_color(*this, button); | - | ||||||||||||||||||
| 71 | } never executed: end of block | 0 | ||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | - | |||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | - | |||||||||||||||||||
| 76 | - | |||||||||||||||||||
| 77 | - | |||||||||||||||||||
| 78 | QPalette::QPalette(Qt::GlobalColor button) | - | ||||||||||||||||||
| 79 | { | - | ||||||||||||||||||
| 80 | init(); | - | ||||||||||||||||||
| 81 | qt_palette_from_color(*this, button); | - | ||||||||||||||||||
| 82 | } never executed: end of block | 0 | ||||||||||||||||||
| 83 | QPalette::QPalette(const QBrush &windowText, const QBrush &button, | - | ||||||||||||||||||
| 84 | const QBrush &light, const QBrush &dark, | - | ||||||||||||||||||
| 85 | const QBrush &mid, const QBrush &text, | - | ||||||||||||||||||
| 86 | const QBrush &bright_text, const QBrush &base, | - | ||||||||||||||||||
| 87 | const QBrush &window) | - | ||||||||||||||||||
| 88 | { | - | ||||||||||||||||||
| 89 | init(); | - | ||||||||||||||||||
| 90 | setColorGroup(All, windowText, button, light, dark, mid, text, bright_text, | - | ||||||||||||||||||
| 91 | base, window); | - | ||||||||||||||||||
| 92 | } never executed: end of block | 0 | ||||||||||||||||||
| 93 | QPalette::QPalette(const QColor &windowText, const QColor &window, | - | ||||||||||||||||||
| 94 | const QColor &light, const QColor &dark, const QColor &mid, | - | ||||||||||||||||||
| 95 | const QColor &text, const QColor &base) | - | ||||||||||||||||||
| 96 | { | - | ||||||||||||||||||
| 97 | init(); | - | ||||||||||||||||||
| 98 | const QBrush windowBrush(window); | - | ||||||||||||||||||
| 99 | const QBrush lightBrush(light); | - | ||||||||||||||||||
| 100 | setColorGroup(All, QBrush(windowText), windowBrush, lightBrush, | - | ||||||||||||||||||
| 101 | QBrush(dark), QBrush(mid), QBrush(text), lightBrush, | - | ||||||||||||||||||
| 102 | QBrush(base), windowBrush); | - | ||||||||||||||||||
| 103 | } never executed: end of block | 0 | ||||||||||||||||||
| 104 | - | |||||||||||||||||||
| 105 | - | |||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | QPalette::QPalette(const QColor &button, const QColor &window) | - | ||||||||||||||||||
| 111 | { | - | ||||||||||||||||||
| 112 | init(); | - | ||||||||||||||||||
| 113 | int h, s, v; | - | ||||||||||||||||||
| 114 | window.getHsv(&h, &s, &v); | - | ||||||||||||||||||
| 115 | - | |||||||||||||||||||
| 116 | const QBrush windowBrush = QBrush(window); | - | ||||||||||||||||||
| 117 | const QBrush whiteBrush = QBrush(Qt::white); | - | ||||||||||||||||||
| 118 | const QBrush blackBrush = QBrush(Qt::black); | - | ||||||||||||||||||
| 119 | const QBrush baseBrush = v > 128
| 0 | ||||||||||||||||||
| 120 | const QBrush foregroundBrush = v > 128
| 0 | ||||||||||||||||||
| 121 | const QBrush disabledForeground = QBrush(Qt::darkGray); | - | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | const QBrush buttonBrush = QBrush(button); | - | ||||||||||||||||||
| 124 | const QBrush buttonBrushDark = QBrush(button.darker()); | - | ||||||||||||||||||
| 125 | const QBrush buttonBrushDark150 = QBrush(button.darker(150)); | - | ||||||||||||||||||
| 126 | const QBrush buttonBrushLight150 = QBrush(button.lighter(150)); | - | ||||||||||||||||||
| 127 | - | |||||||||||||||||||
| 128 | - | |||||||||||||||||||
| 129 | setColorGroup(Inactive, foregroundBrush, buttonBrush, buttonBrushLight150, buttonBrushDark, | - | ||||||||||||||||||
| 130 | buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush, | - | ||||||||||||||||||
| 131 | windowBrush); | - | ||||||||||||||||||
| 132 | setColorGroup(Active, foregroundBrush, buttonBrush, buttonBrushLight150, buttonBrushDark, | - | ||||||||||||||||||
| 133 | buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush, | - | ||||||||||||||||||
| 134 | windowBrush); | - | ||||||||||||||||||
| 135 | setColorGroup(Disabled, disabledForeground, buttonBrush, buttonBrushLight150, | - | ||||||||||||||||||
| 136 | buttonBrushDark, buttonBrushDark150, disabledForeground, | - | ||||||||||||||||||
| 137 | whiteBrush, baseBrush, windowBrush); | - | ||||||||||||||||||
| 138 | } never executed: end of block | 0 | ||||||||||||||||||
| 139 | - | |||||||||||||||||||
| 140 | - | |||||||||||||||||||
| 141 | - | |||||||||||||||||||
| 142 | - | |||||||||||||||||||
| 143 | - | |||||||||||||||||||
| 144 | - | |||||||||||||||||||
| 145 | QPalette::QPalette(const QPalette &p) | - | ||||||||||||||||||
| 146 | : d(p.d), data(p.data) | - | ||||||||||||||||||
| 147 | { | - | ||||||||||||||||||
| 148 | d->ref.ref(); | - | ||||||||||||||||||
| 149 | } never executed: end of block | 0 | ||||||||||||||||||
| 150 | QPalette::~QPalette() | - | ||||||||||||||||||
| 151 | { | - | ||||||||||||||||||
| 152 | if (d
| 0 | ||||||||||||||||||
| 153 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 154 | } never executed: end of block | 0 | ||||||||||||||||||
| 155 | - | |||||||||||||||||||
| 156 | - | |||||||||||||||||||
| 157 | void QPalette::init() { | - | ||||||||||||||||||
| 158 | d = new QPalettePrivate; | - | ||||||||||||||||||
| 159 | data.resolve_mask = 0; | - | ||||||||||||||||||
| 160 | data.current_group = Active; | - | ||||||||||||||||||
| 161 | } never executed: end of block | 0 | ||||||||||||||||||
| 162 | - | |||||||||||||||||||
| 163 | - | |||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | QPalette &QPalette::operator=(const QPalette &p) | - | ||||||||||||||||||
| 170 | { | - | ||||||||||||||||||
| 171 | p.d->ref.ref(); | - | ||||||||||||||||||
| 172 | data = p.data; | - | ||||||||||||||||||
| 173 | if (d
| 0 | ||||||||||||||||||
| 174 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 175 | d = p.d; | - | ||||||||||||||||||
| 176 | return never executed: *this;return *this;never executed: return *this; | 0 | ||||||||||||||||||
| 177 | } | - | ||||||||||||||||||
| 178 | QPalette::operator QVariant() const | - | ||||||||||||||||||
| 179 | { | - | ||||||||||||||||||
| 180 | return never executed: QVariant(QVariant::Palette, this);return QVariant(QVariant::Palette, this);never executed: return QVariant(QVariant::Palette, this); | 0 | ||||||||||||||||||
| 181 | } | - | ||||||||||||||||||
| 182 | const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const | - | ||||||||||||||||||
| 183 | { | - | ||||||||||||||||||
| 184 | ((!(cr < NColorRoles)) ? qt_assert("cr < NColorRoles",__FILE__,721) : qt_noop()); | - | ||||||||||||||||||
| 185 | if(gr >= (int)NColorGroups
| 0 | ||||||||||||||||||
| 186 | if(gr == Current
| 0 | ||||||||||||||||||
| 187 | gr = (ColorGroup)data.current_group; | - | ||||||||||||||||||
| 188 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 189 | QMessageLogger(__FILE__, 726, __PRETTY_FUNCTION__).warning("QPalette::brush: Unknown ColorGroup: %d", (int)gr); | - | ||||||||||||||||||
| 190 | gr = Active; | - | ||||||||||||||||||
| 191 | } never executed: end of block | 0 | ||||||||||||||||||
| 192 | } | - | ||||||||||||||||||
| 193 | return never executed: d->br[gr][cr];return d->br[gr][cr];never executed: return d->br[gr][cr]; | 0 | ||||||||||||||||||
| 194 | } | - | ||||||||||||||||||
| 195 | void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) | - | ||||||||||||||||||
| 196 | { | - | ||||||||||||||||||
| 197 | ((!(cr < NColorRoles)) ? qt_assert("cr < NColorRoles",__FILE__,753) : qt_noop()); | - | ||||||||||||||||||
| 198 | detach(); | - | ||||||||||||||||||
| 199 | if(cg >= (int)NColorGroups
| 0 | ||||||||||||||||||
| 200 | if(cg == All
| 0 | ||||||||||||||||||
| 201 | for(int i = 0; i < (int)NColorGroups
| 0 | ||||||||||||||||||
| 202 | d->br[i][cr] = b; never executed: d->br[i][cr] = b; | 0 | ||||||||||||||||||
| 203 | data.resolve_mask |= (1<<cr); | - | ||||||||||||||||||
| 204 | return; never executed: return; | 0 | ||||||||||||||||||
| 205 | } else if(cg == Current
| 0 | ||||||||||||||||||
| 206 | cg = (ColorGroup)data.current_group; | - | ||||||||||||||||||
| 207 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 208 | QMessageLogger(__FILE__, 764, __PRETTY_FUNCTION__).warning("QPalette::setBrush: Unknown ColorGroup: %d", (int)cg); | - | ||||||||||||||||||
| 209 | cg = Active; | - | ||||||||||||||||||
| 210 | } never executed: end of block | 0 | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | d->br[cg][cr] = b; | - | ||||||||||||||||||
| 213 | data.resolve_mask |= (1<<cr); | - | ||||||||||||||||||
| 214 | } never executed: end of block | 0 | ||||||||||||||||||
| 215 | bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const | - | ||||||||||||||||||
| 216 | { | - | ||||||||||||||||||
| 217 | (void)cg;; | - | ||||||||||||||||||
| 218 | return never executed: (data.resolve_mask & (1<<cr));return (data.resolve_mask & (1<<cr));never executed: return (data.resolve_mask & (1<<cr)); | 0 | ||||||||||||||||||
| 219 | } | - | ||||||||||||||||||
| 220 | - | |||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | - | |||||||||||||||||||
| 223 | - | |||||||||||||||||||
| 224 | void QPalette::detach() | - | ||||||||||||||||||
| 225 | { | - | ||||||||||||||||||
| 226 | if (d->ref.load() != 1
| 0 | ||||||||||||||||||
| 227 | QPalettePrivate *x = new QPalettePrivate; | - | ||||||||||||||||||
| 228 | for(int grp = 0; grp < (int)NColorGroups
| 0 | ||||||||||||||||||
| 229 | for(int role = 0; role < (int)NColorRoles
| 0 | ||||||||||||||||||
| 230 | x->br[grp][role] = d->br[grp][role]; never executed: x->br[grp][role] = d->br[grp][role]; | 0 | ||||||||||||||||||
| 231 | } never executed: end of block | 0 | ||||||||||||||||||
| 232 | if(!d->ref.deref()
| 0 | ||||||||||||||||||
| 233 | delete d; never executed: delete d; | 0 | ||||||||||||||||||
| 234 | d = x; | - | ||||||||||||||||||
| 235 | } never executed: end of block | 0 | ||||||||||||||||||
| 236 | ++d->detach_no; | - | ||||||||||||||||||
| 237 | } never executed: end of block | 0 | ||||||||||||||||||
| 238 | bool QPalette::operator==(const QPalette &p) const | - | ||||||||||||||||||
| 239 | { | - | ||||||||||||||||||
| 240 | if (isCopyOf(p)
| 0 | ||||||||||||||||||
| 241 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 242 | for(int grp = 0; grp < (int)NColorGroups
| 0 | ||||||||||||||||||
| 243 | for(int role = 0; role < (int)NColorRoles
| 0 | ||||||||||||||||||
| 244 | if(d->br[grp][role] != p.d->br[grp][role]
| 0 | ||||||||||||||||||
| 245 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 246 | } never executed: end of block | 0 | ||||||||||||||||||
| 247 | } never executed: end of block | 0 | ||||||||||||||||||
| 248 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 249 | } | - | ||||||||||||||||||
| 250 | - | |||||||||||||||||||
| 251 | - | |||||||||||||||||||
| 252 | - | |||||||||||||||||||
| 253 | - | |||||||||||||||||||
| 254 | - | |||||||||||||||||||
| 255 | - | |||||||||||||||||||
| 256 | - | |||||||||||||||||||
| 257 | bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) const | - | ||||||||||||||||||
| 258 | { | - | ||||||||||||||||||
| 259 | if(group1 >= (int)NColorGroups
| 0 | ||||||||||||||||||
| 260 | if(group1 == Current
| 0 | ||||||||||||||||||
| 261 | group1 = (ColorGroup)data.current_group; | - | ||||||||||||||||||
| 262 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 263 | QMessageLogger(__FILE__, 850, __PRETTY_FUNCTION__).warning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1); | - | ||||||||||||||||||
| 264 | group1 = Active; | - | ||||||||||||||||||
| 265 | } never executed: end of block | 0 | ||||||||||||||||||
| 266 | } | - | ||||||||||||||||||
| 267 | if(group2 >= (int)NColorGroups
| 0 | ||||||||||||||||||
| 268 | if(group2 == Current
| 0 | ||||||||||||||||||
| 269 | group2 = (ColorGroup)data.current_group; | - | ||||||||||||||||||
| 270 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 271 | QMessageLogger(__FILE__, 858, __PRETTY_FUNCTION__).warning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2); | - | ||||||||||||||||||
| 272 | group2 = Active; | - | ||||||||||||||||||
| 273 | } never executed: end of block | 0 | ||||||||||||||||||
| 274 | } | - | ||||||||||||||||||
| 275 | if(group1 == group2
| 0 | ||||||||||||||||||
| 276 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 277 | for(int role = 0; role < (int)NColorRoles
| 0 | ||||||||||||||||||
| 278 | if(d->br[group1][role] != d->br[group2][role]
| 0 | ||||||||||||||||||
| 279 | return never executed: false;return false;never executed: return false; | 0 | ||||||||||||||||||
| 280 | } never executed: end of block | 0 | ||||||||||||||||||
| 281 | return never executed: true;return true;never executed: return true; | 0 | ||||||||||||||||||
| 282 | } | - | ||||||||||||||||||
| 283 | qint64 QPalette::cacheKey() const | - | ||||||||||||||||||
| 284 | { | - | ||||||||||||||||||
| 285 | return never executed: (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no));return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no));never executed: return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no)); | 0 | ||||||||||||||||||
| 286 | } | - | ||||||||||||||||||
| 287 | - | |||||||||||||||||||
| 288 | - | |||||||||||||||||||
| 289 | - | |||||||||||||||||||
| 290 | - | |||||||||||||||||||
| 291 | QPalette QPalette::resolve(const QPalette &other) const | - | ||||||||||||||||||
| 292 | { | - | ||||||||||||||||||
| 293 | if ((*
| 0 | ||||||||||||||||||
| 294 | || data.resolve_mask == 0
| 0 | ||||||||||||||||||
| 295 | QPalette o = other; | - | ||||||||||||||||||
| 296 | o.data.resolve_mask = data.resolve_mask; | - | ||||||||||||||||||
| 297 | return never executed: o;return o;never executed: return o; | 0 | ||||||||||||||||||
| 298 | } | - | ||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | QPalette palette(*this); | - | ||||||||||||||||||
| 301 | palette.detach(); | - | ||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | for(int role = 0; role < (int)NColorRoles
| 0 | ||||||||||||||||||
| 304 | if (!(data.resolve_mask & (1<<role))
| 0 | ||||||||||||||||||
| 305 | for(int grp = 0; grp < (int)NColorGroups
| 0 | ||||||||||||||||||
| 306 | palette.d->br[grp][role] = other.d->br[grp][role]; never executed: palette.d->br[grp][role] = other.d->br[grp][role]; | 0 | ||||||||||||||||||
| 307 | - | |||||||||||||||||||
| 308 | return never executed: palette;return palette;never executed: return palette; | 0 | ||||||||||||||||||
| 309 | } | - | ||||||||||||||||||
| 310 | static const int NumOldRoles = 7; | - | ||||||||||||||||||
| 311 | static const int oldRoles[7] = { QPalette::Foreground, QPalette::Background, QPalette::Light, | - | ||||||||||||||||||
| 312 | QPalette::Dark, QPalette::Mid, QPalette::Text, QPalette::Base }; | - | ||||||||||||||||||
| 313 | QDataStream &operator<<(QDataStream &s, const QPalette &p) | - | ||||||||||||||||||
| 314 | { | - | ||||||||||||||||||
| 315 | for (int grp = 0; grp < (int)QPalette::NColorGroups
| 0 | ||||||||||||||||||
| 316 | if (s.version() == 1
| 0 | ||||||||||||||||||
| 317 | - | |||||||||||||||||||
| 318 | for (int i = 0; i < NumOldRoles
| 0 | ||||||||||||||||||
| 319 | s << p.d->br[grp][oldRoles[i]].color(); never executed: s << p.d->br[grp][oldRoles[i]].color(); | 0 | ||||||||||||||||||
| 320 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 321 | int max = QPalette::ToolTipText + 1; | - | ||||||||||||||||||
| 322 | if (s.version() <= QDataStream::Qt_2_1
| 0 | ||||||||||||||||||
| 323 | max = QPalette::HighlightedText + 1; never executed: max = QPalette::HighlightedText + 1; | 0 | ||||||||||||||||||
| 324 | else if (s.version() <= QDataStream::Qt_4_3
| 0 | ||||||||||||||||||
| 325 | max = QPalette::AlternateBase + 1; never executed: max = QPalette::AlternateBase + 1; | 0 | ||||||||||||||||||
| 326 | for (int r = 0; r < max
| 0 | ||||||||||||||||||
| 327 | s << p.d->br[grp][r]; never executed: s << p.d->br[grp][r]; | 0 | ||||||||||||||||||
| 328 | } never executed: end of block | 0 | ||||||||||||||||||
| 329 | } | - | ||||||||||||||||||
| 330 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||||||||
| 331 | } | - | ||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp) | - | ||||||||||||||||||
| 334 | { | - | ||||||||||||||||||
| 335 | for (int i = 0; i < NumOldRoles
| 0 | ||||||||||||||||||
| 336 | QColor col; | - | ||||||||||||||||||
| 337 | s >> col; | - | ||||||||||||||||||
| 338 | pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col); | - | ||||||||||||||||||
| 339 | } never executed: end of block | 0 | ||||||||||||||||||
| 340 | } never executed: end of block | 0 | ||||||||||||||||||
| 341 | QDataStream &operator>>(QDataStream &s, QPalette &p) | - | ||||||||||||||||||
| 342 | { | - | ||||||||||||||||||
| 343 | if(s.version() == 1
| 0 | ||||||||||||||||||
| 344 | p = QPalette(); | - | ||||||||||||||||||
| 345 | readV1ColorGroup(s, p, QPalette::Active); | - | ||||||||||||||||||
| 346 | readV1ColorGroup(s, p, QPalette::Disabled); | - | ||||||||||||||||||
| 347 | readV1ColorGroup(s, p, QPalette::Inactive); | - | ||||||||||||||||||
| 348 | } never executed: else {end of block | 0 | ||||||||||||||||||
| 349 | int max = QPalette::NColorRoles; | - | ||||||||||||||||||
| 350 | if (s.version() <= QDataStream::Qt_2_1
| 0 | ||||||||||||||||||
| 351 | p = QPalette(); | - | ||||||||||||||||||
| 352 | max = QPalette::HighlightedText + 1; | - | ||||||||||||||||||
| 353 | } never executed: else if (s.version() <= QDataStream::Qt_4_3end of block
| 0 | ||||||||||||||||||
| 354 | p = QPalette(); | - | ||||||||||||||||||
| 355 | max = QPalette::AlternateBase + 1; | - | ||||||||||||||||||
| 356 | } never executed: end of block | 0 | ||||||||||||||||||
| 357 | - | |||||||||||||||||||
| 358 | QBrush tmp; | - | ||||||||||||||||||
| 359 | for(int grp = 0; grp < (int)QPalette::NColorGroups
| 0 | ||||||||||||||||||
| 360 | for(int role = 0; role < max
| 0 | ||||||||||||||||||
| 361 | s >> tmp; | - | ||||||||||||||||||
| 362 | p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp); | - | ||||||||||||||||||
| 363 | } never executed: end of block | 0 | ||||||||||||||||||
| 364 | } never executed: end of block | 0 | ||||||||||||||||||
| 365 | } never executed: end of block | 0 | ||||||||||||||||||
| 366 | return never executed: s;return s;never executed: return s; | 0 | ||||||||||||||||||
| 367 | } | - | ||||||||||||||||||
| 368 | bool QPalette::isCopyOf(const QPalette &p) const | - | ||||||||||||||||||
| 369 | { | - | ||||||||||||||||||
| 370 | return never executed: d == p.d;return d == p.d;never executed: return d == p.d; | 0 | ||||||||||||||||||
| 371 | } | - | ||||||||||||||||||
| 372 | void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBrush &button, | - | ||||||||||||||||||
| 373 | const QBrush &light, const QBrush &dark, const QBrush &mid, | - | ||||||||||||||||||
| 374 | const QBrush &text, const QBrush &bright_text, const QBrush &base, | - | ||||||||||||||||||
| 375 | const QBrush &window) | - | ||||||||||||||||||
| 376 | { | - | ||||||||||||||||||
| 377 | QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color())); | - | ||||||||||||||||||
| 378 | QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color())); | - | ||||||||||||||||||
| 379 | QColor toolTipBase(255, 255, 220); | - | ||||||||||||||||||
| 380 | QColor toolTipText(0, 0, 0); | - | ||||||||||||||||||
| 381 | - | |||||||||||||||||||
| 382 | setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base, | - | ||||||||||||||||||
| 383 | alt_base, window, mid_light, text, | - | ||||||||||||||||||
| 384 | QBrush(Qt::black), QBrush(Qt::darkBlue), QBrush(Qt::white), | - | ||||||||||||||||||
| 385 | QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase), | - | ||||||||||||||||||
| 386 | QBrush(toolTipText)); | - | ||||||||||||||||||
| 387 | - | |||||||||||||||||||
| 388 | data.resolve_mask &= ~(1 << Highlight); | - | ||||||||||||||||||
| 389 | data.resolve_mask &= ~(1 << HighlightedText); | - | ||||||||||||||||||
| 390 | data.resolve_mask &= ~(1 << LinkVisited); | - | ||||||||||||||||||
| 391 | data.resolve_mask &= ~(1 << Link); | - | ||||||||||||||||||
| 392 | } never executed: end of block | 0 | ||||||||||||||||||
| 393 | - | |||||||||||||||||||
| 394 | - | |||||||||||||||||||
| 395 | - | |||||||||||||||||||
| 396 | void | - | ||||||||||||||||||
| 397 | QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button, | - | ||||||||||||||||||
| 398 | const QBrush &light, const QBrush &dark, const QBrush &mid, | - | ||||||||||||||||||
| 399 | const QBrush &text, const QBrush &bright_text, | - | ||||||||||||||||||
| 400 | const QBrush &base, const QBrush &alternate_base, | - | ||||||||||||||||||
| 401 | const QBrush &background, const QBrush &midlight, | - | ||||||||||||||||||
| 402 | const QBrush &button_text, const QBrush &shadow, | - | ||||||||||||||||||
| 403 | const QBrush &highlight, const QBrush &highlighted_text, | - | ||||||||||||||||||
| 404 | const QBrush &link, const QBrush &link_visited) | - | ||||||||||||||||||
| 405 | { | - | ||||||||||||||||||
| 406 | setColorGroup(cg, foreground, button, light, dark, mid, | - | ||||||||||||||||||
| 407 | text, bright_text, base, alternate_base, background, | - | ||||||||||||||||||
| 408 | midlight, button_text, shadow, highlight, highlighted_text, | - | ||||||||||||||||||
| 409 | link, link_visited, background, foreground); | - | ||||||||||||||||||
| 410 | } never executed: end of block | 0 | ||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button, | - | ||||||||||||||||||
| 414 | const QBrush &light, const QBrush &dark, const QBrush &mid, | - | ||||||||||||||||||
| 415 | const QBrush &text, const QBrush &bright_text, | - | ||||||||||||||||||
| 416 | const QBrush &base, const QBrush &alternate_base, | - | ||||||||||||||||||
| 417 | const QBrush &background, const QBrush &midlight, | - | ||||||||||||||||||
| 418 | const QBrush &button_text, const QBrush &shadow, | - | ||||||||||||||||||
| 419 | const QBrush &highlight, const QBrush &highlighted_text, | - | ||||||||||||||||||
| 420 | const QBrush &link, const QBrush &link_visited, | - | ||||||||||||||||||
| 421 | const QBrush &toolTipBase, const QBrush &toolTipText) | - | ||||||||||||||||||
| 422 | { | - | ||||||||||||||||||
| 423 | detach(); | - | ||||||||||||||||||
| 424 | setBrush(cg, WindowText, foreground); | - | ||||||||||||||||||
| 425 | setBrush(cg, Button, button); | - | ||||||||||||||||||
| 426 | setBrush(cg, Light, light); | - | ||||||||||||||||||
| 427 | setBrush(cg, Dark, dark); | - | ||||||||||||||||||
| 428 | setBrush(cg, Mid, mid); | - | ||||||||||||||||||
| 429 | setBrush(cg, Text, text); | - | ||||||||||||||||||
| 430 | setBrush(cg, BrightText, bright_text); | - | ||||||||||||||||||
| 431 | setBrush(cg, Base, base); | - | ||||||||||||||||||
| 432 | setBrush(cg, AlternateBase, alternate_base); | - | ||||||||||||||||||
| 433 | setBrush(cg, Window, background); | - | ||||||||||||||||||
| 434 | setBrush(cg, Midlight, midlight); | - | ||||||||||||||||||
| 435 | setBrush(cg, ButtonText, button_text); | - | ||||||||||||||||||
| 436 | setBrush(cg, Shadow, shadow); | - | ||||||||||||||||||
| 437 | setBrush(cg, Highlight, highlight); | - | ||||||||||||||||||
| 438 | setBrush(cg, HighlightedText, highlighted_text); | - | ||||||||||||||||||
| 439 | setBrush(cg, Link, link); | - | ||||||||||||||||||
| 440 | setBrush(cg, LinkVisited, link_visited); | - | ||||||||||||||||||
| 441 | setBrush(cg, ToolTipBase, toolTipBase); | - | ||||||||||||||||||
| 442 | setBrush(cg, ToolTipText, toolTipText); | - | ||||||||||||||||||
| 443 | } never executed: end of block | 0 | ||||||||||||||||||
| 444 | - | |||||||||||||||||||
| 445 | __attribute__((visibility("default"))) QPalette qt_fusionPalette() | - | ||||||||||||||||||
| 446 | { | - | ||||||||||||||||||
| 447 | QColor backGround(239, 235, 231); | - | ||||||||||||||||||
| 448 | QColor light = backGround.lighter(150); | - | ||||||||||||||||||
| 449 | QColor mid(backGround.darker(130)); | - | ||||||||||||||||||
| 450 | QColor midLight = mid.lighter(110); | - | ||||||||||||||||||
| 451 | QColor base = Qt::white; | - | ||||||||||||||||||
| 452 | QColor disabledBase(backGround); | - | ||||||||||||||||||
| 453 | QColor dark = backGround.darker(150); | - | ||||||||||||||||||
| 454 | QColor darkDisabled = QColor(209, 200, 191).darker(110); | - | ||||||||||||||||||
| 455 | QColor text = Qt::black; | - | ||||||||||||||||||
| 456 | QColor hightlightedText = Qt::white; | - | ||||||||||||||||||
| 457 | QColor disabledText = QColor(190, 190, 190); | - | ||||||||||||||||||
| 458 | QColor button = backGround; | - | ||||||||||||||||||
| 459 | QColor shadow = dark.darker(135); | - | ||||||||||||||||||
| 460 | QColor disabledShadow = shadow.lighter(150); | - | ||||||||||||||||||
| 461 | - | |||||||||||||||||||
| 462 | QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base); | - | ||||||||||||||||||
| 463 | fusionPalette.setBrush(QPalette::Midlight, midLight); | - | ||||||||||||||||||
| 464 | fusionPalette.setBrush(QPalette::Button, button); | - | ||||||||||||||||||
| 465 | fusionPalette.setBrush(QPalette::Shadow, shadow); | - | ||||||||||||||||||
| 466 | fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText); | - | ||||||||||||||||||
| 467 | - | |||||||||||||||||||
| 468 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText); | - | ||||||||||||||||||
| 469 | fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText); | - | ||||||||||||||||||
| 470 | fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText); | - | ||||||||||||||||||
| 471 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase); | - | ||||||||||||||||||
| 472 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); | - | ||||||||||||||||||
| 473 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow); | - | ||||||||||||||||||
| 474 | - | |||||||||||||||||||
| 475 | fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198)); | - | ||||||||||||||||||
| 476 | fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198)); | - | ||||||||||||||||||
| 477 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126)); | - | ||||||||||||||||||
| 478 | return never executed: fusionPalette;return fusionPalette;never executed: return fusionPalette; | 0 | ||||||||||||||||||
| 479 | } | - | ||||||||||||||||||
| 480 | - | |||||||||||||||||||
| 481 | - | |||||||||||||||||||
| 482 | QDebug operator<<(QDebug dbg, const QPalette &p) | - | ||||||||||||||||||
| 483 | { | - | ||||||||||||||||||
| 484 | const char *colorGroupNames[] = {"Active", "Disabled", "Inactive"}; | - | ||||||||||||||||||
| 485 | const char *colorRoleNames[] = | - | ||||||||||||||||||
| 486 | {"WindowText", "Button", "Light", "Midlight", "Dark", "Mid", "Text", | - | ||||||||||||||||||
| 487 | "BrightText", "ButtonText", "Base", "Window", "Shadow", "Highlight", | - | ||||||||||||||||||
| 488 | "HighlightedText", "Link", "LinkVisited", "AlternateBase", "NoRole", | - | ||||||||||||||||||
| 489 | "ToolTipBase","ToolTipText" }; | - | ||||||||||||||||||
| 490 | QDebugStateSaver saver(dbg); | - | ||||||||||||||||||
| 491 | QDebug nospace = dbg.nospace(); | - | ||||||||||||||||||
| 492 | const uint mask = p.resolve(); | - | ||||||||||||||||||
| 493 | nospace << "QPalette(resolve=" << hex << showbase << mask << ','; | - | ||||||||||||||||||
| 494 | for (int role = 0; role < (int)QPalette::NColorRoles
| 0 | ||||||||||||||||||
| 495 | if (mask & (1<<role)
| 0 | ||||||||||||||||||
| 496 | if (role
| 0 | ||||||||||||||||||
| 497 | nospace << ','; never executed: nospace << ','; | 0 | ||||||||||||||||||
| 498 | nospace << colorRoleNames[role] << ":["; | - | ||||||||||||||||||
| 499 | for (int group = 0; group < (int)QPalette::NColorGroups
| 0 | ||||||||||||||||||
| 500 | if (group
| 0 | ||||||||||||||||||
| 501 | nospace << ','; never executed: nospace << ','; | 0 | ||||||||||||||||||
| 502 | const QRgb color = p.color(static_cast<QPalette::ColorGroup>(group), | - | ||||||||||||||||||
| 503 | static_cast<QPalette::ColorRole>(role)).rgba(); | - | ||||||||||||||||||
| 504 | nospace << colorGroupNames[group] << ':' << color; | - | ||||||||||||||||||
| 505 | } never executed: end of block | 0 | ||||||||||||||||||
| 506 | nospace << ']'; | - | ||||||||||||||||||
| 507 | } never executed: end of block | 0 | ||||||||||||||||||
| 508 | } never executed: end of block | 0 | ||||||||||||||||||
| 509 | nospace << ')' << noshowbase << dec; | - | ||||||||||||||||||
| 510 | return never executed: dbg;return dbg;never executed: return dbg; | 0 | ||||||||||||||||||
| 511 | } | - | ||||||||||||||||||
| 512 | - | |||||||||||||||||||
| 513 | - | |||||||||||||||||||
| 514 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |