Merge lp:~renatofilho/ubuntu-calendar-app/fix-arale-event-minimum-size into lp:ubuntu-calendar-app

Proposed by Renato Araujo Oliveira Filho
Status: Merged
Approved by: Bill Filler
Approved revision: 775
Merged at revision: 774
Proposed branch: lp:~renatofilho/ubuntu-calendar-app/fix-arale-event-minimum-size
Merge into: lp:ubuntu-calendar-app
Diff against target: 173 lines (+37/-67)
2 files modified
EventBubble.qml (+28/-67)
TimeLineBaseComponent.qml (+9/-0)
To merge this branch: bzr merge lp:~renatofilho/ubuntu-calendar-app/fix-arale-event-minimum-size
Reviewer Review Type Date Requested Status
Jenkins Bot continuous-integration Approve
Ubuntu Calendar Developers Pending
Review via email: mp+288333@code.launchpad.net

Commit message

Use font size to determine the minimum height of a event.

To post a comment you must log in.
Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
774. By Renato Araujo Oliveira Filho

Use font size to determine the minimum height of a event.

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)
775. By Renato Araujo Oliveira Filho

Use only one label for event title and time.
Use font metricts to get the font height.

Revision history for this message
Jenkins Bot (ubuntu-core-apps-jenkins-bot) wrote :
review: Approve (continuous-integration)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'EventBubble.qml'
2--- EventBubble.qml 2016-03-05 03:04:53 +0000
3+++ EventBubble.qml 2016-03-08 15:21:43 +0000
4@@ -37,17 +37,16 @@
5 property bool isLiveEditing: false
6 property Flickable flickable;
7 property bool isEventBubble: true
8-
9- readonly property int minimumHeight: type == wideType
10- ? detailsItems.timeLabelHeight + /*top-bottom margin*/ units.gu(2)
11- : units.gu(2)
12-
13+ property real minimumHeight: units.gu(4)
14+
15+ readonly property bool isSingleLine: (infoBubble.height < (minimumHeight * 2))
16 readonly property real startTimeInMinutes: event ? CanlendarCanvas.minutesSince(infoBubble.anchorDate, event.startDateTime) : 0.0
17 readonly property real endTimeInMinutes: event ? CanlendarCanvas.minutesSince(infoBubble.anchorDate, event.endDateTime) : 0.0
18 readonly property real durationInMinutes: endTimeInMinutes - startTimeInMinutes
19
20 signal clicked(var event);
21
22+
23 // keep color up-to-date
24 Connections {
25 target: model
26@@ -87,42 +86,27 @@
27 }
28 }
29
30- function setDetails() {
31+ function updateTitle() {
32 if(event === null || event === undefined) {
33 return;
34 }
35
36- var startTime = Qt.formatTime( event.startDateTime, "hh:mm")
37- var endTime = Qt.formatTime( event.endDateTime, "hh:mm")
38+ var startTime = Qt.formatTime(event.startDateTime, "hh:mm")
39+ var endTime = Qt.formatTime(event.endDateTime, "hh:mm")
40
41 if (type === wideType) {
42- timeLabel.text = ""
43- titleLabel.text = ""
44-
45 // TRANSLATORS: the first argument (%1) refers to a start time for an event,
46 // while the second one (%2) refers to the end time
47 var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)
48
49- //height is less then set only event title
50- if( infoBubble.height > minimumHeight ) {
51- //on wide type show all details
52- if( infoBubble.height > titleLabel.y + titleLabel.height + units.gu(1)) {
53- timeLabel.text = timeString
54- titleLabel.text = "<b>" + event.displayLabel +"</b>"
55- } else if ( event.displayLabel ) {
56- // TRANSLATORS: the first argument (%1) refers to a time for an event,
57- // while the second one (%2) refers to title of event
58- timeLabel.text = i18n.tr("%1 <b>%2</b>").arg(timeString).arg(event.displayLabel);
59- }
60- } else if (event.displayLabel){
61- // TRANSLATORS: the first argument (%1) refers to a time for an event,
62- // while the second one (%2) refers to title of event
63- timeLabel.text = i18n.tr("%1 <b>%2</b>").arg(timeString).arg(event.displayLabel);
64+ //there is space for two lines
65+ if (infoBubble.isSingleLine) {
66+ eventTitle.text = ("%1 %2").arg(timeString).arg(event.displayLabel);
67+ } else {
68+ eventTitle.text = ("%1\n%2").arg(timeString).arg(event.displayLabel);
69 }
70 } else {
71- timeLabel.text = event.displayLabel;
72- timeLabel.horizontalAlignment = Text.AlignHCenter
73- timeLabel.wrapMode = Text.WrapAtWordBoundaryOrAnywhere
74+ eventTitle.text = event.displayLabel
75 }
76 }
77
78@@ -131,12 +115,14 @@
79 width = parent ? parent.width * sizeOfRow : 0
80 x = depthInRow * width
81 z = depthInRow
82- height = Math.max(30, (durationInMinutes * parent.minuteHeight))
83+ // avoid events to be draw too small, use the font height for timeLabel plus a gu(1) as margin
84+ height = Math.max(minimumHeight, durationInMinutes * parent.minuteHeight)
85 }
86
87+ onIsSingleLineChanged: updateTitle()
88 onEventChanged: {
89- assingnBgColor();
90- setDetails();
91+ assingnBgColor()
92+ updateTitle()
93 resize()
94 }
95
96@@ -158,42 +144,17 @@
97 border.color: isLiveEditing ? "red" : "white"
98 }
99
100- Item {
101- id: detailsItems
102-
103- property alias timeLabelHeight : timeLabel.height
104-
105- width: parent.width
106- height: detailsColumn.height
107-
108- Column {
109- id: detailsColumn
110-
111- anchors {
112- top: parent.top
113- left: parent.left
114- right: parent.right
115- margins: units.gu(0.5)
116- }
117-
118- Label {
119- id: timeLabel
120- objectName: "timeLabel"
121- color: "White"
122- fontSize:"small"
123- font.bold: true
124- width: parent.width
125- }
126-
127- Label {
128- id: titleLabel
129- objectName: "titleLabel"
130- color: "White"
131- fontSize: "small"
132- width: parent.width
133- wrapMode: Text.WrapAtWordBoundaryOrAnywhere
134- }
135+ Label {
136+ id: eventTitle
137+
138+ anchors {
139+ fill: parent
140+ margins: units.gu(0.5)
141 }
142+ clip: true
143+ fontSize: "small"
144+ color: "White"
145+ font.bold: true
146 }
147
148 Drag.active: dragArea.drag.active
149
150=== modified file 'TimeLineBaseComponent.qml'
151--- TimeLineBaseComponent.qml 2016-03-04 16:10:56 +0000
152+++ TimeLineBaseComponent.qml 2016-03-08 15:21:43 +0000
153@@ -396,6 +396,7 @@
154 flickable: root.isCurrentItem ? timeLineView : null
155 clip: true
156 opacity: parent.enabled ? 1.0 : 0.3
157+ minimumHeight: fontMetrics.height + units.gu(1)
158
159 // send a signal to update application current date
160 onClicked: root.dateHighlighted(event.startDateTime)
161@@ -405,4 +406,12 @@
162 }
163 }
164 }
165+
166+ // used to check font size and calculate the event minimum height
167+
168+ FontMetrics {
169+ id: fontMetrics
170+ font.pixelSize: FontUtils.sizeToPixels("small")
171+ }
172+
173 }

Subscribers

People subscribed via source and target branches

to status/vote changes: