| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/gui/kernel/qpalette.cpp | 
| Source code | Switch to Preprocessed file | 
| Line | Source | Count | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | /**************************************************************************** | - | ||||||||||||
| 2 | ** | - | ||||||||||||
| 3 | ** Copyright (C) 2016 The Qt Company Ltd. | - | ||||||||||||
| 4 | ** Contact: https://www.qt.io/licensing/ | - | ||||||||||||
| 5 | ** | - | ||||||||||||
| 6 | ** This file is part of the QtGui module of the Qt Toolkit. | - | ||||||||||||
| 7 | ** | - | ||||||||||||
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - | ||||||||||||
| 9 | ** Commercial License Usage | - | ||||||||||||
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - | ||||||||||||
| 11 | ** accordance with the commercial license agreement provided with the | - | ||||||||||||
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - | ||||||||||||
| 13 | ** a written agreement between you and The Qt Company. For licensing terms | - | ||||||||||||
| 14 | ** and conditions see https://www.qt.io/terms-conditions. For further | - | ||||||||||||
| 15 | ** information use the contact form at https://www.qt.io/contact-us. | - | ||||||||||||
| 16 | ** | - | ||||||||||||
| 17 | ** GNU Lesser General Public License Usage | - | ||||||||||||
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - | ||||||||||||
| 19 | ** General Public License version 3 as published by the Free Software | - | ||||||||||||
| 20 | ** Foundation and appearing in the file LICENSE.LGPL3 included in the | - | ||||||||||||
| 21 | ** packaging of this file. Please review the following information to | - | ||||||||||||
| 22 | ** ensure the GNU Lesser General Public License version 3 requirements | - | ||||||||||||
| 23 | ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. | - | ||||||||||||
| 24 | ** | - | ||||||||||||
| 25 | ** GNU General Public License Usage | - | ||||||||||||
| 26 | ** Alternatively, this file may be used under the terms of the GNU | - | ||||||||||||
| 27 | ** General Public License version 2.0 or (at your option) the GNU General | - | ||||||||||||
| 28 | ** Public license version 3 or any later version approved by the KDE Free | - | ||||||||||||
| 29 | ** Qt Foundation. The licenses are as published by the Free Software | - | ||||||||||||
| 30 | ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 | - | ||||||||||||
| 31 | ** included in the packaging of this file. Please review the following | - | ||||||||||||
| 32 | ** information to ensure the GNU General Public License requirements will | - | ||||||||||||
| 33 | ** be met: https://www.gnu.org/licenses/gpl-2.0.html and | - | ||||||||||||
| 34 | ** https://www.gnu.org/licenses/gpl-3.0.html. | - | ||||||||||||
| 35 | ** | - | ||||||||||||
| 36 | ** $QT_END_LICENSE$ | - | ||||||||||||
| 37 | ** | - | ||||||||||||
| 38 | ****************************************************************************/ | - | ||||||||||||
| 39 | - | |||||||||||||
| 40 | #include "qpalette.h" | - | ||||||||||||
| 41 | #include "qguiapplication.h" | - | ||||||||||||
| 42 | #include "qguiapplication_p.h" | - | ||||||||||||
| 43 | #include "qdatastream.h" | - | ||||||||||||
| 44 | #include "qvariant.h" | - | ||||||||||||
| 45 | #include "qdebug.h" | - | ||||||||||||
| 46 | - | |||||||||||||
| 47 | QT_BEGIN_NAMESPACE | - | ||||||||||||
| 48 | - | |||||||||||||
| 49 | static int qt_palette_count = 1; | - | ||||||||||||
| 50 | - | |||||||||||||
| 51 | class QPalettePrivate { | - | ||||||||||||
| 52 | public: | - | ||||||||||||
| 53 | QPalettePrivate() : ref(1), ser_no(qt_palette_count++), detach_no(0) { } never executed:  end of block | 0 | ||||||||||||
| 54 | QAtomicInt ref; | - | ||||||||||||
| 55 | QBrush br[QPalette::NColorGroups][QPalette::NColorRoles]; | - | ||||||||||||
| 56 | int ser_no; | - | ||||||||||||
| 57 | int detach_no; | - | ||||||||||||
| 58 | }; | - | ||||||||||||
| 59 | - | |||||||||||||
| 60 | static QColor qt_mix_colors(QColor a, QColor b) | - | ||||||||||||
| 61 | { | - | ||||||||||||
| 62 | return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 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 | ||||||||||||
| 63 | (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 | ||||||||||||
| 64 | } | - | ||||||||||||
| 65 | - | |||||||||||||
| 66 | static void qt_palette_from_color(QPalette &pal, const QColor &button) | - | ||||||||||||
| 67 | { | - | ||||||||||||
| 68 | int h, s, v; | - | ||||||||||||
| 69 | button.getHsv(&h, &s, &v); | - | ||||||||||||
| 70 | // inactive and active are the same.. | - | ||||||||||||
| 71 | const QBrush whiteBrush = QBrush(Qt::white); | - | ||||||||||||
| 72 | const QBrush blackBrush = QBrush(Qt::black); | - | ||||||||||||
| 73 | const QBrush baseBrush = v > 128 ? whiteBrush : blackBrush; 
 | 0 | ||||||||||||
| 74 | const QBrush foregroundBrush = v > 128 ? blackBrush : whiteBrush; 
 | 0 | ||||||||||||
| 75 | const QBrush buttonBrush = QBrush(button); | - | ||||||||||||
| 76 | const QBrush buttonBrushDark = QBrush(button.darker()); | - | ||||||||||||
| 77 | const QBrush buttonBrushDark150 = QBrush(button.darker(150)); | - | ||||||||||||
| 78 | const QBrush buttonBrushLight150 = QBrush(button.lighter(150)); | - | ||||||||||||
| 79 | pal.setColorGroup(QPalette::Active, foregroundBrush, buttonBrush, buttonBrushLight150, | - | ||||||||||||
| 80 | buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush, | - | ||||||||||||
| 81 | baseBrush, buttonBrush); | - | ||||||||||||
| 82 | pal.setColorGroup(QPalette::Inactive, foregroundBrush, buttonBrush, buttonBrushLight150, | - | ||||||||||||
| 83 | buttonBrushDark, buttonBrushDark150, foregroundBrush, whiteBrush, | - | ||||||||||||
| 84 | baseBrush, buttonBrush); | - | ||||||||||||
| 85 | pal.setColorGroup(QPalette::Disabled, buttonBrushDark, buttonBrush, buttonBrushLight150, | - | ||||||||||||
| 86 | buttonBrushDark, buttonBrushDark150, buttonBrushDark, | - | ||||||||||||
| 87 | whiteBrush, buttonBrush, buttonBrush); | - | ||||||||||||
| 88 | } never executed:  end of block | 0 | ||||||||||||
| 89 | - | |||||||||||||
| 90 | /*! | - | ||||||||||||
| 91 | \fn QPalette &QPalette::operator=(QPalette &&other) | - | ||||||||||||
| 92 | - | |||||||||||||
| 93 | Move-assigns \a other to this QPalette instance. | - | ||||||||||||
| 94 | - | |||||||||||||
| 95 | \since 5.2 | - | ||||||||||||
| 96 | */ | - | ||||||||||||
| 97 | - | |||||||||||||
| 98 | /*! | - | ||||||||||||
| 99 | \fn const QColor &QPalette::color(ColorRole role) const | - | ||||||||||||
| 100 | - | |||||||||||||
| 101 | \overload | - | ||||||||||||
| 102 | - | |||||||||||||
| 103 | Returns the color that has been set for the given color \a role in | - | ||||||||||||
| 104 | the current ColorGroup. | - | ||||||||||||
| 105 | - | |||||||||||||
| 106 | \sa brush(), ColorRole | - | ||||||||||||
| 107 | */ | - | ||||||||||||
| 108 | - | |||||||||||||
| 109 | /*! | - | ||||||||||||
| 110 | \fn const QBrush &QPalette::brush(ColorRole role) const | - | ||||||||||||
| 111 | - | |||||||||||||
| 112 | \overload | - | ||||||||||||
| 113 | - | |||||||||||||
| 114 | Returns the brush that has been set for the given color \a role in | - | ||||||||||||
| 115 | the current ColorGroup. | - | ||||||||||||
| 116 | - | |||||||||||||
| 117 | \sa color(), setBrush(), ColorRole | - | ||||||||||||
| 118 | */ | - | ||||||||||||
| 119 | - | |||||||||||||
| 120 | /*! | - | ||||||||||||
| 121 | \fn void QPalette::setColor(ColorRole role, const QColor &color) | - | ||||||||||||
| 122 | - | |||||||||||||
| 123 | \overload | - | ||||||||||||
| 124 | - | |||||||||||||
| 125 | Sets the color used for the given color \a role, in all color | - | ||||||||||||
| 126 | groups, to the specified solid \a color. | - | ||||||||||||
| 127 | - | |||||||||||||
| 128 | \sa brush(), setColor(), ColorRole | - | ||||||||||||
| 129 | */ | - | ||||||||||||
| 130 | - | |||||||||||||
| 131 | /*! | - | ||||||||||||
| 132 | \fn void QPalette::setBrush(ColorRole role, const QBrush &brush) | - | ||||||||||||
| 133 | - | |||||||||||||
| 134 | Sets the brush for the given color \a role to the specified \a | - | ||||||||||||
| 135 | brush for all groups in the palette. | - | ||||||||||||
| 136 | - | |||||||||||||
| 137 | \sa brush(), setColor(), ColorRole | - | ||||||||||||
| 138 | */ | - | ||||||||||||
| 139 | - | |||||||||||||
| 140 | /*! | - | ||||||||||||
| 141 | \fn const QBrush & QPalette::foreground() const | - | ||||||||||||
| 142 | \obsolete | - | ||||||||||||
| 143 | - | |||||||||||||
| 144 | Use windowText() instead. | - | ||||||||||||
| 145 | */ | - | ||||||||||||
| 146 | - | |||||||||||||
| 147 | /*! | - | ||||||||||||
| 148 | \fn const QBrush & QPalette::windowText() const | - | ||||||||||||
| 149 | - | |||||||||||||
| 150 | Returns the window text (general foreground) brush of the | - | ||||||||||||
| 151 | current color group. | - | ||||||||||||
| 152 | - | |||||||||||||
| 153 | \sa ColorRole, brush() | - | ||||||||||||
| 154 | */ | - | ||||||||||||
| 155 | - | |||||||||||||
| 156 | /*! | - | ||||||||||||
| 157 | \fn const QBrush & QPalette::button() const | - | ||||||||||||
| 158 | - | |||||||||||||
| 159 | Returns the button brush of the current color group. | - | ||||||||||||
| 160 | - | |||||||||||||
| 161 | \sa ColorRole, brush() | - | ||||||||||||
| 162 | */ | - | ||||||||||||
| 163 | - | |||||||||||||
| 164 | /*! | - | ||||||||||||
| 165 | \fn const QBrush & QPalette::light() const | - | ||||||||||||
| 166 | - | |||||||||||||
| 167 | Returns the light brush of the current color group. | - | ||||||||||||
| 168 | - | |||||||||||||
| 169 | \sa ColorRole, brush() | - | ||||||||||||
| 170 | */ | - | ||||||||||||
| 171 | - | |||||||||||||
| 172 | /*! | - | ||||||||||||
| 173 | \fn const QBrush& QPalette::midlight() const | - | ||||||||||||
| 174 | - | |||||||||||||
| 175 | Returns the midlight brush of the current color group. | - | ||||||||||||
| 176 | - | |||||||||||||
| 177 | \sa ColorRole, brush() | - | ||||||||||||
| 178 | */ | - | ||||||||||||
| 179 | - | |||||||||||||
| 180 | /*! | - | ||||||||||||
| 181 | \fn const QBrush & QPalette::dark() const | - | ||||||||||||
| 182 | - | |||||||||||||
| 183 | Returns the dark brush of the current color group. | - | ||||||||||||
| 184 | - | |||||||||||||
| 185 | \sa ColorRole, brush() | - | ||||||||||||
| 186 | */ | - | ||||||||||||
| 187 | - | |||||||||||||
| 188 | /*! | - | ||||||||||||
| 189 | \fn const QBrush & QPalette::mid() const | - | ||||||||||||
| 190 | - | |||||||||||||
| 191 | Returns the mid brush of the current color group. | - | ||||||||||||
| 192 | - | |||||||||||||
| 193 | \sa ColorRole, brush() | - | ||||||||||||
| 194 | */ | - | ||||||||||||
| 195 | - | |||||||||||||
| 196 | /*! | - | ||||||||||||
| 197 | \fn const QBrush & QPalette::text() const | - | ||||||||||||
| 198 | - | |||||||||||||
| 199 | Returns the text foreground brush of the current color group. | - | ||||||||||||
| 200 | - | |||||||||||||
| 201 | \sa ColorRole, brush() | - | ||||||||||||
| 202 | */ | - | ||||||||||||
| 203 | - | |||||||||||||
| 204 | /*! | - | ||||||||||||
| 205 | \fn const QBrush & QPalette::brightText() const | - | ||||||||||||
| 206 | - | |||||||||||||
| 207 | Returns the bright text foreground brush of the current color group. | - | ||||||||||||
| 208 | - | |||||||||||||
| 209 | \sa ColorRole, brush() | - | ||||||||||||
| 210 | */ | - | ||||||||||||
| 211 | - | |||||||||||||
| 212 | /*! | - | ||||||||||||
| 213 | \fn const QBrush & QPalette::buttonText() const | - | ||||||||||||
| 214 | - | |||||||||||||
| 215 | Returns the button text foreground brush of the current color group. | - | ||||||||||||
| 216 | - | |||||||||||||
| 217 | \sa ColorRole, brush() | - | ||||||||||||
| 218 | */ | - | ||||||||||||
| 219 | - | |||||||||||||
| 220 | /*! | - | ||||||||||||
| 221 | \fn const QBrush & QPalette::base() const | - | ||||||||||||
| 222 | - | |||||||||||||
| 223 | Returns the base brush of the current color group. | - | ||||||||||||
| 224 | - | |||||||||||||
| 225 | \sa ColorRole, brush() | - | ||||||||||||
| 226 | */ | - | ||||||||||||
| 227 | - | |||||||||||||
| 228 | /*! | - | ||||||||||||
| 229 | \fn const QBrush & QPalette::alternateBase() const | - | ||||||||||||
| 230 | - | |||||||||||||
| 231 | Returns the alternate base brush of the current color group. | - | ||||||||||||
| 232 | - | |||||||||||||
| 233 | \sa ColorRole, brush() | - | ||||||||||||
| 234 | */ | - | ||||||||||||
| 235 | - | |||||||||||||
| 236 | /*! | - | ||||||||||||
| 237 | \fn const QBrush & QPalette::toolTipBase() const | - | ||||||||||||
| 238 | \since 4.4 | - | ||||||||||||
| 239 | - | |||||||||||||
| 240 | Returns the tool tip base brush of the current color group. This brush is | - | ||||||||||||
| 241 | used by QToolTip and QWhatsThis. | - | ||||||||||||
| 242 | - | |||||||||||||
| 243 | \note Tool tips use the Inactive color group of QPalette, because tool | - | ||||||||||||
| 244 | tips are not active windows. | - | ||||||||||||
| 245 | - | |||||||||||||
| 246 | \sa ColorRole, brush() | - | ||||||||||||
| 247 | */ | - | ||||||||||||
| 248 | - | |||||||||||||
| 249 | /*! | - | ||||||||||||
| 250 | \fn const QBrush & QPalette::toolTipText() const | - | ||||||||||||
| 251 | \since 4.4 | - | ||||||||||||
| 252 | - | |||||||||||||
| 253 | Returns the tool tip text brush of the current color group. This brush is | - | ||||||||||||
| 254 | used by QToolTip and QWhatsThis. | - | ||||||||||||
| 255 | - | |||||||||||||
| 256 | \note Tool tips use the Inactive color group of QPalette, because tool | - | ||||||||||||
| 257 | tips are not active windows. | - | ||||||||||||
| 258 | - | |||||||||||||
| 259 | \sa ColorRole, brush() | - | ||||||||||||
| 260 | */ | - | ||||||||||||
| 261 | - | |||||||||||||
| 262 | /*! | - | ||||||||||||
| 263 | \fn const QBrush & QPalette::background() const | - | ||||||||||||
| 264 | \obsolete | - | ||||||||||||
| 265 | - | |||||||||||||
| 266 | Use window() instead. | - | ||||||||||||
| 267 | */ | - | ||||||||||||
| 268 | - | |||||||||||||
| 269 | /*! | - | ||||||||||||
| 270 | \fn const QBrush & QPalette::window() const | - | ||||||||||||
| 271 | - | |||||||||||||
| 272 | Returns the window (general background) brush of the current | - | ||||||||||||
| 273 | color group. | - | ||||||||||||
| 274 | - | |||||||||||||
| 275 | \sa ColorRole, brush() | - | ||||||||||||
| 276 | */ | - | ||||||||||||
| 277 | - | |||||||||||||
| 278 | /*! | - | ||||||||||||
| 279 | \fn const QBrush & QPalette::shadow() const | - | ||||||||||||
| 280 | - | |||||||||||||
| 281 | Returns the shadow brush of the current color group. | - | ||||||||||||
| 282 | - | |||||||||||||
| 283 | \sa ColorRole, brush() | - | ||||||||||||
| 284 | */ | - | ||||||||||||
| 285 | - | |||||||||||||
| 286 | /*! | - | ||||||||||||
| 287 | \fn const QBrush & QPalette::highlight() const | - | ||||||||||||
| 288 | - | |||||||||||||
| 289 | Returns the highlight brush of the current color group. | - | ||||||||||||
| 290 | - | |||||||||||||
| 291 | \sa ColorRole, brush() | - | ||||||||||||
| 292 | */ | - | ||||||||||||
| 293 | - | |||||||||||||
| 294 | /*! | - | ||||||||||||
| 295 | \fn const QBrush & QPalette::highlightedText() const | - | ||||||||||||
| 296 | - | |||||||||||||
| 297 | Returns the highlighted text brush of the current color group. | - | ||||||||||||
| 298 | - | |||||||||||||
| 299 | \sa ColorRole, brush() | - | ||||||||||||
| 300 | */ | - | ||||||||||||
| 301 | - | |||||||||||||
| 302 | /*! | - | ||||||||||||
| 303 | \fn const QBrush & QPalette::link() const | - | ||||||||||||
| 304 | - | |||||||||||||
| 305 | Returns the unvisited link text brush of the current color group. | - | ||||||||||||
| 306 | - | |||||||||||||
| 307 | \sa ColorRole, brush() | - | ||||||||||||
| 308 | */ | - | ||||||||||||
| 309 | - | |||||||||||||
| 310 | /*! | - | ||||||||||||
| 311 | \fn const QBrush & QPalette::linkVisited() const | - | ||||||||||||
| 312 | - | |||||||||||||
| 313 | Returns the visited link text brush of the current color group. | - | ||||||||||||
| 314 | - | |||||||||||||
| 315 | \sa ColorRole, brush() | - | ||||||||||||
| 316 | */ | - | ||||||||||||
| 317 | - | |||||||||||||
| 318 | /*! | - | ||||||||||||
| 319 | \fn ColorGroup QPalette::currentColorGroup() const | - | ||||||||||||
| 320 | - | |||||||||||||
| 321 | Returns the palette's current color group. | - | ||||||||||||
| 322 | */ | - | ||||||||||||
| 323 | - | |||||||||||||
| 324 | /*! | - | ||||||||||||
| 325 | \fn void QPalette::setCurrentColorGroup(ColorGroup cg) | - | ||||||||||||
| 326 | - | |||||||||||||
| 327 | Set the palette's current color group to \a cg. | - | ||||||||||||
| 328 | */ | - | ||||||||||||
| 329 | - | |||||||||||||
| 330 | /*! | - | ||||||||||||
| 331 | \class QPalette | - | ||||||||||||
| 332 | - | |||||||||||||
| 333 | \brief The QPalette class contains color groups for each widget state. | - | ||||||||||||
| 334 | - | |||||||||||||
| 335 | \inmodule QtGui | - | ||||||||||||
| 336 | \ingroup appearance | - | ||||||||||||
| 337 | \ingroup shared | - | ||||||||||||
| 338 | - | |||||||||||||
| 339 | A palette consists of three color groups: \e Active, \e Disabled, | - | ||||||||||||
| 340 | and \e Inactive. All widgets in Qt contain a palette and | - | ||||||||||||
| 341 | use their palette to draw themselves. This makes the user | - | ||||||||||||
| 342 | interface easily configurable and easier to keep consistent. | - | ||||||||||||
| 343 | - | |||||||||||||
| 344 | - | |||||||||||||
| 345 | If you create a new widget we strongly recommend that you use the | - | ||||||||||||
| 346 | colors in the palette rather than hard-coding specific colors. | - | ||||||||||||
| 347 | - | |||||||||||||
| 348 | The color groups: | - | ||||||||||||
| 349 | \list | - | ||||||||||||
| 350 | \li The Active group is used for the window that has keyboard focus. | - | ||||||||||||
| 351 | \li The Inactive group is used for other windows. | - | ||||||||||||
| 352 | \li The Disabled group is used for widgets (not windows) that are | - | ||||||||||||
| 353 | disabled for some reason. | - | ||||||||||||
| 354 | \endlist | - | ||||||||||||
| 355 | - | |||||||||||||
| 356 | Both active and inactive windows can contain disabled widgets. | - | ||||||||||||
| 357 | (Disabled widgets are often called \e inaccessible or \e{grayed | - | ||||||||||||
| 358 | out}.) | - | ||||||||||||
| 359 | - | |||||||||||||
| 360 | In most styles, Active and Inactive look the same. | - | ||||||||||||
| 361 | - | |||||||||||||
| 362 | Colors and brushes can be set for particular roles in any of a palette's | - | ||||||||||||
| 363 | color groups with setColor() and setBrush(). A color group contains a | - | ||||||||||||
| 364 | group of colors used by widgets for drawing themselves. We recommend that | - | ||||||||||||
| 365 | widgets use color group roles from the palette such as "foreground" and | - | ||||||||||||
| 366 | "base" rather than literal colors like "red" or "turquoise". The color | - | ||||||||||||
| 367 | roles are enumerated and defined in the \l ColorRole documentation. | - | ||||||||||||
| 368 | - | |||||||||||||
| 369 | We strongly recommend that you use the default palette of the | - | ||||||||||||
| 370 | current style (returned by QGuiApplication::palette()) and | - | ||||||||||||
| 371 | modify that as necessary. This is done by Qt's widgets when they | - | ||||||||||||
| 372 | are drawn. | - | ||||||||||||
| 373 | - | |||||||||||||
| 374 | To modify a color group you call the functions | - | ||||||||||||
| 375 | setColor() and setBrush(), depending on whether you want a pure | - | ||||||||||||
| 376 | color or a pixmap pattern. | - | ||||||||||||
| 377 | - | |||||||||||||
| 378 | There are also corresponding color() and brush() getters, and a | - | ||||||||||||
| 379 | commonly used convenience function to get the ColorRole for the current ColorGroup: | - | ||||||||||||
| 380 | window(), windowText(), base(), etc. | - | ||||||||||||
| 381 | - | |||||||||||||
| 382 | - | |||||||||||||
| 383 | You can copy a palette using the copy constructor and test to see | - | ||||||||||||
| 384 | if two palettes are \e identical using isCopyOf(). | - | ||||||||||||
| 385 | - | |||||||||||||
| 386 | QPalette is optimized by the use of \l{implicit sharing}, | - | ||||||||||||
| 387 | so it is very efficient to pass QPalette objects as arguments. | - | ||||||||||||
| 388 | - | |||||||||||||
| 389 | \warning Some styles do not use the palette for all drawing, for | - | ||||||||||||
| 390 | instance, if they make use of native theme engines. This is the | - | ||||||||||||
| 391 | case for both the Windows XP, Windows Vista, and the \macos | - | ||||||||||||
| 392 | styles. | - | ||||||||||||
| 393 | - | |||||||||||||
| 394 | \sa QApplication::setPalette(), QWidget::setPalette(), QColor | - | ||||||||||||
| 395 | */ | - | ||||||||||||
| 396 | - | |||||||||||||
| 397 | /*! | - | ||||||||||||
| 398 | \enum QPalette::ColorGroup | - | ||||||||||||
| 399 | - | |||||||||||||
| 400 | \value Disabled | - | ||||||||||||
| 401 | \value Active | - | ||||||||||||
| 402 | \value Inactive | - | ||||||||||||
| 403 | \value Normal synonym for Active | - | ||||||||||||
| 404 | - | |||||||||||||
| 405 | \omitvalue All | - | ||||||||||||
| 406 | \omitvalue NColorGroups | - | ||||||||||||
| 407 | \omitvalue Current | - | ||||||||||||
| 408 | */ | - | ||||||||||||
| 409 | - | |||||||||||||
| 410 | /*! | - | ||||||||||||
| 411 | \enum QPalette::ColorRole | - | ||||||||||||
| 412 | - | |||||||||||||
| 413 | \image palette.png Color Roles | - | ||||||||||||
| 414 | - | |||||||||||||
| 415 | The ColorRole enum defines the different symbolic color roles used | - | ||||||||||||
| 416 | in current GUIs. | - | ||||||||||||
| 417 | - | |||||||||||||
| 418 | The central roles are: | - | ||||||||||||
| 419 | - | |||||||||||||
| 420 | \value Window A general background color. | - | ||||||||||||
| 421 | - | |||||||||||||
| 422 | \value Background This value is obsolete. Use Window instead. | - | ||||||||||||
| 423 | - | |||||||||||||
| 424 | \value WindowText A general foreground color. | - | ||||||||||||
| 425 | - | |||||||||||||
| 426 | \value Foreground This value is obsolete. Use WindowText instead. | - | ||||||||||||
| 427 | - | |||||||||||||
| 428 | \value Base Used mostly as the background color for text entry widgets, | - | ||||||||||||
| 429 | but can also be used for other painting - such as the | - | ||||||||||||
| 430 | background of combobox drop down lists and toolbar handles. | - | ||||||||||||
| 431 | It is usually white or another light color. | - | ||||||||||||
| 432 | - | |||||||||||||
| 433 | \value AlternateBase Used as the alternate background color in views with | - | ||||||||||||
| 434 | alternating row colors (see | - | ||||||||||||
| 435 | QAbstractItemView::setAlternatingRowColors()). | - | ||||||||||||
| 436 | - | |||||||||||||
| 437 | \value ToolTipBase Used as the background color for QToolTip and | - | ||||||||||||
| 438 | QWhatsThis. Tool tips use the Inactive color group | - | ||||||||||||
| 439 | of QPalette, because tool tips are not active | - | ||||||||||||
| 440 | windows. | - | ||||||||||||
| 441 | - | |||||||||||||
| 442 | \value ToolTipText Used as the foreground color for QToolTip and | - | ||||||||||||
| 443 | QWhatsThis. Tool tips use the Inactive color group | - | ||||||||||||
| 444 | of QPalette, because tool tips are not active | - | ||||||||||||
| 445 | windows. | - | ||||||||||||
| 446 | - | |||||||||||||
| 447 | \value Text The foreground color used with \c Base. This is usually | - | ||||||||||||
| 448 | the same as the \c WindowText, in which case it must provide | - | ||||||||||||
| 449 | good contrast with \c Window and \c Base. | - | ||||||||||||
| 450 | - | |||||||||||||
| 451 | \value Button The general button background color. This background can be different from | - | ||||||||||||
| 452 | \c Window as some styles require a different background color for buttons. | - | ||||||||||||
| 453 | - | |||||||||||||
| 454 | \value ButtonText A foreground color used with the \c Button color. | - | ||||||||||||
| 455 | - | |||||||||||||
| 456 | \value BrightText A text color that is very different from | - | ||||||||||||
| 457 | \c WindowText, and contrasts well with e.g. \c | - | ||||||||||||
| 458 | Dark. Typically used for text that needs to be | - | ||||||||||||
| 459 | drawn where \c Text or \c WindowText would give | - | ||||||||||||
| 460 | poor contrast, such as on pressed push buttons. | - | ||||||||||||
| 461 | Note that text colors can be used for things | - | ||||||||||||
| 462 | other than just words; text colors are \e | - | ||||||||||||
| 463 | usually used for text, but it's quite common to | - | ||||||||||||
| 464 | use the text color roles for lines, icons, etc. | - | ||||||||||||
| 465 | - | |||||||||||||
| 466 | - | |||||||||||||
| 467 | There are some color roles used mostly for 3D bevel and shadow effects. | - | ||||||||||||
| 468 | All of these are normally derived from \c Window, and used in ways that | - | ||||||||||||
| 469 | depend on that relationship. For example, buttons depend on it to make the | - | ||||||||||||
| 470 | bevels look attractive, and Motif scroll bars depend on \c Mid to be | - | ||||||||||||
| 471 | slightly different from \c Window. | - | ||||||||||||
| 472 | - | |||||||||||||
| 473 | \value Light Lighter than \c Button color. | - | ||||||||||||
| 474 | - | |||||||||||||
| 475 | \value Midlight Between \c Button and \c Light. | - | ||||||||||||
| 476 | - | |||||||||||||
| 477 | \value Dark Darker than \c Button. | - | ||||||||||||
| 478 | - | |||||||||||||
| 479 | \value Mid Between \c Button and \c Dark. | - | ||||||||||||
| 480 | - | |||||||||||||
| 481 | \value Shadow A very dark color. By default, the shadow color is | - | ||||||||||||
| 482 | Qt::black. | - | ||||||||||||
| 483 | - | |||||||||||||
| 484 | - | |||||||||||||
| 485 | Selected (marked) items have two roles: | - | ||||||||||||
| 486 | - | |||||||||||||
| 487 | \value Highlight A color to indicate a selected item or the current | - | ||||||||||||
| 488 | item. By default, the highlight color is | - | ||||||||||||
| 489 | Qt::darkBlue. | - | ||||||||||||
| 490 | - | |||||||||||||
| 491 | \value HighlightedText A text color that contrasts with \c Highlight. | - | ||||||||||||
| 492 | By default, the highlighted text color is Qt::white. | - | ||||||||||||
| 493 | - | |||||||||||||
| 494 | There are two color roles related to hyperlinks: | - | ||||||||||||
| 495 | - | |||||||||||||
| 496 | \value Link A text color used for unvisited hyperlinks. | - | ||||||||||||
| 497 | By default, the link color is Qt::blue. | - | ||||||||||||
| 498 | - | |||||||||||||
| 499 | \value LinkVisited A text color used for already visited hyperlinks. | - | ||||||||||||
| 500 | By default, the linkvisited color is Qt::magenta. | - | ||||||||||||
| 501 | - | |||||||||||||
| 502 | Note that we do not use the \c Link and \c LinkVisited roles when | - | ||||||||||||
| 503 | rendering rich text in Qt, and that we recommend that you use CSS | - | ||||||||||||
| 504 | and the QTextDocument::setDefaultStyleSheet() function to alter | - | ||||||||||||
| 505 | the appearance of links. For example: | - | ||||||||||||
| 506 | - | |||||||||||||
| 507 | \snippet textdocument-css/main.cpp 0 | - | ||||||||||||
| 508 | - | |||||||||||||
| 509 | \value NoRole No role; this special role is often used to indicate that a | - | ||||||||||||
| 510 | role has not been assigned. | - | ||||||||||||
| 511 | - | |||||||||||||
| 512 | \omitvalue NColorRoles | - | ||||||||||||
| 513 | */ | - | ||||||||||||
| 514 | - | |||||||||||||
| 515 | /*! | - | ||||||||||||
| 516 | Constructs a palette object that uses the application's default palette. | - | ||||||||||||
| 517 | - | |||||||||||||
| 518 | \sa QApplication::setPalette(), QApplication::palette() | - | ||||||||||||
| 519 | */ | - | ||||||||||||
| 520 | QPalette::QPalette() | - | ||||||||||||
| 521 | : d(0) | - | ||||||||||||
| 522 | { | - | ||||||||||||
| 523 | data.current_group = Active; | - | ||||||||||||
| 524 | data.resolve_mask = 0; | - | ||||||||||||
| 525 | // Initialize to application palette if present, else default to black. | - | ||||||||||||
| 526 | // This makes it possible to instantiate QPalette outside QGuiApplication, | - | ||||||||||||
| 527 | // for example in the platform plugins. | - | ||||||||||||
| 528 | if (QGuiApplicationPrivate::app_pal) { 
 | 0 | ||||||||||||
| 529 | d = QGuiApplicationPrivate::app_pal->d; | - | ||||||||||||
| 530 | d->ref.ref(); | - | ||||||||||||
| 531 | } else { never executed:  end of block | 0 | ||||||||||||
| 532 | init(); | - | ||||||||||||
| 533 | qt_palette_from_color(*this, Qt::black); | - | ||||||||||||
| 534 | data.resolve_mask = 0; | - | ||||||||||||
| 535 | } never executed:  end of block | 0 | ||||||||||||
| 536 | } | - | ||||||||||||
| 537 | - | |||||||||||||
| 538 | /*! | - | ||||||||||||
| 539 | Constructs a palette from the \a button color. The other colors are | - | ||||||||||||
| 540 | automatically calculated, based on this color. \c Window will be | - | ||||||||||||
| 541 | the button color as well. | - | ||||||||||||
| 542 | */ | - | ||||||||||||
| 543 | QPalette::QPalette(const QColor &button) | - | ||||||||||||
| 544 | { | - | ||||||||||||
| 545 | init(); | - | ||||||||||||
| 546 | qt_palette_from_color(*this, button); | - | ||||||||||||
| 547 | } never executed:  end of block | 0 | ||||||||||||
| 548 | - | |||||||||||||
| 549 | /*! | - | ||||||||||||
| 550 | Constructs a palette from the \a button color. The other colors are | - | ||||||||||||
| 551 | automatically calculated, based on this color. \c Window will be | - | ||||||||||||
| 552 | the button color as well. | - | ||||||||||||
| 553 | */ | - | ||||||||||||
| 554 | QPalette::QPalette(Qt::GlobalColor button) | - | ||||||||||||
| 555 | { | - | ||||||||||||
| 556 | init(); | - | ||||||||||||
| 557 | qt_palette_from_color(*this, button); | - | ||||||||||||
| 558 | } never executed:  end of block | 0 | ||||||||||||
| 559 | - | |||||||||||||
| 560 | /*! | - | ||||||||||||
| 561 | Constructs a palette. You can pass either brushes, pixmaps or | - | ||||||||||||
| 562 | plain colors for \a windowText, \a button, \a light, \a dark, \a | - | ||||||||||||
| 563 | mid, \a text, \a bright_text, \a base and \a window. | - | ||||||||||||
| 564 | - | |||||||||||||
| 565 | \sa QBrush | - | ||||||||||||
| 566 | */ | - | ||||||||||||
| 567 | QPalette::QPalette(const QBrush &windowText, const QBrush &button, | - | ||||||||||||
| 568 | const QBrush &light, const QBrush &dark, | - | ||||||||||||
| 569 | const QBrush &mid, const QBrush &text, | - | ||||||||||||
| 570 | const QBrush &bright_text, const QBrush &base, | - | ||||||||||||
| 571 | const QBrush &window) | - | ||||||||||||
| 572 | { | - | ||||||||||||
| 573 | init(); | - | ||||||||||||
| 574 | setColorGroup(All, windowText, button, light, dark, mid, text, bright_text, | - | ||||||||||||
| 575 | base, window); | - | ||||||||||||
| 576 | } never executed:  end of block | 0 | ||||||||||||
| 577 | - | |||||||||||||
| 578 | - | |||||||||||||
| 579 | /*!\obsolete | - | ||||||||||||
| 580 | - | |||||||||||||
| 581 | Constructs a palette with the specified \a windowText, \a | - | ||||||||||||
| 582 | window, \a light, \a dark, \a mid, \a text, and \a base colors. | - | ||||||||||||
| 583 | The button color will be set to the window color. | - | ||||||||||||
| 584 | */ | - | ||||||||||||
| 585 | QPalette::QPalette(const QColor &windowText, const QColor &window, | - | ||||||||||||
| 586 | const QColor &light, const QColor &dark, const QColor &mid, | - | ||||||||||||
| 587 | const QColor &text, const QColor &base) | - | ||||||||||||
| 588 | { | - | ||||||||||||
| 589 | init(); | - | ||||||||||||
| 590 | const QBrush windowBrush(window); | - | ||||||||||||
| 591 | const QBrush lightBrush(light); | - | ||||||||||||
| 592 | setColorGroup(All, QBrush(windowText), windowBrush, lightBrush, | - | ||||||||||||
| 593 | QBrush(dark), QBrush(mid), QBrush(text), lightBrush, | - | ||||||||||||
| 594 | QBrush(base), windowBrush); | - | ||||||||||||
| 595 | } never executed:  end of block | 0 | ||||||||||||
| 596 | - | |||||||||||||
| 597 | /*! | - | ||||||||||||
| 598 | Constructs a palette from a \a button color and a \a window. | - | ||||||||||||
| 599 | The other colors are automatically calculated, based on these | - | ||||||||||||
| 600 | colors. | - | ||||||||||||
| 601 | */ | - | ||||||||||||
| 602 | QPalette::QPalette(const QColor &button, const QColor &window) | - | ||||||||||||
| 603 | { | - | ||||||||||||
| 604 | init(); | - | ||||||||||||
| 605 | int h, s, v; | - | ||||||||||||
| 606 | window.getHsv(&h, &s, &v); | - | ||||||||||||
| 607 | - | |||||||||||||
| 608 | const QBrush windowBrush = QBrush(window); | - | ||||||||||||
| 609 | const QBrush whiteBrush = QBrush(Qt::white); | - | ||||||||||||
| 610 | const QBrush blackBrush = QBrush(Qt::black); | - | ||||||||||||
| 611 | const QBrush baseBrush = v > 128 ? whiteBrush : blackBrush; 
 | 0 | ||||||||||||
| 612 | const QBrush foregroundBrush = v > 128 ? blackBrush : whiteBrush; 
 | 0 | ||||||||||||
| 613 | const QBrush disabledForeground = QBrush(Qt::darkGray); | - | ||||||||||||
| 614 | - | |||||||||||||
| 615 | const QBrush buttonBrush = QBrush(button); | - | ||||||||||||
| 616 | const QBrush buttonBrushDark = QBrush(button.darker()); | - | ||||||||||||
| 617 | const QBrush buttonBrushDark150 = QBrush(button.darker(150)); | - | ||||||||||||
| 618 | const QBrush buttonBrushLight150 = QBrush(button.lighter(150)); | - | ||||||||||||
| 619 | - | |||||||||||||
| 620 | //inactive and active are identical | - | ||||||||||||
| 621 | setColorGroup(Inactive, foregroundBrush, buttonBrush, buttonBrushLight150, buttonBrushDark, | - | ||||||||||||
| 622 | buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush, | - | ||||||||||||
| 623 | windowBrush); | - | ||||||||||||
| 624 | setColorGroup(Active, foregroundBrush, buttonBrush, buttonBrushLight150, buttonBrushDark, | - | ||||||||||||
| 625 | buttonBrushDark150, foregroundBrush, whiteBrush, baseBrush, | - | ||||||||||||
| 626 | windowBrush); | - | ||||||||||||
| 627 | setColorGroup(Disabled, disabledForeground, buttonBrush, buttonBrushLight150, | - | ||||||||||||
| 628 | buttonBrushDark, buttonBrushDark150, disabledForeground, | - | ||||||||||||
| 629 | whiteBrush, baseBrush, windowBrush); | - | ||||||||||||
| 630 | } never executed:  end of block | 0 | ||||||||||||
| 631 | - | |||||||||||||
| 632 | /*! | - | ||||||||||||
| 633 | Constructs a copy of \a p. | - | ||||||||||||
| 634 | - | |||||||||||||
| 635 | This constructor is fast thanks to \l{implicit sharing}. | - | ||||||||||||
| 636 | */ | - | ||||||||||||
| 637 | QPalette::QPalette(const QPalette &p) | - | ||||||||||||
| 638 | : d(p.d), data(p.data) | - | ||||||||||||
| 639 | { | - | ||||||||||||
| 640 | d->ref.ref(); | - | ||||||||||||
| 641 | } never executed:  end of block | 0 | ||||||||||||
| 642 | - | |||||||||||||
| 643 | /*! | - | ||||||||||||
| 644 | \fn QPalette::QPalette(QPalette &&other) | - | ||||||||||||
| 645 | \since 5.4 | - | ||||||||||||
| 646 | - | |||||||||||||
| 647 | Move-constructs a QPalette instance, making it point at the same | - | ||||||||||||
| 648 | object that \a other was pointing to. | - | ||||||||||||
| 649 | - | |||||||||||||
| 650 | After being moved from, you can only assign to or destroy \a other. | - | ||||||||||||
| 651 | Any other operation will result in undefined behavior. | - | ||||||||||||
| 652 | */ | - | ||||||||||||
| 653 | - | |||||||||||||
| 654 | /*! | - | ||||||||||||
| 655 | Destroys the palette. | - | ||||||||||||
| 656 | */ | - | ||||||||||||
| 657 | QPalette::~QPalette() | - | ||||||||||||
| 658 | { | - | ||||||||||||
| 659 | if (d && !d->ref.deref()) 
 
 | 0 | ||||||||||||
| 660 | delete d; never executed:  delete d; | 0 | ||||||||||||
| 661 | } never executed:  end of block | 0 | ||||||||||||
| 662 | - | |||||||||||||
| 663 | /*!\internal*/ | - | ||||||||||||
| 664 | void QPalette::init() { | - | ||||||||||||
| 665 | d = new QPalettePrivate; | - | ||||||||||||
| 666 | data.resolve_mask = 0; | - | ||||||||||||
| 667 | data.current_group = Active; //as a default.. | - | ||||||||||||
| 668 | } never executed:  end of block | 0 | ||||||||||||
| 669 | - | |||||||||||||
| 670 | /*! | - | ||||||||||||
| 671 | Assigns \a p to this palette and returns a reference to this | - | ||||||||||||
| 672 | palette. | - | ||||||||||||
| 673 | - | |||||||||||||
| 674 | This operation is fast thanks to \l{implicit sharing}. | - | ||||||||||||
| 675 | */ | - | ||||||||||||
| 676 | QPalette &QPalette::operator=(const QPalette &p) | - | ||||||||||||
| 677 | { | - | ||||||||||||
| 678 | p.d->ref.ref(); | - | ||||||||||||
| 679 | data = p.data; | - | ||||||||||||
| 680 | if (d && !d->ref.deref()) 
 
 | 0 | ||||||||||||
| 681 | delete d; never executed:  delete d; | 0 | ||||||||||||
| 682 | d = p.d; | - | ||||||||||||
| 683 | return *this; never executed:  return *this; | 0 | ||||||||||||
| 684 | } | - | ||||||||||||
| 685 | - | |||||||||||||
| 686 | /*! | - | ||||||||||||
| 687 | \fn void QPalette::swap(QPalette &other) | - | ||||||||||||
| 688 | \since 5.0 | - | ||||||||||||
| 689 | - | |||||||||||||
| 690 | Swaps this palette instance with \a other. This function is very | - | ||||||||||||
| 691 | fast and never fails. | - | ||||||||||||
| 692 | */ | - | ||||||||||||
| 693 | - | |||||||||||||
| 694 | /*! | - | ||||||||||||
| 695 | Returns the palette as a QVariant | - | ||||||||||||
| 696 | */ | - | ||||||||||||
| 697 | QPalette::operator QVariant() const | - | ||||||||||||
| 698 | { | - | ||||||||||||
| 699 | return QVariant(QVariant::Palette, this); never executed:  return QVariant(QVariant::Palette, this); | 0 | ||||||||||||
| 700 | } | - | ||||||||||||
| 701 | - | |||||||||||||
| 702 | /*! | - | ||||||||||||
| 703 | \fn const QColor &QPalette::color(ColorGroup group, ColorRole role) const | - | ||||||||||||
| 704 | - | |||||||||||||
| 705 | Returns the color in the specified color \a group, used for the | - | ||||||||||||
| 706 | given color \a role. | - | ||||||||||||
| 707 | - | |||||||||||||
| 708 | \sa brush(), setColor(), ColorRole | - | ||||||||||||
| 709 | */ | - | ||||||||||||
| 710 | - | |||||||||||||
| 711 | /*! | - | ||||||||||||
| 712 | \fn const QBrush &QPalette::brush(ColorGroup group, ColorRole role) const | - | ||||||||||||
| 713 | - | |||||||||||||
| 714 | Returns the brush in the specified color \a group, used for the | - | ||||||||||||
| 715 | given color \a role. | - | ||||||||||||
| 716 | - | |||||||||||||
| 717 | \sa color(), setBrush(), ColorRole | - | ||||||||||||
| 718 | */ | - | ||||||||||||
| 719 | const QBrush &QPalette::brush(ColorGroup gr, ColorRole cr) const | - | ||||||||||||
| 720 | { | - | ||||||||||||
| 721 | Q_ASSERT(cr < NColorRoles); | - | ||||||||||||
| 722 | if(gr >= (int)NColorGroups) { 
 | 0 | ||||||||||||
| 723 | if(gr == Current) { 
 | 0 | ||||||||||||
| 724 | gr = (ColorGroup)data.current_group; | - | ||||||||||||
| 725 | } else { never executed:  end of block | 0 | ||||||||||||
| 726 | qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr); | - | ||||||||||||
| 727 | gr = Active; | - | ||||||||||||
| 728 | } never executed:  end of block | 0 | ||||||||||||
| 729 | } | - | ||||||||||||
| 730 | return d->br[gr][cr]; never executed:  return d->br[gr][cr]; | 0 | ||||||||||||
| 731 | } | - | ||||||||||||
| 732 | - | |||||||||||||
| 733 | /*! | - | ||||||||||||
| 734 | \fn void QPalette::setColor(ColorGroup group, ColorRole role, const QColor &color) | - | ||||||||||||
| 735 | - | |||||||||||||
| 736 | Sets the color in the specified color \a group, used for the given | - | ||||||||||||
| 737 | color \a role, to the specified solid \a color. | - | ||||||||||||
| 738 | - | |||||||||||||
| 739 | \sa setBrush(), color(), ColorRole | - | ||||||||||||
| 740 | */ | - | ||||||||||||
| 741 | - | |||||||||||||
| 742 | /*! | - | ||||||||||||
| 743 | \fn void QPalette::setBrush(ColorGroup group, ColorRole role, const QBrush &brush) | - | ||||||||||||
| 744 | \overload | - | ||||||||||||
| 745 | - | |||||||||||||
| 746 | Sets the brush in the specified color \a group, used for the given | - | ||||||||||||
| 747 | color \a role, to \a brush. | - | ||||||||||||
| 748 | - | |||||||||||||
| 749 | \sa brush(), setColor(), ColorRole | - | ||||||||||||
| 750 | */ | - | ||||||||||||
| 751 | void QPalette::setBrush(ColorGroup cg, ColorRole cr, const QBrush &b) | - | ||||||||||||
| 752 | { | - | ||||||||||||
| 753 | Q_ASSERT(cr < NColorRoles); | - | ||||||||||||
| 754 | detach(); | - | ||||||||||||
| 755 | if(cg >= (int)NColorGroups) { 
 | 0 | ||||||||||||
| 756 | if(cg == All) { 
 | 0 | ||||||||||||
| 757 | for(int i = 0; i < (int)NColorGroups; i++) 
 | 0 | ||||||||||||
| 758 | d->br[i][cr] = b; never executed:  d->br[i][cr] = b; | 0 | ||||||||||||
| 759 | data.resolve_mask |= (1<<cr); | - | ||||||||||||
| 760 | return; never executed:  return; | 0 | ||||||||||||
| 761 | } else if(cg == Current) { 
 | 0 | ||||||||||||
| 762 | cg = (ColorGroup)data.current_group; | - | ||||||||||||
| 763 | } else { never executed:  end of block | 0 | ||||||||||||
| 764 | qWarning("QPalette::setBrush: Unknown ColorGroup: %d", (int)cg); | - | ||||||||||||
| 765 | cg = Active; | - | ||||||||||||
| 766 | } never executed:  end of block | 0 | ||||||||||||
| 767 | } | - | ||||||||||||
| 768 | d->br[cg][cr] = b; | - | ||||||||||||
| 769 | data.resolve_mask |= (1<<cr); | - | ||||||||||||
| 770 | } never executed:  end of block | 0 | ||||||||||||
| 771 | - | |||||||||||||
| 772 | /*! | - | ||||||||||||
| 773 | \since 4.2 | - | ||||||||||||
| 774 | - | |||||||||||||
| 775 | Returns \c true if the ColorGroup \a cg and ColorRole \a cr has been | - | ||||||||||||
| 776 | set previously on this palette; otherwise returns \c false. | - | ||||||||||||
| 777 | - | |||||||||||||
| 778 | \sa setBrush() | - | ||||||||||||
| 779 | */ | - | ||||||||||||
| 780 | bool QPalette::isBrushSet(ColorGroup cg, ColorRole cr) const | - | ||||||||||||
| 781 | { | - | ||||||||||||
| 782 | Q_UNUSED(cg); | - | ||||||||||||
| 783 | return (data.resolve_mask & (1<<cr)); never executed:  return (data.resolve_mask & (1<<cr)); | 0 | ||||||||||||
| 784 | } | - | ||||||||||||
| 785 | - | |||||||||||||
| 786 | /*! | - | ||||||||||||
| 787 | \internal | - | ||||||||||||
| 788 | */ | - | ||||||||||||
| 789 | void QPalette::detach() | - | ||||||||||||
| 790 | { | - | ||||||||||||
| 791 | if (d->ref.load() != 1) { 
 | 0 | ||||||||||||
| 792 | QPalettePrivate *x = new QPalettePrivate; | - | ||||||||||||
| 793 | for(int grp = 0; grp < (int)NColorGroups; grp++) { 
 | 0 | ||||||||||||
| 794 | for(int role = 0; role < (int)NColorRoles; role++) 
 | 0 | ||||||||||||
| 795 | x->br[grp][role] = d->br[grp][role]; never executed:  x->br[grp][role] = d->br[grp][role]; | 0 | ||||||||||||
| 796 | } never executed:  end of block | 0 | ||||||||||||
| 797 | if(!d->ref.deref()) 
 | 0 | ||||||||||||
| 798 | delete d; never executed:  delete d; | 0 | ||||||||||||
| 799 | d = x; | - | ||||||||||||
| 800 | } never executed:  end of block | 0 | ||||||||||||
| 801 | ++d->detach_no; | - | ||||||||||||
| 802 | } never executed:  end of block | 0 | ||||||||||||
| 803 | - | |||||||||||||
| 804 | /*! | - | ||||||||||||
| 805 | \fn bool QPalette::operator!=(const QPalette &p) const | - | ||||||||||||
| 806 | - | |||||||||||||
| 807 | Returns \c true (slowly) if this palette is different from \a p; | - | ||||||||||||
| 808 | otherwise returns \c false (usually quickly). | - | ||||||||||||
| 809 | - | |||||||||||||
| 810 | \note The current ColorGroup is not taken into account when | - | ||||||||||||
| 811 | comparing palettes | - | ||||||||||||
| 812 | - | |||||||||||||
| 813 | \sa operator==() | - | ||||||||||||
| 814 | */ | - | ||||||||||||
| 815 | - | |||||||||||||
| 816 | /*! | - | ||||||||||||
| 817 | Returns \c true (usually quickly) if this palette is equal to \a p; | - | ||||||||||||
| 818 | otherwise returns \c false (slowly). | - | ||||||||||||
| 819 | - | |||||||||||||
| 820 | \note The current ColorGroup is not taken into account when | - | ||||||||||||
| 821 | comparing palettes | - | ||||||||||||
| 822 | - | |||||||||||||
| 823 | \sa operator!=() | - | ||||||||||||
| 824 | */ | - | ||||||||||||
| 825 | bool QPalette::operator==(const QPalette &p) const | - | ||||||||||||
| 826 | { | - | ||||||||||||
| 827 | if (isCopyOf(p)) 
 | 0 | ||||||||||||
| 828 | return true; never executed:  return true; | 0 | ||||||||||||
| 829 | for(int grp = 0; grp < (int)NColorGroups; grp++) { 
 | 0 | ||||||||||||
| 830 | for(int role = 0; role < (int)NColorRoles; role++) { 
 | 0 | ||||||||||||
| 831 | if(d->br[grp][role] != p.d->br[grp][role]) 
 | 0 | ||||||||||||
| 832 | return false; never executed:  return false; | 0 | ||||||||||||
| 833 | } never executed:  end of block | 0 | ||||||||||||
| 834 | } never executed:  end of block | 0 | ||||||||||||
| 835 | return true; never executed:  return true; | 0 | ||||||||||||
| 836 | } | - | ||||||||||||
| 837 | - | |||||||||||||
| 838 | /*! | - | ||||||||||||
| 839 | \fn bool QPalette::isEqual(ColorGroup cg1, ColorGroup cg2) const | - | ||||||||||||
| 840 | - | |||||||||||||
| 841 | Returns \c true (usually quickly) if color group \a cg1 is equal to | - | ||||||||||||
| 842 | \a cg2; otherwise returns \c false. | - | ||||||||||||
| 843 | */ | - | ||||||||||||
| 844 | bool QPalette::isEqual(QPalette::ColorGroup group1, QPalette::ColorGroup group2) const | - | ||||||||||||
| 845 | { | - | ||||||||||||
| 846 | if(group1 >= (int)NColorGroups) { 
 | 0 | ||||||||||||
| 847 | if(group1 == Current) { 
 | 0 | ||||||||||||
| 848 | group1 = (ColorGroup)data.current_group; | - | ||||||||||||
| 849 | } else { never executed:  end of block | 0 | ||||||||||||
| 850 | qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1); | - | ||||||||||||
| 851 | group1 = Active; | - | ||||||||||||
| 852 | } never executed:  end of block | 0 | ||||||||||||
| 853 | } | - | ||||||||||||
| 854 | if(group2 >= (int)NColorGroups) { 
 | 0 | ||||||||||||
| 855 | if(group2 == Current) { 
 | 0 | ||||||||||||
| 856 | group2 = (ColorGroup)data.current_group; | - | ||||||||||||
| 857 | } else { never executed:  end of block | 0 | ||||||||||||
| 858 | qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2); | - | ||||||||||||
| 859 | group2 = Active; | - | ||||||||||||
| 860 | } never executed:  end of block | 0 | ||||||||||||
| 861 | } | - | ||||||||||||
| 862 | if(group1 == group2) 
 | 0 | ||||||||||||
| 863 | return true; never executed:  return true; | 0 | ||||||||||||
| 864 | for(int role = 0; role < (int)NColorRoles; role++) { 
 | 0 | ||||||||||||
| 865 | if(d->br[group1][role] != d->br[group2][role]) 
 | 0 | ||||||||||||
| 866 | return false; never executed:  return false; | 0 | ||||||||||||
| 867 | } never executed:  end of block | 0 | ||||||||||||
| 868 | return true; never executed:  return true; | 0 | ||||||||||||
| 869 | } | - | ||||||||||||
| 870 | - | |||||||||||||
| 871 | /*! \fn int QPalette::serialNumber() const | - | ||||||||||||
| 872 | \obsolete | - | ||||||||||||
| 873 | - | |||||||||||||
| 874 | Returns a number that identifies the contents of this QPalette | - | ||||||||||||
| 875 | object. Distinct QPalette objects can only have the same serial | - | ||||||||||||
| 876 | number if they refer to the same contents (but they don't have | - | ||||||||||||
| 877 | to). Also, the serial number of a QPalette may change during the | - | ||||||||||||
| 878 | lifetime of the object. | - | ||||||||||||
| 879 | - | |||||||||||||
| 880 | Use cacheKey() instead. | - | ||||||||||||
| 881 | - | |||||||||||||
| 882 | \warning The serial number doesn't necessarily change when the | - | ||||||||||||
| 883 | palette is altered. This means that it may be dangerous to use it | - | ||||||||||||
| 884 | as a cache key. | - | ||||||||||||
| 885 | - | |||||||||||||
| 886 | \sa operator==() | - | ||||||||||||
| 887 | */ | - | ||||||||||||
| 888 | - | |||||||||||||
| 889 | /*! | - | ||||||||||||
| 890 | Returns a number that identifies the contents of this QPalette | - | ||||||||||||
| 891 | object. Distinct QPalette objects can have the same key if | - | ||||||||||||
| 892 | they refer to the same contents. | - | ||||||||||||
| 893 | - | |||||||||||||
| 894 | The cacheKey() will change when the palette is altered. | - | ||||||||||||
| 895 | */ | - | ||||||||||||
| 896 | qint64 QPalette::cacheKey() const | - | ||||||||||||
| 897 | { | - | ||||||||||||
| 898 | return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no)); never executed:  return (((qint64) d->ser_no) << 32) | ((qint64) (d->detach_no)); | 0 | ||||||||||||
| 899 | } | - | ||||||||||||
| 900 | - | |||||||||||||
| 901 | /*! | - | ||||||||||||
| 902 | Returns a new QPalette that has attributes copied from \a other. | - | ||||||||||||
| 903 | */ | - | ||||||||||||
| 904 | QPalette QPalette::resolve(const QPalette &other) const | - | ||||||||||||
| 905 | { | - | ||||||||||||
| 906 | if ((*this == other && data.resolve_mask == other.data.resolve_mask) 
 
 | 0 | ||||||||||||
| 907 | || data.resolve_mask == 0) { 
 | 0 | ||||||||||||
| 908 | QPalette o = other; | - | ||||||||||||
| 909 | o.data.resolve_mask = data.resolve_mask; | - | ||||||||||||
| 910 | return o; never executed:  return o; | 0 | ||||||||||||
| 911 | } | - | ||||||||||||
| 912 | - | |||||||||||||
| 913 | QPalette palette(*this); | - | ||||||||||||
| 914 | palette.detach(); | - | ||||||||||||
| 915 | - | |||||||||||||
| 916 | for(int role = 0; role < (int)NColorRoles; role++) 
 | 0 | ||||||||||||
| 917 | if (!(data.resolve_mask & (1<<role))) 
 | 0 | ||||||||||||
| 918 | for(int grp = 0; grp < (int)NColorGroups; grp++) 
 | 0 | ||||||||||||
| 919 | palette.d->br[grp][role] = other.d->br[grp][role]; never executed:  palette.d->br[grp][role] = other.d->br[grp][role]; | 0 | ||||||||||||
| 920 | - | |||||||||||||
| 921 | return palette; never executed:  return palette; | 0 | ||||||||||||
| 922 | } | - | ||||||||||||
| 923 | - | |||||||||||||
| 924 | /*! | - | ||||||||||||
| 925 | \fn uint QPalette::resolve() const | - | ||||||||||||
| 926 | \internal | - | ||||||||||||
| 927 | */ | - | ||||||||||||
| 928 | - | |||||||||||||
| 929 | /*! | - | ||||||||||||
| 930 | \fn void QPalette::resolve(uint mask) | - | ||||||||||||
| 931 | \internal | - | ||||||||||||
| 932 | */ | - | ||||||||||||
| 933 | - | |||||||||||||
| 934 | - | |||||||||||||
| 935 | /***************************************************************************** | - | ||||||||||||
| 936 | QPalette stream functions | - | ||||||||||||
| 937 | *****************************************************************************/ | - | ||||||||||||
| 938 | - | |||||||||||||
| 939 | #ifndef QT_NO_DATASTREAM | - | ||||||||||||
| 940 | - | |||||||||||||
| 941 | static const int NumOldRoles = 7; | - | ||||||||||||
| 942 | static const int oldRoles[7] = { QPalette::Foreground, QPalette::Background, QPalette::Light, | - | ||||||||||||
| 943 | QPalette::Dark, QPalette::Mid, QPalette::Text, QPalette::Base }; | - | ||||||||||||
| 944 | - | |||||||||||||
| 945 | /*! | - | ||||||||||||
| 946 | \relates QPalette | - | ||||||||||||
| 947 | - | |||||||||||||
| 948 | Writes the palette, \a p to the stream \a s and returns a | - | ||||||||||||
| 949 | reference to the stream. | - | ||||||||||||
| 950 | - | |||||||||||||
| 951 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||
| 952 | */ | - | ||||||||||||
| 953 | - | |||||||||||||
| 954 | QDataStream &operator<<(QDataStream &s, const QPalette &p) | - | ||||||||||||
| 955 | { | - | ||||||||||||
| 956 | for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) { 
 | 0 | ||||||||||||
| 957 | if (s.version() == 1) { 
 | 0 | ||||||||||||
| 958 | // Qt 1.x | - | ||||||||||||
| 959 | for (int i = 0; i < NumOldRoles; ++i) 
 | 0 | ||||||||||||
| 960 | s << p.d->br[grp][oldRoles[i]].color(); never executed:  s << p.d->br[grp][oldRoles[i]].color(); | 0 | ||||||||||||
| 961 | } else { never executed:  end of block | 0 | ||||||||||||
| 962 | int max = QPalette::ToolTipText + 1; | - | ||||||||||||
| 963 | if (s.version() <= QDataStream::Qt_2_1) 
 | 0 | ||||||||||||
| 964 | max = QPalette::HighlightedText + 1; never executed:  max = QPalette::HighlightedText + 1; | 0 | ||||||||||||
| 965 | else if (s.version() <= QDataStream::Qt_4_3) 
 | 0 | ||||||||||||
| 966 | max = QPalette::AlternateBase + 1; never executed:  max = QPalette::AlternateBase + 1; | 0 | ||||||||||||
| 967 | for (int r = 0; r < max; r++) 
 | 0 | ||||||||||||
| 968 | s << p.d->br[grp][r]; never executed:  s << p.d->br[grp][r]; | 0 | ||||||||||||
| 969 | } never executed:  end of block | 0 | ||||||||||||
| 970 | } | - | ||||||||||||
| 971 | return s; never executed:  return s; | 0 | ||||||||||||
| 972 | } | - | ||||||||||||
| 973 | - | |||||||||||||
| 974 | static void readV1ColorGroup(QDataStream &s, QPalette &pal, QPalette::ColorGroup grp) | - | ||||||||||||
| 975 | { | - | ||||||||||||
| 976 | for (int i = 0; i < NumOldRoles; ++i) { 
 | 0 | ||||||||||||
| 977 | QColor col; | - | ||||||||||||
| 978 | s >> col; | - | ||||||||||||
| 979 | pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col); | - | ||||||||||||
| 980 | } never executed:  end of block | 0 | ||||||||||||
| 981 | } never executed:  end of block | 0 | ||||||||||||
| 982 | - | |||||||||||||
| 983 | /*! | - | ||||||||||||
| 984 | \relates QPalette | - | ||||||||||||
| 985 | - | |||||||||||||
| 986 | Reads a palette from the stream, \a s into the palette \a p, and | - | ||||||||||||
| 987 | returns a reference to the stream. | - | ||||||||||||
| 988 | - | |||||||||||||
| 989 | \sa{Serializing Qt Data Types}{Format of the QDataStream operators} | - | ||||||||||||
| 990 | */ | - | ||||||||||||
| 991 | - | |||||||||||||
| 992 | QDataStream &operator>>(QDataStream &s, QPalette &p) | - | ||||||||||||
| 993 | { | - | ||||||||||||
| 994 | if(s.version() == 1) { 
 | 0 | ||||||||||||
| 995 | p = QPalette(); | - | ||||||||||||
| 996 | readV1ColorGroup(s, p, QPalette::Active); | - | ||||||||||||
| 997 | readV1ColorGroup(s, p, QPalette::Disabled); | - | ||||||||||||
| 998 | readV1ColorGroup(s, p, QPalette::Inactive); | - | ||||||||||||
| 999 | } else { never executed:  end of block | 0 | ||||||||||||
| 1000 | int max = QPalette::NColorRoles; | - | ||||||||||||
| 1001 | if (s.version() <= QDataStream::Qt_2_1) { 
 | 0 | ||||||||||||
| 1002 | p = QPalette(); | - | ||||||||||||
| 1003 | max = QPalette::HighlightedText + 1; | - | ||||||||||||
| 1004 | } else if (s.version() <= QDataStream::Qt_4_3) { never executed:  end of block
 | 0 | ||||||||||||
| 1005 | p = QPalette(); | - | ||||||||||||
| 1006 | max = QPalette::AlternateBase + 1; | - | ||||||||||||
| 1007 | } never executed:  end of block | 0 | ||||||||||||
| 1008 | - | |||||||||||||
| 1009 | QBrush tmp; | - | ||||||||||||
| 1010 | for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) { 
 | 0 | ||||||||||||
| 1011 | for(int role = 0; role < max; ++role) { 
 | 0 | ||||||||||||
| 1012 | s >> tmp; | - | ||||||||||||
| 1013 | p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp); | - | ||||||||||||
| 1014 | } never executed:  end of block | 0 | ||||||||||||
| 1015 | } never executed:  end of block | 0 | ||||||||||||
| 1016 | } never executed:  end of block | 0 | ||||||||||||
| 1017 | return s; never executed:  return s; | 0 | ||||||||||||
| 1018 | } | - | ||||||||||||
| 1019 | #endif //QT_NO_DATASTREAM | - | ||||||||||||
| 1020 | - | |||||||||||||
| 1021 | /*! | - | ||||||||||||
| 1022 | Returns \c true if this palette and \a p are copies of each other, | - | ||||||||||||
| 1023 | i.e. one of them was created as a copy of the other and neither | - | ||||||||||||
| 1024 | was subsequently modified; otherwise returns \c false. This is much | - | ||||||||||||
| 1025 | stricter than equality. | - | ||||||||||||
| 1026 | - | |||||||||||||
| 1027 | \sa operator=(), operator==() | - | ||||||||||||
| 1028 | */ | - | ||||||||||||
| 1029 | - | |||||||||||||
| 1030 | bool QPalette::isCopyOf(const QPalette &p) const | - | ||||||||||||
| 1031 | { | - | ||||||||||||
| 1032 | return d == p.d; never executed:  return d == p.d; | 0 | ||||||||||||
| 1033 | } | - | ||||||||||||
| 1034 | - | |||||||||||||
| 1035 | /*! | - | ||||||||||||
| 1036 | - | |||||||||||||
| 1037 | Sets a the group at \a cg. You can pass either brushes, pixmaps or | - | ||||||||||||
| 1038 | plain colors for \a windowText, \a button, \a light, \a dark, \a | - | ||||||||||||
| 1039 | mid, \a text, \a bright_text, \a base and \a window. | - | ||||||||||||
| 1040 | - | |||||||||||||
| 1041 | \sa QBrush | - | ||||||||||||
| 1042 | */ | - | ||||||||||||
| 1043 | void QPalette::setColorGroup(ColorGroup cg, const QBrush &windowText, const QBrush &button, | - | ||||||||||||
| 1044 | const QBrush &light, const QBrush &dark, const QBrush &mid, | - | ||||||||||||
| 1045 | const QBrush &text, const QBrush &bright_text, const QBrush &base, | - | ||||||||||||
| 1046 | const QBrush &window) | - | ||||||||||||
| 1047 | { | - | ||||||||||||
| 1048 | QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color())); | - | ||||||||||||
| 1049 | QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color())); | - | ||||||||||||
| 1050 | QColor toolTipBase(255, 255, 220); | - | ||||||||||||
| 1051 | QColor toolTipText(0, 0, 0); | - | ||||||||||||
| 1052 | - | |||||||||||||
| 1053 | setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base, | - | ||||||||||||
| 1054 | alt_base, window, mid_light, text, | - | ||||||||||||
| 1055 | QBrush(Qt::black), QBrush(Qt::darkBlue), QBrush(Qt::white), | - | ||||||||||||
| 1056 | QBrush(Qt::blue), QBrush(Qt::magenta), QBrush(toolTipBase), | - | ||||||||||||
| 1057 | QBrush(toolTipText)); | - | ||||||||||||
| 1058 | - | |||||||||||||
| 1059 | data.resolve_mask &= ~(1 << Highlight); | - | ||||||||||||
| 1060 | data.resolve_mask &= ~(1 << HighlightedText); | - | ||||||||||||
| 1061 | data.resolve_mask &= ~(1 << LinkVisited); | - | ||||||||||||
| 1062 | data.resolve_mask &= ~(1 << Link); | - | ||||||||||||
| 1063 | } never executed:  end of block | 0 | ||||||||||||
| 1064 | - | |||||||||||||
| 1065 | - | |||||||||||||
| 1066 | /*!\internal*/ | - | ||||||||||||
| 1067 | void | - | ||||||||||||
| 1068 | QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button, | - | ||||||||||||
| 1069 | const QBrush &light, const QBrush &dark, const QBrush &mid, | - | ||||||||||||
| 1070 | const QBrush &text, const QBrush &bright_text, | - | ||||||||||||
| 1071 | const QBrush &base, const QBrush &alternate_base, | - | ||||||||||||
| 1072 | const QBrush &background, const QBrush &midlight, | - | ||||||||||||
| 1073 | const QBrush &button_text, const QBrush &shadow, | - | ||||||||||||
| 1074 | const QBrush &highlight, const QBrush &highlighted_text, | - | ||||||||||||
| 1075 | const QBrush &link, const QBrush &link_visited) | - | ||||||||||||
| 1076 | { | - | ||||||||||||
| 1077 | setColorGroup(cg, foreground, button, light, dark, mid, | - | ||||||||||||
| 1078 | text, bright_text, base, alternate_base, background, | - | ||||||||||||
| 1079 | midlight, button_text, shadow, highlight, highlighted_text, | - | ||||||||||||
| 1080 | link, link_visited, background, foreground); | - | ||||||||||||
| 1081 | } never executed:  end of block | 0 | ||||||||||||
| 1082 | - | |||||||||||||
| 1083 | /*!\internal*/ | - | ||||||||||||
| 1084 | void QPalette::setColorGroup(ColorGroup cg, const QBrush &foreground, const QBrush &button, | - | ||||||||||||
| 1085 | const QBrush &light, const QBrush &dark, const QBrush &mid, | - | ||||||||||||
| 1086 | const QBrush &text, const QBrush &bright_text, | - | ||||||||||||
| 1087 | const QBrush &base, const QBrush &alternate_base, | - | ||||||||||||
| 1088 | const QBrush &background, const QBrush &midlight, | - | ||||||||||||
| 1089 | const QBrush &button_text, const QBrush &shadow, | - | ||||||||||||
| 1090 | const QBrush &highlight, const QBrush &highlighted_text, | - | ||||||||||||
| 1091 | const QBrush &link, const QBrush &link_visited, | - | ||||||||||||
| 1092 | const QBrush &toolTipBase, const QBrush &toolTipText) | - | ||||||||||||
| 1093 | { | - | ||||||||||||
| 1094 | detach(); | - | ||||||||||||
| 1095 | setBrush(cg, WindowText, foreground); | - | ||||||||||||
| 1096 | setBrush(cg, Button, button); | - | ||||||||||||
| 1097 | setBrush(cg, Light, light); | - | ||||||||||||
| 1098 | setBrush(cg, Dark, dark); | - | ||||||||||||
| 1099 | setBrush(cg, Mid, mid); | - | ||||||||||||
| 1100 | setBrush(cg, Text, text); | - | ||||||||||||
| 1101 | setBrush(cg, BrightText, bright_text); | - | ||||||||||||
| 1102 | setBrush(cg, Base, base); | - | ||||||||||||
| 1103 | setBrush(cg, AlternateBase, alternate_base); | - | ||||||||||||
| 1104 | setBrush(cg, Window, background); | - | ||||||||||||
| 1105 | setBrush(cg, Midlight, midlight); | - | ||||||||||||
| 1106 | setBrush(cg, ButtonText, button_text); | - | ||||||||||||
| 1107 | setBrush(cg, Shadow, shadow); | - | ||||||||||||
| 1108 | setBrush(cg, Highlight, highlight); | - | ||||||||||||
| 1109 | setBrush(cg, HighlightedText, highlighted_text); | - | ||||||||||||
| 1110 | setBrush(cg, Link, link); | - | ||||||||||||
| 1111 | setBrush(cg, LinkVisited, link_visited); | - | ||||||||||||
| 1112 | setBrush(cg, ToolTipBase, toolTipBase); | - | ||||||||||||
| 1113 | setBrush(cg, ToolTipText, toolTipText); | - | ||||||||||||
| 1114 | } never executed:  end of block | 0 | ||||||||||||
| 1115 | - | |||||||||||||
| 1116 | Q_GUI_EXPORT QPalette qt_fusionPalette() | - | ||||||||||||
| 1117 | { | - | ||||||||||||
| 1118 | QColor backGround(239, 235, 231); | - | ||||||||||||
| 1119 | QColor light = backGround.lighter(150); | - | ||||||||||||
| 1120 | QColor mid(backGround.darker(130)); | - | ||||||||||||
| 1121 | QColor midLight = mid.lighter(110); | - | ||||||||||||
| 1122 | QColor base = Qt::white; | - | ||||||||||||
| 1123 | QColor disabledBase(backGround); | - | ||||||||||||
| 1124 | QColor dark = backGround.darker(150); | - | ||||||||||||
| 1125 | QColor darkDisabled = QColor(209, 200, 191).darker(110); | - | ||||||||||||
| 1126 | QColor text = Qt::black; | - | ||||||||||||
| 1127 | QColor hightlightedText = Qt::white; | - | ||||||||||||
| 1128 | QColor disabledText = QColor(190, 190, 190); | - | ||||||||||||
| 1129 | QColor button = backGround; | - | ||||||||||||
| 1130 | QColor shadow = dark.darker(135); | - | ||||||||||||
| 1131 | QColor disabledShadow = shadow.lighter(150); | - | ||||||||||||
| 1132 | - | |||||||||||||
| 1133 | QPalette fusionPalette(Qt::black,backGround,light,dark,mid,text,base); | - | ||||||||||||
| 1134 | fusionPalette.setBrush(QPalette::Midlight, midLight); | - | ||||||||||||
| 1135 | fusionPalette.setBrush(QPalette::Button, button); | - | ||||||||||||
| 1136 | fusionPalette.setBrush(QPalette::Shadow, shadow); | - | ||||||||||||
| 1137 | fusionPalette.setBrush(QPalette::HighlightedText, hightlightedText); | - | ||||||||||||
| 1138 | - | |||||||||||||
| 1139 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Text, disabledText); | - | ||||||||||||
| 1140 | fusionPalette.setBrush(QPalette::Disabled, QPalette::WindowText, disabledText); | - | ||||||||||||
| 1141 | fusionPalette.setBrush(QPalette::Disabled, QPalette::ButtonText, disabledText); | - | ||||||||||||
| 1142 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Base, disabledBase); | - | ||||||||||||
| 1143 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Dark, darkDisabled); | - | ||||||||||||
| 1144 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Shadow, disabledShadow); | - | ||||||||||||
| 1145 | - | |||||||||||||
| 1146 | fusionPalette.setBrush(QPalette::Active, QPalette::Highlight, QColor(48, 140, 198)); | - | ||||||||||||
| 1147 | fusionPalette.setBrush(QPalette::Inactive, QPalette::Highlight, QColor(48, 140, 198)); | - | ||||||||||||
| 1148 | fusionPalette.setBrush(QPalette::Disabled, QPalette::Highlight, QColor(145, 141, 126)); | - | ||||||||||||
| 1149 | return fusionPalette; never executed:  return fusionPalette; | 0 | ||||||||||||
| 1150 | } | - | ||||||||||||
| 1151 | - | |||||||||||||
| 1152 | #ifndef QT_NO_DEBUG_STREAM | - | ||||||||||||
| 1153 | QDebug operator<<(QDebug dbg, const QPalette &p) | - | ||||||||||||
| 1154 | { | - | ||||||||||||
| 1155 | const char *colorGroupNames[] = {"Active", "Disabled", "Inactive"}; | - | ||||||||||||
| 1156 | const char *colorRoleNames[] = | - | ||||||||||||
| 1157 | {"WindowText", "Button", "Light", "Midlight", "Dark", "Mid", "Text", | - | ||||||||||||
| 1158 | "BrightText", "ButtonText", "Base", "Window", "Shadow", "Highlight", | - | ||||||||||||
| 1159 | "HighlightedText", "Link", "LinkVisited", "AlternateBase", "NoRole", | - | ||||||||||||
| 1160 | "ToolTipBase","ToolTipText" }; | - | ||||||||||||
| 1161 | QDebugStateSaver saver(dbg); | - | ||||||||||||
| 1162 | QDebug nospace = dbg.nospace(); | - | ||||||||||||
| 1163 | const uint mask = p.resolve(); | - | ||||||||||||
| 1164 | nospace << "QPalette(resolve=" << hex << showbase << mask << ','; | - | ||||||||||||
| 1165 | for (int role = 0; role < (int)QPalette::NColorRoles; ++role) { 
 | 0 | ||||||||||||
| 1166 | if (mask & (1<<role)) { 
 | 0 | ||||||||||||
| 1167 | if (role) 
 | 0 | ||||||||||||
| 1168 | nospace << ','; never executed:  nospace << ','; | 0 | ||||||||||||
| 1169 | nospace << colorRoleNames[role] << ":["; | - | ||||||||||||
| 1170 | for (int group = 0; group < (int)QPalette::NColorGroups; ++group) { 
 | 0 | ||||||||||||
| 1171 | if (group) 
 | 0 | ||||||||||||
| 1172 | nospace << ','; never executed:  nospace << ','; | 0 | ||||||||||||
| 1173 | const QRgb color = p.color(static_cast<QPalette::ColorGroup>(group), | - | ||||||||||||
| 1174 | static_cast<QPalette::ColorRole>(role)).rgba(); | - | ||||||||||||
| 1175 | nospace << colorGroupNames[group] << ':' << color; | - | ||||||||||||
| 1176 | } never executed:  end of block | 0 | ||||||||||||
| 1177 | nospace << ']'; | - | ||||||||||||
| 1178 | } never executed:  end of block | 0 | ||||||||||||
| 1179 | } never executed:  end of block | 0 | ||||||||||||
| 1180 | nospace << ')' << noshowbase << dec; | - | ||||||||||||
| 1181 | return dbg; never executed:  return dbg; | 0 | ||||||||||||
| 1182 | } | - | ||||||||||||
| 1183 | #endif | - | ||||||||||||
| 1184 | - | |||||||||||||
| 1185 | QT_END_NAMESPACE | - | ||||||||||||
| Source code | Switch to Preprocessed file |