Let month menu navigate in current year

Rather than jumping back to the current year unconditionally, just navigate
inside the current year.

BUG: 342327
REVIEW: 121774
This commit is contained in:
Kai Uwe Broulik 2015-01-02 14:10:04 +01:00
parent 6f58ddc05d
commit 94ecb4ff43
2 changed files with 11 additions and 51 deletions

View File

@ -17,62 +17,21 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA.
*/ */
import QtQuick 2.0 import QtQuick 2.2
import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.components 2.0 as PlasmaComponents
PlasmaComponents.Menu { PlasmaComponents.Menu {
id: testMenu id: testMenu
property date today: new Date() property int year
// Needs to be a property since Menu doesn't accept other items than MenuItem
property Instantiator items: Instantiator {
model: 12
PlasmaComponents.MenuItem { PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(0)) text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(index))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 0, 1) onClicked: calendarBackend.displayedDate = new Date(year, index, 1)
} }
onObjectAdded: testMenu.addMenuItem(object)
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(1))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 1, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(2))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 2, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(3))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 3, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(4))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 4, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(5))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 5, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(6))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 6, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(7))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 7, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(8))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 8, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(9))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 9, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(10))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 10, 1)
}
PlasmaComponents.MenuItem {
text: capitalizeFirstLetter(Qt.locale().standaloneMonthName(11))
onClicked: calendarBackend.displayedDate = new Date(today.getFullYear(), 11, 1)
} }
// Because some locales don't have it in standaloneMonthNames, // Because some locales don't have it in standaloneMonthNames,

View File

@ -119,6 +119,7 @@ Item {
if (menuLoader.source == "") { if (menuLoader.source == "") {
menuLoader.source = "MonthMenu.qml" menuLoader.source = "MonthMenu.qml"
} }
menuLoader.item.year = selectedYear
menuLoader.item.open(0, height); menuLoader.item.open(0, height);
} }
onExited: previousPixelDelta = 0 onExited: previousPixelDelta = 0