Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickcolorgroup.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
4
5#include <QScopeGuard>
6
7#include <QtQuick/private/qquickabstractpaletteprovider_p.h>
8#include <QtQuick/private/qquickpalette_p.h>
9#include <QtQuick/private/qquickpalettecolorprovider_p.h>
10
12
25
201 : QObject(&parent)
202 , m_groupTag(defaultGroupTag())
203 , m_colorProvider(parent.colorProvider().shared_from_this())
204{
205}
206
211
216
221
226
228{
229 return color(QPalette::Base);
230}
231
236
241
246
251
256
261
266
271
276
281
286
288{
289 return color(QPalette::Dark);
290}
291
296
301
306
311
316
321
326
331
336
341
346
348{
349 return color(QPalette::Link);
350}
351
356
361
366
371
376
378{
379 return color(QPalette::Mid);
380}
381
386
391
396
401
406
411
416
421
423{
424 return color(QPalette::Text);
425}
426
431
436
441
446
451
456
461
466
471
476
481
486
491
496
501
503{
504 setColor(QPalette::PlaceholderText, color, &QQuickColorGroup::placeholderTextChanged);
505}
506
508{
509 resetColor(QPalette::PlaceholderText, &QQuickColorGroup::placeholderTextChanged);
510}
511
516
518{
519 setColor(QPalette::Accent, color, &QQuickColorGroup::accentChanged);
520}
521
523{
524 resetColor(QPalette::Accent, &QQuickColorGroup::accentChanged);
525}
526
528{
529 return m_groupTag;
530}
531
533 : QObject(parent)
534 , m_groupTag(defaultGroupTag())
535 , m_colorProvider(std::make_shared<QQuickPaletteColorProvider>())
536{
537}
538
540{
541 if (m_groupTag != tag) {
542 m_groupTag = tag;
543 Q_EMIT changed();
544 }
545}
546
548{
549 Q_ASSERT(m_colorProvider);
550 return *m_colorProvider;
551}
552
554{
555 return const_cast<QQuickPaletteColorProvider &>(
556 const_cast<const QQuickColorGroup*>(this)->colorProvider());
557}
558
563
564QColor QQuickColorGroup::color(QPalette::ColorRole role) const
565{
566 return colorProvider().color(currentColorGroup(), role);
567}
568
569void QQuickColorGroup::setColor(QPalette::ColorRole role, QColor color, Notifier notifier)
570{
571 if (colorProvider().setColor(groupTag(), role, color)) {
572 Q_EMIT (this->*notifier)();
573 Q_EMIT changed();
574 }
575}
576
577void QQuickColorGroup::resetColor(QPalette::ColorRole role, Notifier notifier)
578{
579 if (colorProvider().resetColor(groupTag(), role)) {
580 Q_EMIT (this->*notifier)();
581 Q_EMIT changed();
582 }
583}
584
586
587#include "moc_qquickcolorgroup_p.cpp"
DarwinBluetooth::LECBManagerNotifier * notifier
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\inmodule QtCore
Definition qobject.h:103
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:346
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Definition qpalette.h:49
@ HighlightedText
Definition qpalette.h:53
@ ToolTipBase
Definition qpalette.h:57
@ BrightText
Definition qpalette.h:52
@ AlternateBase
Definition qpalette.h:55
@ ButtonText
Definition qpalette.h:52
@ WindowText
Definition qpalette.h:51
@ Highlight
Definition qpalette.h:53
@ ToolTipText
Definition qpalette.h:57
@ PlaceholderText
Definition qpalette.h:58
@ Midlight
Definition qpalette.h:51
@ LinkVisited
Definition qpalette.h:54
QQuickColorGroup(QObject *parent=nullptr)
virtual QPalette::ColorGroup currentColorGroup() const
QPalette::ColorGroup groupTag() const
void setAccent(const QColor &color)
void setShadow(const QColor &color)
void setHighlightedText(const QColor &color)
void setHighlight(const QColor &color)
void setButtonText(const QColor &color)
void linkVisitedChanged()
void setButton(const QColor &color)
void setBase(const QColor &color)
void setPlaceholderText(const QColor &color)
void buttonTextChanged()
void setMid(const QColor &color)
void brightTextChanged()
void setMidlight(const QColor &color)
static QQuickColorGroup * createWithParent(QQuickPalette &parent)
void setLinkVisited(const QColor &color)
void setGroupTag(QPalette::ColorGroup tag)
const QQuickPaletteColorProvider & colorProvider() const
void setBrightText(const QColor &color)
void setLight(const QColor &color)
void toolTipTextChanged()
void setAlternateBase(const QColor &color)
void setLink(const QColor &color)
void windowTextChanged()
void setText(const QColor &color)
void alternateBaseChanged()
void setToolTipText(const QColor &color)
void setDark(const QColor &color)
void highlightChanged()
void midlightChanged()
void toolTipBaseChanged()
void setToolTipBase(const QColor &color)
void setWindowText(const QColor &color)
void setWindow(const QColor &color)
void highlightedTextChanged()
const QColor & color(QPalette::ColorGroup group, QPalette::ColorRole role) const
Contains color groups for each QML item state. \inmodule QtQuick.
Combined button and popup list for selecting options.
AudioChannelLayoutTag tag
GLuint color
[2]
static QQmlColorProvider * colorProvider
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_EMIT