aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicknativestyle/items/qquickstyleitemradiodelegate.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/quicknativestyle/items/qquickstyleitemradiodelegate.cpp')
-rw-r--r--src/quicknativestyle/items/qquickstyleitemradiodelegate.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/quicknativestyle/items/qquickstyleitemradiodelegate.cpp b/src/quicknativestyle/items/qquickstyleitemradiodelegate.cpp
new file mode 100644
index 0000000000..a4325cfe15
--- /dev/null
+++ b/src/quicknativestyle/items/qquickstyleitemradiodelegate.cpp
@@ -0,0 +1,29 @@
+// Copyright (C) 2023 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
+
+#include "qquickstyleitemradiodelegate.h"
+
+#include <QtQuickTemplates2/private/qquickradiodelegate_p.h>
+
+QT_BEGIN_NAMESPACE
+
+void QQuickStyleItemRadioDelegate::connectToControl() const
+{
+ QQuickStyleItem::connectToControl();
+ auto radioDelegate = control<QQuickRadioDelegate>();
+ connect(radioDelegate, &QQuickRadioDelegate::downChanged, this, &QQuickStyleItem::markImageDirty);
+ connect(radioDelegate, &QQuickRadioDelegate::checkedChanged, this, &QQuickStyleItem::markImageDirty);
+}
+
+void QQuickStyleItemRadioDelegate::initStyleOption(QStyleOptionButton &styleOption) const
+{
+ initStyleOptionBase(styleOption);
+ auto radioDelegate = control<QQuickRadioDelegate>();
+
+ styleOption.state |= radioDelegate->isDown() ? QStyle::State_Sunken : QStyle::State_Raised;
+ styleOption.state |= radioDelegate->isChecked() ? QStyle::State_On : QStyle::State_Off;
+}
+
+QT_END_NAMESPACE
+
+#include "moc_qquickstyleitemradiodelegate.cpp"