-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCalendarDialog.qml
More file actions
178 lines (147 loc) · 5.77 KB
/
CalendarDialog.qml
File metadata and controls
178 lines (147 loc) · 5.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
import QtQuick
import QtQuick.LegacyControls
import QtQuick.Layouts
TibiaDialog {
id: root
caption: qsTrId("calendar_caption")
width: 780
property var controller: null
property date todayDate: new Date()
onControllerChanged: {
if (controller != null) {
root.todayDate = controller.todayDateServer;
} else {
root.todayDate = new Date();
}
} //onControllerChanged
initialFocusItem: root
KeyNavigation.tab: root
KeyNavigation.backtab: root
onCancelPressedFunction: onCloseClicked
function onCloseClicked() {
if (controller != null) {
controller.closeButtonClicked();
}
} //function onCloseClicked
property variant events: controller != null ? controller.eventsMap : { }
ColumnLayout {
id: rootLayout
anchors { left: parent.left; top: parent.top; right: parent.right }
spacing: TibiaStyle.marginUnrelated
Item {
Layout.fillWidth: true
Layout.preferredHeight: monthNavigationLayout.height
RowLayout {
id: monthNavigationLayout
anchors.centerIn: parent
spacing: 0
TibiaButton {
Layout.preferredWidth: height
imageSource: "/images/icon-arrow.png"
imageSourceDisabled: "/images/icon-arrow-disabled.png"
enabled: calendar.minimumDate < calendar.visibleDate
onClicked: {
calendar.showPreviousMonth();
}//onClicked
} //TibiaButton
TibiaText {
Layout.preferredWidth: 120
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: calendar.__locale.standaloneMonthName(calendar.visibleMonth)
+ new Date(calendar.visibleYear, calendar.visibleMonth, 1).toLocaleDateString(calendar.__locale, " yyyy")
} //TibiaText
TibiaButton {
Layout.preferredWidth: height
imageSource: "/images/icon-arrow.png"
imageSourceDisabled: "/images/icon-arrow-disabled.png"
imageMirrored: true
enabled: calendar.visibleDate < calendar.firstDayMaximumMonth
onClicked: {
calendar.showNextMonth();
}//onClicked
} //TibiaButton
} //RowLayout
TibiaText {
anchors.right: parent.right
anchors.verticalCenter: parent.verticalCenter
text: controller != null ? controller.currentTimeServer : ""
} //TibiaText
} //Item
TibiaFrame1PixelDown {
Layout.fillWidth: true
Layout.preferredHeight: 426
CalendarOld {
id: calendar
anchors.fill: parent
anchors.margins: parent.borderWidth
anchors.rightMargin: 0
z: -1
selectedDate: root.todayDate
minimumDate: controller != null ? controller.minimumDate : new Date()
maximumDate: controller != null ? controller.maximumDate : new Date()
visibleMonth: root.todayDate.getMonth()
visibleYear: root.todayDate.getFullYear()
onVisibleMonthChanged: asyncVisibleDateUpdater.restart()
onVisibleYearChanged: asyncVisibleDateUpdater.restart()
Timer {
id: asyncVisibleDateUpdater
interval: 1
onTriggered: {
calendar.visibleDate = new Date(calendar.visibleYear,
calendar.visibleMonth,
1);
}
} //Timer
property date visibleDate: new Date()
property date firstDayMaximumMonth: new Date(maximumDate.getFullYear(), maximumDate.getMonth(), 1)
onVisibleDateChanged: {
// selectedDate is not used within the event schedule
// if it is set to a day in a month which is not the visible month this day can no longer be used to navigate to the next or previous month
// therefore we set it to the first day of the visible month just to have it out of the way.
selectedDate = visibleDate;
} //onVisibleDateChanged
locale: Qt.locale("en_GB")
dayOfWeekFormat: Locale.LongFormat
frameVisible: false
navigationBarVisible : false
style: CalendarStyle {
gridVisible: false
__gridLineWidth: 0 //should not be needed but is
background: Item { }
dayOfWeekDelegate: TibiaCalendarDayCaption {
caption: control.__locale.dayName(styleData.dayOfWeek, control.dayOfWeekFormat)
rightFrameVisible: styleData.index != 6
} //dayOfWeekDelegate:TibiaCalendarDayCaption
dayDelegate: TibiaCalendarDay {
property string dateString: styleData.date.toLocaleDateString(calendar.__locale, "yyyy-MM-dd")
//need to use .getTime() which gives the timestamp https://stackoverflow.com/a/493018/5134351
isToday: styleData.date.getTime() == root.todayDate.getTime()
isVisibleMonth: styleData.visibleMonth
dayOfMonthNumber: styleData.date.getDate()
eventModel: root.events[dateString]
rightFrameVisible: styleData.date.getDay() != 0
tooltip: controller != null ? controller.getTooltipForDay(dateString) : ""
seasonalTooltip: controller != null ? controller.getSeasonalTooltipForDay(dateString) : ""
} //dayDelegate: TibiaCalendarDay
} //style: CalendarStyle
} //Calendar
} //TibiaFrame1PixelDown
TibiaText {
text: qsTrId("calendar_serversave_explanation")
}
TibiaHorizontalSeparator {
Layout.fillWidth: true
} //TibiaHorizontalSeparator
RowLayout {
Layout.alignment: Qt.AlignRight
spacing: TibiaStyle.marginRelated
Item { Layout.fillWidth: true }
TibiaButton {
id: closeButton
text: qsTrId("close")
onClicked: root.onCloseClicked()
} // TibiaButton
} // RowLayout
} // ColumnLayout
} // TibiaDialog