Qt 6.x
The Qt SDK
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
191 : QObject(&parent)
192 , m_groupTag(defaultGroupTag())
193 , m_colorProvider(parent.colorProvider().shared_from_this())
194{
195}
196
198{
199 return groupTag();
200}
201
203{
205}
206
208{
210}
211
213{
215}
216
218{
219 return color(QPalette::Base);
220}
221
223{
225}
226
228{
230}
231
233{
235}
236
238{
240}
241
243{
245}
246
248{
249 return color(QPalette::Button);
250}
251
253{
255}
256
258{
260}
261
263{
265}
266
268{
270}
271
273{
275}
276
278{
279 return color(QPalette::Dark);
280}
281
283{
285}
286
288{
290}
291
293{
295}
296
298{
300}
301
303{
305}
306
308{
310}
311
313{
315}
316
318{
320}
321
323{
324 return color(QPalette::Light);
325}
326
328{
330}
331
333{
335}
336
338{
339 return color(QPalette::Link);
340}
341
343{
345}
346
348{
350}
351
353{
355}
356
358{
360}
361
363{
365}
366
368{
369 return color(QPalette::Mid);
370}
371
373{
375}
376
378{
380}
381
383{
385}
386
388{
390}
391
393{
395}
396
398{
399 return color(QPalette::Shadow);
400}
401
403{
405}
406
408{
410}
411
413{
414 return color(QPalette::Text);
415}
416
418{
420}
421
423{
425}
426
428{
430}
431
433{
435}
436
438{
440}
441
443{
445}
446
448{
450}
451
453{
455}
456
458{
459 return color(QPalette::Window);
460}
461
463{
465}
466
468{
470}
471
473{
475}
476
478{
480}
481
483{
485}
486
488{
490}
491
493{
494 setColor(QPalette::PlaceholderText, color, &QQuickColorGroup::placeholderTextChanged);
495}
496
498{
499 resetColor(QPalette::PlaceholderText, &QQuickColorGroup::placeholderTextChanged);
500}
501
503{
504 return m_groupTag;
505}
506
508 : QObject(parent)
509 , m_groupTag(defaultGroupTag())
510 , m_colorProvider(std::make_shared<QQuickPaletteColorProvider>())
511{
512}
513
515{
516 if (m_groupTag != tag) {
517 m_groupTag = tag;
518 Q_EMIT changed();
519 }
520}
521
523{
524 Q_ASSERT(m_colorProvider);
525 return *m_colorProvider;
526}
527
529{
530 return const_cast<QQuickPaletteColorProvider &>(
531 const_cast<const QQuickColorGroup*>(this)->colorProvider());
532}
533
535{
536 return new QQuickColorGroup(parent);
537}
538
539QColor QQuickColorGroup::color(QPalette::ColorRole role) const
540{
541 return colorProvider().color(currentColorGroup(), role);
542}
543
544void QQuickColorGroup::setColor(QPalette::ColorRole role, QColor color, Notifier notifier)
545{
546 if (colorProvider().setColor(groupTag(), role, color)) {
547 Q_EMIT (this->*notifier)();
548 Q_EMIT changed();
549 }
550}
551
552void QQuickColorGroup::resetColor(QPalette::ColorRole role, Notifier notifier)
553{
554 if (colorProvider().resetColor(groupTag(), role)) {
555 Q_EMIT (this->*notifier)();
556 Q_EMIT changed();
557 }
558}
559
561
562#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:90
QObject * parent() const
Returns a pointer to the parent object.
Definition qobject.h:311
ColorGroup
\value Disabled \value Active \value Inactive \value Normal synonym for Active
Definition qpalette.h:48
@ HighlightedText
Definition qpalette.h:52
@ ToolTipBase
Definition qpalette.h:56
@ BrightText
Definition qpalette.h:51
@ AlternateBase
Definition qpalette.h:54
@ ButtonText
Definition qpalette.h:51
@ WindowText
Definition qpalette.h:50
@ Highlight
Definition qpalette.h:52
@ ToolTipText
Definition qpalette.h:56
@ PlaceholderText
Definition qpalette.h:57
@ Midlight
Definition qpalette.h:50
@ LinkVisited
Definition qpalette.h:53
QQuickColorGroup(QObject *parent=nullptr)
virtual QPalette::ColorGroup currentColorGroup() const
QPalette::ColorGroup groupTag() const
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
static QQmlColorProvider * colorProvider
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define Q_EMIT
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent