Skip to content

Commit fe1bf79

Browse files
committed
Add ColorButton component
1 parent d0332b5 commit fe1bf79

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

src/uicomponents/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set(MODULE_QML_FILES
44
CustomButton.qml
55
CustomToolButton.qml
66
AccentButton.qml
7+
ColorButton.qml
78
HoverToolTip.qml
89
CustomMenuBar.qml
910
CustomMenu.qml

src/uicomponents/ColorButton.qml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-License-Identifier: GPL-3.0-or-later
2+
3+
import QtQuick
4+
import QtQuick.Controls
5+
import QtQuick.Controls.Material
6+
import ScratchCPP.Ui
7+
8+
RoundButton {
9+
property color color: Material.background
10+
id: control
11+
onColorChanged: Material.background = color
12+
13+
Rectangle {
14+
width: control.background.width
15+
height: control.background.height
16+
anchors.centerIn: parent
17+
radius: width / 2
18+
color: Qt.rgba(0, 0, 0, 0)
19+
border.color: ThemeEngine.borderColor
20+
}
21+
22+
Rectangle {
23+
visible: control.checked
24+
width: control.background.width + 6
25+
height: control.background.height + 6
26+
anchors.centerIn: parent
27+
radius: width / 2
28+
color: Qt.rgba(0, 0, 0, 0)
29+
border.color: ThemeEngine.foregroundColor
30+
}
31+
}

0 commit comments

Comments
 (0)