1// Copyright (C) 2023 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
3
4#include "qquickstyleitemcheckdelegate.h"
5
6#include <QtQuickTemplates2/private/qquickcheckdelegate_p.h>
7
8QT_BEGIN_NAMESPACE
9
10void QQuickStyleItemCheckDelegate::connectToControl() const
11{
12 QQuickStyleItem::connectToControl();
13 auto checkDelegate = control<QQuickCheckDelegate>();
14 connect(sender: checkDelegate, signal: &QQuickCheckDelegate::downChanged, context: this, slot: &QQuickStyleItem::markImageDirty);
15 connect(sender: checkDelegate, signal: &QQuickCheckDelegate::checkStateChanged, context: this, slot: &QQuickStyleItem::markImageDirty);
16}
17
18void QQuickStyleItemCheckDelegate::initStyleOption(QStyleOptionButton &styleOption) const
19{
20 initStyleOptionBase(styleOption);
21 auto checkDelegate = control<QQuickCheckDelegate>();
22
23 styleOption.state |= checkDelegate->isDown() ? QStyle::State_Sunken : QStyle::State_Raised;
24 if (checkDelegate->isTristate() && checkDelegate->checkState() == Qt::PartiallyChecked)
25 styleOption.state |= QStyle::State_NoChange;
26 else
27 styleOption.state |= checkDelegate->isChecked() ? QStyle::State_On : QStyle::State_Off;
28}
29
30QT_END_NAMESPACE
31
32#include "moc_qquickstyleitemcheckdelegate.cpp"
33

Provided by KDAB

Privacy Policy
Start learning QML with our Intro Training
Find out more

source code of qtdeclarative/src/quicknativestyle/items/qquickstyleitemcheckdelegate.cpp