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
=== modified file 'EventBubble.qml'
--- EventBubble.qml 2016-03-05 03:04:53 +0000
+++ EventBubble.qml 2016-03-08 15:21:43 +0000
@@ -37,17 +37,16 @@
37 property bool isLiveEditing: false37 property bool isLiveEditing: false
38 property Flickable flickable;38 property Flickable flickable;
39 property bool isEventBubble: true39 property bool isEventBubble: true
4040 property real minimumHeight: units.gu(4)
41 readonly property int minimumHeight: type == wideType41
42 ? detailsItems.timeLabelHeight + /*top-bottom margin*/ units.gu(2)42 readonly property bool isSingleLine: (infoBubble.height < (minimumHeight * 2))
43 : units.gu(2)
44
45 readonly property real startTimeInMinutes: event ? CanlendarCanvas.minutesSince(infoBubble.anchorDate, event.startDateTime) : 0.043 readonly property real startTimeInMinutes: event ? CanlendarCanvas.minutesSince(infoBubble.anchorDate, event.startDateTime) : 0.0
46 readonly property real endTimeInMinutes: event ? CanlendarCanvas.minutesSince(infoBubble.anchorDate, event.endDateTime) : 0.044 readonly property real endTimeInMinutes: event ? CanlendarCanvas.minutesSince(infoBubble.anchorDate, event.endDateTime) : 0.0
47 readonly property real durationInMinutes: endTimeInMinutes - startTimeInMinutes45 readonly property real durationInMinutes: endTimeInMinutes - startTimeInMinutes
4846
49 signal clicked(var event);47 signal clicked(var event);
5048
49
51 // keep color up-to-date50 // keep color up-to-date
52 Connections {51 Connections {
53 target: model52 target: model
@@ -87,42 +86,27 @@
87 }86 }
88 }87 }
8988
90 function setDetails() {89 function updateTitle() {
91 if(event === null || event === undefined) {90 if(event === null || event === undefined) {
92 return;91 return;
93 }92 }
9493
95 var startTime = Qt.formatTime( event.startDateTime, "hh:mm")94 var startTime = Qt.formatTime(event.startDateTime, "hh:mm")
96 var endTime = Qt.formatTime( event.endDateTime, "hh:mm")95 var endTime = Qt.formatTime(event.endDateTime, "hh:mm")
9796
98 if (type === wideType) {97 if (type === wideType) {
99 timeLabel.text = ""
100 titleLabel.text = ""
101
102 // TRANSLATORS: the first argument (%1) refers to a start time for an event,98 // TRANSLATORS: the first argument (%1) refers to a start time for an event,
103 // while the second one (%2) refers to the end time99 // while the second one (%2) refers to the end time
104 var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)100 var timeString = i18n.tr("%1 - %2").arg(startTime).arg(endTime)
105101
106 //height is less then set only event title102 //there is space for two lines
107 if( infoBubble.height > minimumHeight ) {103 if (infoBubble.isSingleLine) {
108 //on wide type show all details104 eventTitle.text = ("%1 %2").arg(timeString).arg(event.displayLabel);
109 if( infoBubble.height > titleLabel.y + titleLabel.height + units.gu(1)) {105 } else {
110 timeLabel.text = timeString106 eventTitle.text = ("%1\n%2").arg(timeString).arg(event.displayLabel);
111 titleLabel.text = "<b>" + event.displayLabel +"</b>"
112 } else if ( event.displayLabel ) {
113 // TRANSLATORS: the first argument (%1) refers to a time for an event,
114 // while the second one (%2) refers to title of event
115 timeLabel.text = i18n.tr("%1 <b>%2</b>").arg(timeString).arg(event.displayLabel);
116 }
117 } else if (event.displayLabel){
118 // TRANSLATORS: the first argument (%1) refers to a time for an event,
119 // while the second one (%2) refers to title of event
120 timeLabel.text = i18n.tr("%1 <b>%2</b>").arg(timeString).arg(event.displayLabel);
121 }107 }
122 } else {108 } else {
123 timeLabel.text = event.displayLabel;109 eventTitle.text = event.displayLabel
124 timeLabel.horizontalAlignment = Text.AlignHCenter
125 timeLabel.wrapMode = Text.WrapAtWordBoundaryOrAnywhere
126 }110 }
127 }111 }
128112
@@ -131,12 +115,14 @@
131 width = parent ? parent.width * sizeOfRow : 0115 width = parent ? parent.width * sizeOfRow : 0
132 x = depthInRow * width116 x = depthInRow * width
133 z = depthInRow117 z = depthInRow
134 height = Math.max(30, (durationInMinutes * parent.minuteHeight))118 // avoid events to be draw too small, use the font height for timeLabel plus a gu(1) as margin
119 height = Math.max(minimumHeight, durationInMinutes * parent.minuteHeight)
135 }120 }
136121
122 onIsSingleLineChanged: updateTitle()
137 onEventChanged: {123 onEventChanged: {
138 assingnBgColor();124 assingnBgColor()
139 setDetails();125 updateTitle()
140 resize()126 resize()
141 }127 }
142128
@@ -158,42 +144,17 @@
158 border.color: isLiveEditing ? "red" : "white"144 border.color: isLiveEditing ? "red" : "white"
159 }145 }
160146
161 Item {147 Label {
162 id: detailsItems148 id: eventTitle
163149
164 property alias timeLabelHeight : timeLabel.height150 anchors {
165151 fill: parent
166 width: parent.width152 margins: units.gu(0.5)
167 height: detailsColumn.height
168
169 Column {
170 id: detailsColumn
171
172 anchors {
173 top: parent.top
174 left: parent.left
175 right: parent.right
176 margins: units.gu(0.5)
177 }
178
179 Label {
180 id: timeLabel
181 objectName: "timeLabel"
182 color: "White"
183 fontSize:"small"
184 font.bold: true
185 width: parent.width
186 }
187
188 Label {
189 id: titleLabel
190 objectName: "titleLabel"
191 color: "White"
192 fontSize: "small"
193 width: parent.width
194 wrapMode: Text.WrapAtWordBoundaryOrAnywhere
195 }
196 }153 }
154 clip: true
155 fontSize: "small"
156 color: "White"
157 font.bold: true
197 }158 }
198159
199 Drag.active: dragArea.drag.active160 Drag.active: dragArea.drag.active
200161
=== modified file 'TimeLineBaseComponent.qml'
--- TimeLineBaseComponent.qml 2016-03-04 16:10:56 +0000
+++ TimeLineBaseComponent.qml 2016-03-08 15:21:43 +0000
@@ -396,6 +396,7 @@
396 flickable: root.isCurrentItem ? timeLineView : null396 flickable: root.isCurrentItem ? timeLineView : null
397 clip: true397 clip: true
398 opacity: parent.enabled ? 1.0 : 0.3398 opacity: parent.enabled ? 1.0 : 0.3
399 minimumHeight: fontMetrics.height + units.gu(1)
399400
400 // send a signal to update application current date401 // send a signal to update application current date
401 onClicked: root.dateHighlighted(event.startDateTime)402 onClicked: root.dateHighlighted(event.startDateTime)
@@ -405,4 +406,12 @@
405 }406 }
406 }407 }
407 }408 }
409
410 // used to check font size and calculate the event minimum height
411
412 FontMetrics {
413 id: fontMetrics
414 font.pixelSize: FontUtils.sizeToPixels("small")
415 }
416
408}417}

Subscribers

People subscribed via source and target branches

to status/vote changes: