MauiKit Calendar

DaysGrid.qml
1import QtQuick
2import QtQuick.Layouts
3import QtQuick.Controls
4
5import org.mauikit.controls as Maui
6import org.mauikit.calendar as Kalendar
7
8import "dateutils.js" as DateUtils
9
10/**
11 * @inherit QtQuick.Controls.Page
12 * @brief A control for quickly picking a date in the format of year, month and day number.
13 *
14 * @image html daysgrid.png
15 *
16 * @code
17 *
18 * Maui.ApplicationWindow
19 * {
20 * id: root
21 * title: _daysGrid.year
22 * Maui.Page
23 * {
24 * anchors.fill: parent
25 * Maui.Controls.showCSD: true
26 * title: root.title
27 *
28 * MC.DaysGrid
29 * {
30 * id: _daysGrid
31 * height: 300
32 * width: 300
33 * anchors.centerIn: parent
34 *
35 * year: 1993
36 * month: 5
37 *
38 * onDateClicked: (date) => root.title = date.toString()
39 * }
40 * }
41 * }
42 * @endcode
43 */
44Page
45{
46 id: control
47
48 /**
49 * @brief
50 */
51 property bool compact : false
52
53 /**
54 * @brief
55 */
56 readonly property alias model : _monthModel
57
58 /**
59 * @brief
60 */
61 property alias year: _monthModel.year
62
63 /**
64 * @brief
65 */
66 property alias month : _monthModel.month
67
68 /**
69 * @brief
70 * @param date
71 */
72 signal dateClicked(var date)
73
74 /**
75 * @brief
76 * @param date
77 */
78 signal dateRightClicked(var date)
79
80 title : _monthModel.monthName(control.month)
81
82 padding: control.compact ? Maui.Style.space.small : Maui.Style.defaultPadding
83
84 Kalendar.MonthModel
85 {
86 id: _monthModel
87 }
88
89 background: null
90
91 contentItem: GridLayout
92 {
93 id: _daysGrid
94
95 columns: 7
96 rows: 7
97
98 columnSpacing: control.compact ? 0 : Maui.Style.space.small
99 rowSpacing: control.compact ? 0 : Maui.Style.space.small
100
101 ButtonGroup
102 {
103 buttons: _daysGrid.children
104 }
105
106 Repeater
107 {
108 model: _monthModel
109
110 delegate: Button
111 {
112 Maui.Theme.colorSet: Maui.Theme.View
113 Maui.Theme.inherit: false
114
115 Layout.fillWidth: true
116 Layout.fillHeight: true
117
118 padding: 0
119
120 highlighted: model.isToday
121
122 checkable: true
123 checked: model.isToday
124
125 opacity: sameMonth ? 1 : 0.7
126
127 text: model.dayNumber
128
129 font.bold: model.isToday
130 font.weight: checked ? Font.Bold : Font.Normal
131 font.pointSize: control.compact ? Maui.Style.fontSizes.tiny : Maui.Style.fontSizes.medium
132
133 onClicked: control.dateClicked(model.date)
134
135 background: Rectangle
136 {
137 visible: sameMonth
138 color: checked || pressed ? Maui.Theme.highlightColor : hovered ? Maui.Theme.hoverColor : "transparent"
139 radius: Maui.Style.radiusV
140 }
141 }
142 }
143 }
144}
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 29 2024 11:53:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.