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