From c6d2e6329d6ecbc30debb4506a3df20a6a065783 Mon Sep 17 00:00:00 2001 From: Jens Persson Date: Mon, 20 Jun 2011 19:55:35 +0200 Subject: [PATCH] implemented playlist item info on qml --- data/panucci-all.conf | 6 +-- data/ui/qml/AboutDialog.qml | 2 +- data/ui/qml/Playlist.qml | 4 +- data/ui/qml/PlaylistItemInfo.qml | 111 +++++++++++++++++++++++++++++++++++++++ data/ui/qml/main.qml | 48 +++++++++++++++++ src/panucci/qmlui/qmlmain.py | 26 +++++++++ 6 files changed, 192 insertions(+), 5 deletions(-) create mode 100644 data/ui/qml/PlaylistItemInfo.qml diff --git a/data/panucci-all.conf b/data/panucci-all.conf index 152c9da..ff7c293 100644 --- a/data/panucci-all.conf +++ b/data/panucci-all.conf @@ -8,7 +8,7 @@ dual_action_button_delay = 0.5 max_recent_files = 10 lock_progress = false scrolling_labels = true -scrolling_color = fff +scrolling_color = eee seek_long = 60 seek_short = 10 seek_back = false @@ -26,9 +26,9 @@ highlight = 4312ae main_width = 500 main_height = 285 button_color = 472b83 -button_border_color = 559 +button_border_color = 7446d7 button_border_width = 6 button_radius = 10 -progress_color = 559 +progress_color = 7446d7 progress_background_color = 280671 font_size = 14 diff --git a/data/ui/qml/AboutDialog.qml b/data/ui/qml/AboutDialog.qml index 28101ce..5f50950 100644 --- a/data/ui/qml/AboutDialog.qml +++ b/data/ui/qml/AboutDialog.qml @@ -51,7 +51,7 @@ Item { x: 90 y: about_copyright.y + config.font_size + 11 font.pixelSize: config.font_size + 1 - color: "#" + config.foreground + color: "#" + config.highlight text: "" + items[3] + "" onLinkActivated: main.open_external_url(link) } diff --git a/data/ui/qml/Playlist.qml b/data/ui/qml/Playlist.qml index 6b79519..7230221 100644 --- a/data/ui/qml/Playlist.qml +++ b/data/ui/qml/Playlist.qml @@ -133,7 +133,9 @@ Item { } MouseArea { anchors.fill: parent - onClicked: {playlistArea.close()} + onClicked: { if (playlistView.currentItem) + main.playlist_item_info_callback(playlistView.currentItem.item.item_id) + } } } Rectangle { diff --git a/data/ui/qml/PlaylistItemInfo.qml b/data/ui/qml/PlaylistItemInfo.qml new file mode 100644 index 0000000..088b46e --- /dev/null +++ b/data/ui/qml/PlaylistItemInfo.qml @@ -0,0 +1,111 @@ + +import Qt 4.7 + +Item { + id: playlistItemInfoArea + signal close + property variant metadata: {"artist":"","title":"","length":"","album":"","path":""} + + MouseArea { + anchors.fill: parent + onClicked: playlistItemInfoArea.close() + } + Rectangle { + color: "#" + config.background + anchors.fill: parent + opacity: .9 + } + Text { + text: info_header_str + y: config.font_size + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: config.font_size * 1.5 + color: "#" + config.foreground + } + Flickable { + id: playlistItemInfoFlick + width: root.width + height: root.height - config.font_size - 3.5 + x: 0 + y: config.font_size * 3.5 + contentWidth: root.width * 2 + clip: true + + MouseArea { + anchors.fill: parent + onClicked: playlistItemInfoArea.close() + } + + Column { + id: leftColumn + x: config.font_size + y: 0 + spacing: config.font_size / 2 + + Text { + text: info_title_str + anchors.right: parent.right + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: info_length_str + anchors.right: parent.right + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: info_artist_str + anchors.right: parent.right + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: info_album_str + anchors.right: parent.right + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: info_filepath_str + anchors.right: parent.right + font.pixelSize: config.font_size + color: "#" + config.foreground + } + } + Column { + id: rightColumn + spacing: config.font_size / 2 + anchors { + top: leftColumn.top + left: leftColumn.right + leftMargin: config.font_size / 2 + } + Text { + text: playlistItemInfoArea.metadata["title"] + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: playlistItemInfoArea.metadata["length"] + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: playlistItemInfoArea.metadata["artist"] + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: playlistItemInfoArea.metadata["album"] + font.pixelSize: config.font_size + color: "#" + config.foreground + } + Text { + text: playlistItemInfoArea.metadata["path"] + font.pixelSize: config.font_size + color: "#" + config.foreground + } + } + } +} diff --git a/data/ui/qml/main.qml b/data/ui/qml/main.qml index 5b6c98c..3cf2b36 100644 --- a/data/ui/qml/main.qml +++ b/data/ui/qml/main.qml @@ -26,6 +26,10 @@ Rectangle { playlist.state = 'opened' playlist.items = items } + function openPlaylistItemInfo(metadata) { + playlistItemInfo.state = 'opened' + playlistItemInfo.metadata = metadata + } function openSettings() { settings.state = 'opened' } @@ -470,6 +474,50 @@ Rectangle { AnchorAnimation { duration: 150 } } } + PlaylistItemInfo { + id: playlistItemInfo + width: parent.width + opacity: 0 + + anchors { + top: parent.top + bottom: parent.bottom + } + onClose: playlistItemInfo.state = 'closed' + state: 'closed' + Behavior on opacity { NumberAnimation { duration: 300 } } + + states: [ + State { + name: 'opened' + PropertyChanges { + target: playlistItemInfo + opacity: 1 + } + AnchorChanges { + target: playlistItemInfo + anchors.right: root.right + } + }, + State { + name: 'closed' + PropertyChanges { + target: playlistItemInfo + opacity: 0 + } + AnchorChanges { + target: playlistItemInfo + anchors.right: root.left + } + StateChangeScript { + //script: controller.contextMenuClosed() + } + } + ] + transitions: Transition { + AnchorAnimation { duration: 150 } + } + } Filechooser { id: filechooser width: parent.width diff --git a/src/panucci/qmlui/qmlmain.py b/src/panucci/qmlui/qmlmain.py index 9257557..764f5a4 100644 --- a/src/panucci/qmlui/qmlmain.py +++ b/src/panucci/qmlui/qmlmain.py @@ -200,6 +200,19 @@ class PanucciGUI(QtCore.QObject, ObservableService): self.action_player_skip_forward = QtGui.QAction(QtGui.QIcon(''), _("").decode("utf-8"), self.main_window, triggered=self.player_skip_forward_callback) self.context.setContextProperty('action_player_skip_forward', self.action_player_skip_forward) + # Playlist info + self.info_header_str = _('Playlist item details').decode("utf-8") + self.context.setContextProperty('info_header_str', self.info_header_str) + self.info_title_str = _('Title:').decode("utf-8") + self.context.setContextProperty('info_title_str', self.info_title_str) + self.info_length_str = _('Length:').decode("utf-8") + self.context.setContextProperty('info_length_str', self.info_length_str) + self.info_artist_str = _('Artist:').decode("utf-8") + self.context.setContextProperty('info_artist_str', self.info_artist_str) + self.info_album_str = _('Album:').decode("utf-8") + self.context.setContextProperty('info_album_str', self.info_album_str) + self.info_filepath_str = _('Filepath:').decode("utf-8") + self.context.setContextProperty('info_filepath_str', self.info_filepath_str) def make_config(self): self.config_qml = {} @@ -333,6 +346,19 @@ class PanucciGUI(QtCore.QObject, ObservableService): return self.playlist_items + @QtCore.Slot(str) + def playlist_item_info_callback(self, item_id): + playlist_item = self.playlist.get_item_by_id(item_id) + metadata = playlist_item.metadata + metadata["length"] = util.convert_ns(metadata["length"]) + metadata["path"] = playlist_item.filepath.decode("utf-8") + for i in ["title", "artist", "album"]: + if metadata[i]: + metadata[i] = metadata[i].decode("utf-8") + else: + metadata[i] = " " + self.view.rootObject().openPlaylistItemInfo(metadata) + def settings_callback(self): self.view.rootObject().openSettings() #from panucci.qtui.qtsettingsdialog import SettingsDialog -- 2.11.4.GIT