on xenial help sign in
fix issues from reviews, finetune progress bar design
commit3ef6e9846967aa361cb31b60b4b75448c9fa0f99 authorMichael Zanetti <michael.zanetti@canonical.com> dateTue 12 Nov 2013, 12:53 (13 years ago) parent698ed61
4 files changed+45−11
Dash/DashPreview.qml+2 Dash/GenericScopeView.qml+6 Dash/Music/MusicPreview.qml+36−10 plugins/Unity/musicpreview.cpp+1−1
Dash/DashPreview.qml+2
@@ -25,6 +25,7 @@ Item {
2525 property alias showProcessingAction: waitingForActionMouseArea.enabled
2626
2727 property real previewWidthRatio: 0.5
28+ property bool isCurrent: false
2829
2930 property Component previewImages
3031 property Component header
@@ -36,6 +37,7 @@ Item {
3637 readonly property int columnWidth: narrowMode ? contentRow.width : (contentRow.width / 3) - contentRow.spacing
3738 readonly property int contentSpacing: units.gu(3)
3839
40+
3941 clip: true
4042
4143 function ensureVisible(item) {
Dash/GenericScopeView.qml+6
@@ -484,6 +484,12 @@ ScopeView {
484484 }
485485 }
486486
487+ Binding {
488+ target: item
489+ property: "isCurrent"
490+ value: previewListView.currentIndex == index
491+ }
492+
487493 function closePreviewSpinner() {
488494 if(item) {
489495 item.showProcessingAction = false;
Dash/Music/MusicPreview.qml+36−10
@@ -55,6 +55,13 @@ GenericPreview {
5555 Column {
5656 height: childrenRect.height
5757
58+ ThinDivider {
59+ anchors {
60+ left: parent.left
61+ right: parent.right
62+ }
63+ }
64+
5865 Repeater {
5966 id: trackRepeater
6067
@@ -115,23 +122,29 @@ GenericPreview {
115122 styleColor: "black"
116123 elide: Text.ElideRight
117124
118− // FIXME: get color values from design
119125 UbuntuShape {
120− color: "#66000000"
126+ id: progressBarFill
127+ color: UbuntuColors.orange
128+ anchors.left: progressBarImage.left
129+ anchors.right: progressBarImage.right
130+ anchors.verticalCenter: progressBarImage.verticalCenter
131+ height: units.dp(2)
132+ anchors.margins: units.dp(2)
133+ anchors.rightMargin: maxWidth - (maxWidth * audioPlayer.percent / 100) + units.dp(2)
134+ visible: progressBarImage.visible
135+ property int maxWidth: progressBarImage.width - units.dp(4)
136+ }
137+ Image {
138+ id: progressBarImage
121139 anchors {
122140 left: parent.left
123141 top: parent.bottom
124142 right: parent.right
125− topMargin: units.dp(3)
126143 }
127− height: units.dp(2)
144+ height: units.dp(6)
128145 visible: audioPlayer.playbackState != Audio.StoppedState
146+ source: "graphics/music_progress_bg.png"
129147
130− UbuntuShape {
131− color: "#dd4814"
132− anchors.fill: parent
133− anchors.rightMargin: parent.width - (parent.width * audioPlayer.percent / 100)
134− }
135148 }
136149 }
137150 Label {
@@ -161,8 +174,21 @@ GenericPreview {
161174 id: audioPlayer
162175 source: uri
163176 property real percent: audioPlayer.position * 100 / audioPlayer.duration
164− onPositionChanged: print("got percent", percent, position, duration)
165177
178+ Component.onDestruction: {
179+ audioPlayer.stop();
180+ }
181+
182+ onErrorStringChanged: print("Audio player error:", errorString)
183+
184+ }
185+ Connections {
186+ target: root
187+ onIsCurrentChanged: {
188+ if (!root.isCurrent) {
189+ audioPlayer.stop();
190+ }
191+ }
166192 }
167193 Connections {
168194 target: trackRepeater
plugins/Unity/musicpreview.cpp+1−1
@@ -39,7 +39,7 @@ void MusicPreview::setUnityPreview(unity::dash::Preview::Ptr unityPreview)
3939 Q_EMIT tracksChanged();
4040}
4141
42−MusicPreviewTrackModel *MusicPreview::tracks() const
42+MusicPreviewTrackModel* MusicPreview::tracks() const
4343{
4444 if (m_unityMusicPreview == nullptr) {
4545 qWarning() << "Preview not set";