Navigation improvements

- fix today highlighting
- click on month name opens menu to switch month
- jump to today works
This commit is contained in:
Sebastian Kügler 2013-11-12 04:53:50 +01:00
parent 19db9c9663
commit 6134503899
4 changed files with 62 additions and 31 deletions

View File

@ -29,7 +29,8 @@ Row {
right: parent.right
}
spacing: 4
visible: false
Components.ToolButton {
id: monthright
flat: true;
@ -42,24 +43,24 @@ Row {
}
}
Components.ToolButton {
id: month
anchors.left: monthright.right
anchors.right: monthYear.left
anchors.leftMargin: 20
Loader {
id: menuLoader
}
onClicked: {
if (menuLoader.source == "") {
menuLoader.source = "MonthMenu.qml"
} else {
//menuLoader.source = ""
}
menuLoader.item.open(0, height);
}
text: monthCalendar.monthName
}
// Components.ToolButton {
// id: month
// anchors.left: monthright.right
// anchors.right: monthYear.left
// anchors.leftMargin: 20
// Loader {
// id: menuLoader
// }
// onClicked: {
// if (menuLoader.source == "") {
// menuLoader.source = "MonthMenu.qml"
// } else {
// //menuLoader.source = ""
// }
// menuLoader.item.open(0, height);
// }
// text: monthCalendar.monthName
// }
Components.ToolButton {
id: monthYear

View File

@ -34,7 +34,7 @@ DayStyle {
font.pixelSize: Math.max(theme.defaultFont.pixelSize, cellHeight / 3)
text: dayNumber
z: 99
font.bold: (containsEventItems)||(containsTodoItems) ? true: false
//font.bold: (containsEventItems)||(containsTodoItems) ? true: false
opacity: (isPreviousMonth || isNextMonth) ? 0.5: 1.0
}
MouseArea {

View File

@ -41,9 +41,10 @@ Item {
width: parent.width - (borderWidth)
height: parent.height - (borderWidth)
// anchors.fill: parent
opacity: calendarDays.selectedItem == dayStyle ? 0.8 : 0
opacity: (calendarDays.selectedItem == dayStyle || isToday(dayNumber+"/"+monthNumber+"/"+yearNumber)) ? 0.8 : 0
Behavior on opacity { NumberAnimation {} }
color: theme.highlightColor
//border.color: isToday(dayNumber+"/"+monthNumber+"/"+yearNumber) ? theme.highlightColor : "transparent"
}
Rectangle {
@ -55,7 +56,7 @@ Item {
//visible: dateMouse.containsMouse
Behavior on opacity { NumberAnimation {} }
color: theme.viewBackgroundColor
border.color: isToday(dayNumber+"/"+monthNumber+"/"+yearNumber) ? theme.highlightColor : "transparent"
//border.color: isToday(dayNumber+"/"+monthNumber+"/"+yearNumber) ? theme.highlightColor : "transparent"
}
// Rectangle {

View File

@ -27,6 +27,9 @@ Item {
height: parent.height
property string date ;
property date showDate: new Date()
property string selectedMonth
property string selectedYear
property alias calendarGrid: calendarGrid
property int mWidth: theme.mSize(theme.defaultFont).width
@ -34,7 +37,7 @@ Item {
property int borderWidth: 1
property int columns: monthCalendar.days
property int rows: 1 + monthCalendar.weeks
property int rows: monthCalendar.weeks
property int cellWidth: prefCellWidth()
property int cellHeight: prefCellHeight()
@ -49,7 +52,7 @@ Item {
property Item selectedItem
property int week;
property int firstDay: new Date(showDate.getFullYear(), showDate.getMonth(), 1).getDay()
anchors.margins: theme.largeSpacing * 3
function prefCellWidth() {
@ -74,6 +77,7 @@ Item {
function isToday(date) {
if (date == Qt.formatDateTime(new Date(), "d/M/yyyy")) {
print("!!!!!!!!!!!!!! TODAY: " + date);
return true;
}
else return false;
@ -96,13 +100,34 @@ Item {
anchors {
top: parent.top
left: calendarGrid.left
right: parent.right
//right: parent.right
leftMargin: -borderWidth
}
level: 1
opacity: 0.8
text: monthCalendar.monthName
text: monthCalendar.monthName + ", " + monthCalendar.year
MouseArea {
id: month
width: monthHeading.paintedWidth
anchors {
left: parent.left
top: parent.top
bottom: parent.bottom
}
anchors.fill: parent
Loader {
id: menuLoader
}
onClicked: {
if (menuLoader.source == "") {
menuLoader.source = "MonthMenu.qml"
} else {
//menuLoader.source = ""
}
menuLoader.item.open(0, height);
}
}
}
Calendar {
@ -114,14 +139,18 @@ Item {
startDate: "2013-08-01"
onStartDateChanged: {
//monthHeading.text = monthName
month.text = monthName
monthYear.text = year
//monthHeading.text = monthName
selectedMonth = monthName
selectedYear = year
//print("Year now: " + selectedMonth + ", " + year)
monthHeading.text = selectedMonth + ", " + year;
//monthYear.text = year
}
}
// CalendarToolbar {
//
// }
CalendarToolbar {
}
//Rectangle { anchors.fill: calendarGrid; color: "orange"; opacity: 0.3; }
DaysCalendar {