Commit ed0ce368 authored by Claudio Cambra's avatar Claudio Cambra
Browse files

Add a due date menu in the context menu for tasks



Signed-off-by: Claudio Cambra's avatarClaudio Cambra <claudio.cambra@gmail.com>
parent 84272eb8
Pipeline #235058 passed with stage
in 4 minutes and 39 seconds
......@@ -158,6 +158,65 @@ MouseArea {
onClicked: setPriorityMenu.setPriority(9)
}
}
QQC2.Menu {
id: setDueDateMenu
title: i18n("Set due date...")
enabled: incidenceData.incidenceType === Kalendar.IncidenceWrapper.TypeTodo
z: 1001
function setDate(date) {
let wrapper = Qt.createQmlObject('import org.kde.kalendar 1.0; IncidenceWrapper {id: incidence}', this, "incidence");
wrapper.incidenceItem = Kalendar.CalendarManager.incidenceItem(mouseArea.incidenceData.incidencePtr);
if(date && !isNaN(date.getTime())) {
// Remember we have to convert from JS months (0-11) to Qt months (1-12)
wrapper.setIncidenceEndDate(date.getDate(), date.getMonth() + 1, date.getFullYear());
wrapper.allDay = true;
} else {
wrapper.incidenceEnd = new Date(undefined);
}
Kalendar.CalendarManager.editIncidence(wrapper);
}
QQC2.MenuItem {
icon.name: "edit-none"
text: i18n("None")
onClicked: setDueDateMenu.setDate(undefined)
}
QQC2.MenuItem {
icon.name: "go-jump-today"
text: i18n("Today")
onClicked: setDueDateMenu.setDate(new Date())
}
QQC2.MenuItem {
icon.name: "view-calendar-day"
text: i18n("Tomorrow")
onClicked: {
let date = new Date();
date.setDate(date.getDate() + 1);
setDueDateMenu.setDate(date);
}
}
QQC2.MenuItem {
icon.name: "view-calendar-week"
text: i18n("In a week")
onClicked: {
let date = new Date();
date.setDate(date.getDate() + 7);
setDueDateMenu.setDate(date);
}
}
QQC2.MenuItem {
icon.name: "view-calendar-month"
text: i18n("In a month")
onClicked: {
let date = new Date();
date.setMonth(date.getMonth() + 1);
setDueDateMenu.setDate(date);
}
}
}
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment