@ -23,12 +23,12 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
import org . kde . plasma . components 3.0 as PlasmaComponents3
import org . kde . plasma . extras 2.0 as PlasmaExtras
Item {
PlasmaComponents3 . Page {
id: calendar
/ / T h e " s e n s i b l e " v a l u e s
property int _minimumWidth : rootLayout . childrenRect . width + ( rootLayout . anchors . margin s * 2 )
property int _minimumHeight : rootLayout . childrenRect . height + ( rootLayout . anchors . margins * 2 )
property int _minimumWidth : rootLayout . childrenRect . width + ( calendar . padding s * 2 )
property int _minimumHeight : rootLayout . childrenRect . height + ( calendar . paddings * 2 ) + headerArea . height
Layout.minimumWidth: _minimumWidth
Layout.minimumHeight: _minimumHeight
@ -37,6 +37,7 @@ Item {
Layout.maximumWidth: _minimumWidth
Layout.maximumHeight: _minimumHeight
readonly property int paddings: units . smallSpacing
readonly property bool showAgenda: PlasmaCalendar . EventPluginsManager . enabledPlugins . length > 0
readonly property bool showClocks: plasmoid . configuration . selectedTimeZones . length > 1
@ -52,6 +53,33 @@ Item {
monthView . resetToToday ( ) ;
}
/ / H e a d e r c o n t a i n i n g d a t e a n d p i n b u t t o n
header: PlasmaExtras . PlasmoidHeading {
id: headerArea
RowLayout {
width: parent . width
PlasmaExtras . Heading {
Layout.fillWidth: true
Layout.leftMargin: calendar . paddings / / M a t c h c a l e n d a r t i t l e
level: 1
text: monthView . currentDate . toLocaleDateString ( Qt . locale ( ) , Locale . LongFormat )
}
/ / A l l o w s t h e u s e r t o k e e p t h e c a l e n d a r o p e n f o r r e f e r e n c e
PlasmaComponents3 . ToolButton {
checkable: true
checked: plasmoid . configuration . pin
onToggled: plasmoid . configuration . pin = checked
icon.name: "window-pin"
PlasmaComponents3 . ToolTip {
text: i18n ( "Keep Open" )
}
}
}
}
/ / T o p - l e v e l l a y o u t c o n t a i n i n g :
/ / - L e f t c o l u m n w i t h c u r r e n t d a t e h e a d e r , c a l e n d a r , a n d a g e n d a v i e w
/ / - R i g h t c o l u m n w i t h w o r l d c l o c k s
@ -61,84 +89,81 @@ Item {
anchors {
top: parent . top
left: parent . left
margins: units . largeSpacing
margins: calendar . paddings
}
/ / L e f t c o l u m n c o n t a i n i n g h e a d e r , c a l e n d a r , a n d e v e n t v i e w
ColumnLayout {
id: leftColumnLayout
spacing: calendar . paddings
/ / L e f t c o l u m n c o n t a i n i n g c a l e n d a r
/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
/ / T O D O K F 6 : r e m o v e t h e ` I t e m ` w r a p p e r , w h i c h t h i s i s o n l y n e e d e d s i n c e
/ / P l a s m a C a l e n d a r . M o n t h V i e w i n t e r n a l l y h a s ` a n c h o r s . f i l l : p a r e n t ` s e t o n
/ / i t , e r r o n e o u s l y e x p e c t i n g t o n e v e r b e i n a L a y o u t
Item {
Layout.fillWidth: true
Layout.minimumHeight: units . gridUnit * 22
Layout.minimumWidth: units . gridUnit * 22
PlasmaCalendar . MonthView {
id: monthView
borderOpacity: 0.25
today: root . tzDate
showWeekNumbers: plasmoid . configuration . showWeekNumbers
}
}
Layout.minimumWidth: units . gridUnit * 19
function dateString ( format ) {
return Qt . formatDate ( monthView . currentDate , format ) ;
}
/ / V e r t i c a l s e p a r a t o r l i n e b e t w e e n c o l u m n s
/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
PlasmaCore . SvgItem {
visible: rightColumn . visible
/ / H e a d e r f o r t h e c a l e n d a r : C u r r e n t d a y , m o n t h , a n d y e a r
RowLayout {
id: currentDateHeaderLayout
PlasmaComponents . Label {
height: dayAndMonthLayout . height
width: paintedWidth
font.pixelSize: dayAndMonthLayout . height
font.weight: Font . Light
text: leftColumnLayout . dateString ( "dd" )
opacity: 0.6
}
Layout.preferredWidth: naturalSize . width
Layout.fillHeight: true
/ / U n i f y m a r g i n s b e c a u s e t h e c a l e n d a r i n c l u d e s i t s o w n
Layout.topMargin: calendar . paddings
Layout.rightMargin: calendar . paddings
ColumnLayout {
id: dayAndMonthLayout
PlasmaExtras . Heading {
level: 1
elide: Text . ElideRight
text: leftColumnLayout . dateString ( "dddd" )
}
PlasmaComponents . Label {
elide: Text . ElideRight
text: Qt . locale ( ) . standaloneMonthName ( monthView . currentDate . getMonth ( ) )
+ leftColumnLayout . dateString ( " yyyy" )
}
}
elementId: "vertical-line"
svg: PlasmaCore . Svg {
imagePath: "widgets/line"
}
}
/ / H o r i z o n t a l s e p a r a t o r l i n e
PlasmaCore . SvgItem {
Layout.fillWidth: true
Layout.preferredHeight: naturalSize . height
elementId: "horizontal-line"
svg: PlasmaCore . Svg {
imagePath: "widgets/line"
}
}
/ / R i g h t c o l u m n c o n t a i n i n g a g e n d a v i e w a n d t i m e z o n e s
/ / = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
ColumnLayout {
id: rightColumn
visible: agenda . visible || worldClocks . visible
Layout.minimumWidth: units . gridUnit * 14
/ / A g e n d a v i e w s t u f f
/ / - - - - - - - - - - - - - - - - -
/ / H e a d e r t e x t
PlasmaExtras . Heading {
visible: agenda . visible
/ / C a l e n d a r
/ / T O D O K F 6 : r e m o v e t h e ` I t e m ` w r a p p e r , w h i c h t h i s i s o n l y n e e d e d s i n c e
/ / P l a s m a C a l e n d a r . M o n t h V i e w i n t e r n a l l y h a s ` a n c h o r s . f i l l : p a r e n t ` s e t o n
/ / i t , e r r o n e o u s l y e x p e c t i n g t o n e v e r b e i n a L a y o u t
Item {
id: monthViewContainer
Layout.fillWidth: true
Layout.minimumHeight: units . gridUnit * 19
PlasmaCalendar . MonthView {
id: monthView
borderOpacity: 0.25
today: root . tzDate
showWeekNumbers: plasmoid . configuration . showWeekNumbers
}
}
level: 2
text: i18n ( "Events" )
maximumLineCount: 1
elide: Text . ElideRight
}
/ / A g e n d a v i e w
/ / A g e n d a v i e w i t s e l f
Item {
id: agenda
visible: calendar . showAgenda
Layout.fillWidth: true
Layout.minimumHeight: units . gridUnit * 12
Layout.fillHeight: true
Layout.minimumHeight: units . gridUnit * 4
Layout.leftMargin: - units . smallSpacing
function formatDateWithoutYear ( date ) {
/ / U n f o r t u n a t e l l y Q t o v e r r i d e s E C M A ' s D a t e . t o L o c a l e D a t e S t r i n g ( ) ,
@ -318,7 +343,7 @@ Item {
? Qt . formatTime ( modelData . endDateTime )
: agenda . formatDateWithoutYear ( modelData . endDateTime )
horizontalAlignment: Qt . AlignRight
enabled: false
opacity: 0.7
visible: eventItem . hasTime
}
@ -333,7 +358,6 @@ Item {
Layout.column: 2
Layout.fillWidth: true
font.weight: Font . Bold
elide: Text . ElideRight
text: modelData . title
verticalAlignment: Text . AlignVCenter
@ -344,6 +368,8 @@ Item {
PlasmaComponents . Label {
id: eventDescription
opacity: 0.7
Layout.row: 1
Layout.column: 2
Layout.fillWidth: true
@ -358,13 +384,6 @@ Item {
}
}
}
section.property: "modelData.eventType"
section.delegate: PlasmaExtras . Heading {
level: 3
elide: Text . ElideRight
text: section
}
}
}
@ -381,59 +400,49 @@ Item {
visible: holidaysList . count == 0
}
}
}
/ / H o r i z o n t a l s e p a r a t o r l i n e b e t w e e n e v e n t s a n d t i m e z o n e s
PlasmaCore . SvgItem {
visible: worldClocks . visible && agenda . visible
/ / V e r t i c a l s e p a r a t o r l i n e b e t w e e n c o l u m n s
PlasmaCore . SvgItem {
visible: calendar . showClocks
Layout.preferredWidth: naturalSize . width
Layout.leftMargin: units . largeSpacing
Layout.rightMargin: units . largeSpacing
Layout.fillHeight: true
elementId: "vertical-line"
svg: PlasmaCore . Svg {
imagePath: "widgets/line"
}
}
Layout.fillWidth: true
Layout.preferredHeight: naturalSize . height
elementId: "horizontal-line"
svg: PlasmaCore . Svg {
imagePath: "widgets/line"
}
}
/ / L i s t o f w o r l d c l o c k s
ColumnLayout {
id: worldClocks
/ / C l o c k s s t u f f
/ / - - - - - - - - - - - -
/ / H e a d e r t e x t
PlasmaExtras . Heading {
visible: worldClocks . visible
visible: calendar . showClocks
Layout.fillWidth: true
Layout.minimumWidth: units . gridUnit * 12
Layout.fillHeight: true
level: 2
/ / H e a d e r t e x t
PlasmaExtras . Heading {
Layout.minimumHeight: currentDateHeaderLayout . height
verticalAlignment: Text . AlignBottom
text: i18n ( "Time Zones" )
maximumLineCount: 1
elide: Text . ElideRight
}
/ / H o r i z o n t a l s e p a r a t o r l i n e
PlasmaCore . SvgItem {
Layout.fillWidth: true
Layout.preferredHeight: naturalSize . height
elementId: "horizontal-line"
svg: PlasmaCore . Svg {
imagePath: "widgets/line"
}
}
/ / C l o c k s l i s t
/ / C l o c k s v i e w i t s e l f
PlasmaExtras . ScrollArea {
id: worldClocks
visible: calendar . showClocks
Layout.fillWidth: true
Layout.fillHeight: true
Layout.fillHeight: ! agenda . visible
Layout.leftMargin: - units . smallSpacing
ListView {
id: clocksList
width: parent . width
model: {
var timezones = [ ] ;
for ( var i = 0 ; i < plasmoid . configuration . selectedTimeZones . length ; i ++ ) {
@ -446,6 +455,10 @@ Item {
delegate: PlasmaComponents . ListItem {
id: listItem
readonly property bool isCurrentTimeZone: modelData === plasmoid . configuration . lastSelectedTimezone
separatorVisible: false
width: clocksList . width
height: units . gridUnit + units . smallSpacing
MouseArea {
anchors.fill: parent
@ -453,28 +466,23 @@ Item {
onClicked: plasmoid . configuration . lastSelectedTimezone = modelData
}
ColumnLayout {
width: clocksList . width
spacing: 0
RowLayout {
anchors.fill: parent
PlasmaExtras . Heading {
Layout.fillWidth: true
level: 3
PlasmaComponents3 . Label {
text: root . nameForZone ( modelData )
font.weight: listItem . isCurrentTimeZone ? Font.Bold : Font . Normal
maximumLineCount: 1
elide: Text . ElideRight
}
PlasmaExtras . Heading {
PlasmaComponents3 . Label {
Layout.fillWidth: true
level: 5
horizontalAlignment: Qt . AlignRight
text: root . timeForZone ( modelData )
font.weight: listItem . isCurrentTimeZone ? Font.Bold : Font . Normal
maximumLineCount: 2
elide: Text . ElideRight
opacity: 0.6
maximumLineCount: 1
}
}
}
@ -482,17 +490,4 @@ Item {
}
}
}
/ / A l l o w s t h e u s e r t o k e e p t h e c a l e n d a r o p e n f o r r e f e r e n c e
PlasmaComponents3 . ToolButton {
anchors.right: parent . right
checkable: true
checked: plasmoid . configuration . pin
onToggled: plasmoid . configuration . pin = checked
icon.name: "window-pin"
PlasmaComponents3 . ToolTip {
text: i18n ( "Keep Open" )
}
}
}