From 9eb356a25a71812081a9d31155dbeed429d61bc8 Mon Sep 17 00:00:00 2001 From: Jens Persson Date: Wed, 22 Jun 2011 23:39:16 +0200 Subject: [PATCH] added support for themes to qml --- data/panucci-all.conf | 1 + data/theme.conf | 37 +++ data/ui/qml/AboutDialog.qml | 33 +- data/ui/qml/AppButton.qml | 4 +- data/ui/qml/ContextMenu.qml | 4 +- data/ui/qml/Filechooser.qml | 10 +- data/ui/qml/Playlist.qml | 6 +- data/ui/qml/PlaylistItemInfo.qml | 24 +- data/ui/qml/SelectableItem.qml | 2 +- data/ui/qml/Settings.qml | 628 +++++++++++++++--------------------- data/ui/qml/SettingsButton.qml | 26 ++ data/ui/qml/SettingsButtonSmall.qml | 25 ++ data/ui/qml/SleepTimer.qml | 10 +- data/ui/qml/main.qml | 16 +- setup.py | 2 +- src/panucci/__init__.py | 1 + src/panucci/qmlui/qmlmain.py | 54 ++++ src/panucci/settings.py | 7 +- 18 files changed, 462 insertions(+), 428 deletions(-) create mode 100644 data/theme.conf rewrite data/ui/qml/Settings.qml (66%) create mode 100644 data/ui/qml/SettingsButton.qml create mode 100644 data/ui/qml/SettingsButtonSmall.qml diff --git a/data/panucci-all.conf b/data/panucci-all.conf index ff7c293..98e2cfe 100644 --- a/data/panucci-all.conf +++ b/data/panucci-all.conf @@ -32,3 +32,4 @@ button_radius = 10 progress_color = 7446d7 progress_background_color = 280671 font_size = 14 +theme = black diff --git a/data/theme.conf b/data/theme.conf new file mode 100644 index 0000000..3165614 --- /dev/null +++ b/data/theme.conf @@ -0,0 +1,37 @@ +# Panucci's theme file + +[black] +background = 000 +foreground = eee +highlight = 444 +button_color = 333 +button_border_color = 666 +progress_color = 666 +progress_background_color = 222 + +[blue] +background = 000 +foreground = eee +highlight = 0D58A6 +button_color = 26517C +button_border_color = 4188D2 +progress_color = 4188D2 +progress_background_color = 04376C + +[pink] +background = 000 +foreground = eee +highlight = A600A6 +button_color = 7C1F7C +button_border_color = D235D2 +progress_color = D235D2 +progress_background_color = 6C006C + +[custom] +background = 000 +foreground = eee +highlight = 4312ae +button_color = 472b83 +button_border_color = 7446d7 +progress_color = 7446d7 +progress_background_color = 280671 diff --git a/data/ui/qml/AboutDialog.qml b/data/ui/qml/AboutDialog.qml index 5f50950..86204f8 100644 --- a/data/ui/qml/AboutDialog.qml +++ b/data/ui/qml/AboutDialog.qml @@ -11,7 +11,7 @@ Item { onClicked: aboutDialogArea.close() } Rectangle { - color: "#" + config.background + color: themeController.background anchors.fill: parent opacity: .9 } @@ -27,7 +27,7 @@ Item { y: 10 font.pixelSize: config.font_size + 3 font.weight: Font.Bold - color: "#" + config.foreground + color: themeController.foreground text: items[0] } Text { @@ -35,7 +35,7 @@ Item { x: 90 y: about_name.y + config.font_size + 13 font.pixelSize: config.font_size + 1 - color: "#" + config.foreground + color: themeController.foreground text: items[1] } Text { @@ -43,7 +43,7 @@ Item { x: 90 y: about_text.y + config.font_size + 11 font.pixelSize: config.font_size + 1 - color: "#" + config.foreground + color: themeController.foreground text: items[2] } Text { @@ -51,31 +51,8 @@ Item { x: 90 y: about_copyright.y + config.font_size + 11 font.pixelSize: config.font_size + 1 - color: "#" + config.highlight + color: themeController.highlight text: "" + items[3] + "" onLinkActivated: main.open_external_url(link) } - /* - Rectangle { - x: 90 - y: about_website.y + config.font_size + 15 - color: "#" + config.button_color - width: config.button_width - height: config.button_height - border.color: "#" + config.button_border_color - border.width: config.button_border_width - radius: 10 - smooth: true - - Image { - anchors.centerIn: parent - smooth: true - source: "close.png" - } - MouseArea { - anchors.fill: parent - onClicked: {aboutDialogArea.close()} - } - } - */ } diff --git a/data/ui/qml/AppButton.qml b/data/ui/qml/AppButton.qml index 862fffc..15705ad 100644 --- a/data/ui/qml/AppButton.qml +++ b/data/ui/qml/AppButton.qml @@ -9,9 +9,9 @@ Rectangle { id: appButton width: config.button_width height: config.button_height - color: "#" + config.button_color + color: themeController.button_color border.width: config.button_border_width - border.color: "#" + config.button_border_color + border.color: themeController.button_border_color radius: config.button_radius smooth: true diff --git a/data/ui/qml/ContextMenu.qml b/data/ui/qml/ContextMenu.qml index 6202846..8d6fcce 100644 --- a/data/ui/qml/ContextMenu.qml +++ b/data/ui/qml/ContextMenu.qml @@ -11,7 +11,7 @@ Item { anchors.fill: parent } Rectangle { - color: "#" + config.background + color: themeController.background anchors.fill: parent opacity: .9 } @@ -39,7 +39,7 @@ Item { verticalCenter: parent.verticalCenter leftMargin: config.font_size * 5 } - color: "#" + config.foreground + color: themeController.foreground font.pixelSize: parent.height * .3 text: modelData.text } diff --git a/data/ui/qml/Filechooser.qml b/data/ui/qml/Filechooser.qml index 01dbb63..0520cac 100644 --- a/data/ui/qml/Filechooser.qml +++ b/data/ui/qml/Filechooser.qml @@ -14,7 +14,7 @@ Item { anchors.fill: parent } Rectangle { - color: "#" + config.background + color: themeController.background anchors.fill: parent opacity: .9 } @@ -28,7 +28,7 @@ Item { header: Item { height: config.font_size } footer: Item { height: config.font_size } - highlight: Rectangle { color: "#" + config.highlight + highlight: Rectangle { color: themeController.highlight width: filechooserView.width height: config.font_size * 3 y: filechooserView.currentItem?filechooserView.currentItem.y:root.height @@ -51,7 +51,7 @@ Item { verticalCenter: parent.verticalCenter leftMargin: 40 } - color: "#" + config.foreground + color: themeController.foreground font.pixelSize: config.font_size text: modelData.caption } @@ -71,14 +71,14 @@ Item { height: config.font_size * 1.1 x: 0 y: root.height - config.button_height - textinput.height - config.button_border_width - color: "#" + config.progress_bg_color + color: themeController.progress_bg_color } TextInput { id: textinput width: root.width x: 5 y: root.height - config.button_height - textinput.height - config.button_border_width - color: "#" + config.foreground + color: themeController.foreground font.pixelSize: config.font_size text: filechooserArea.path } diff --git a/data/ui/qml/Playlist.qml b/data/ui/qml/Playlist.qml index 2aef2a6..6468399 100644 --- a/data/ui/qml/Playlist.qml +++ b/data/ui/qml/Playlist.qml @@ -10,7 +10,7 @@ Item { anchors.fill: parent } Rectangle { - color: "#" + config.background + color: themeController.background anchors.fill: parent opacity: .9 } @@ -23,7 +23,7 @@ Item { header: Item { height: config.font_size } footer: Item { height: config.font_size } - highlight: Rectangle { color: "#" + config.highlight + highlight: Rectangle { color: themeController.highlight width: playlistView.width height: config.font_size * 3 y: playlistView.currentItem.y @@ -39,7 +39,7 @@ Item { verticalCenter: parent.verticalCenter leftMargin: modelData.bookmark_id == "" ? config.font_size : config.font_size * 2 } - color: "#" + config.foreground + color: themeController.foreground font.pixelSize: config.font_size text: modelData.caption } diff --git a/data/ui/qml/PlaylistItemInfo.qml b/data/ui/qml/PlaylistItemInfo.qml index d465948..1633f40 100644 --- a/data/ui/qml/PlaylistItemInfo.qml +++ b/data/ui/qml/PlaylistItemInfo.qml @@ -13,7 +13,7 @@ Item { onClicked: playlistItemInfoArea.close() } Rectangle { - color: "#" + config.background + color: themeController.background anchors.fill: parent opacity: .9 } @@ -22,7 +22,7 @@ Item { y: config.font_size anchors.horizontalCenter: parent.horizontalCenter font.pixelSize: config.font_size * 1.5 - color: "#" + config.foreground + color: themeController.foreground } Flickable { id: playlistItemInfoFlick @@ -48,31 +48,31 @@ Item { text: info_title_str anchors.right: parent.right font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: info_length_str anchors.right: parent.right font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: info_artist_str anchors.right: parent.right font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: info_album_str anchors.right: parent.right font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: info_filepath_str anchors.right: parent.right font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } } Column { @@ -86,27 +86,27 @@ Item { Text { text: playlistItemInfoArea.metadata["title"] font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: playlistItemInfoArea.metadata["length"] font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: playlistItemInfoArea.metadata["artist"] font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: playlistItemInfoArea.metadata["album"] font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } Text { text: playlistItemInfoArea.metadata["path"] font.pixelSize: config.font_size - color: "#" + config.foreground + color: themeController.foreground } } } diff --git a/data/ui/qml/SelectableItem.qml b/data/ui/qml/SelectableItem.qml index 021f07d..1a774ee 100644 --- a/data/ui/qml/SelectableItem.qml +++ b/data/ui/qml/SelectableItem.qml @@ -12,7 +12,7 @@ Item { Rectangle { id: highlight opacity: mouseArea.pressed?.5:0 - color: "#" + config.highlight + color: themeController.highlight anchors.fill: parent Behavior on opacity { NumberAnimation { duration: 150 } } diff --git a/data/ui/qml/Settings.qml b/data/ui/qml/Settings.qml dissimilarity index 66% index f5e40f9..70ab134 100644 --- a/data/ui/qml/Settings.qml +++ b/data/ui/qml/Settings.qml @@ -1,360 +1,268 @@ - -import Qt 4.7 - -Item { - id: settingsArea - signal close - - MouseArea { - anchors.fill: parent - onClicked: settingsArea.close() - } - Rectangle { - color: "#" + config.background - anchors.fill: parent - opacity: .9 - } - Flickable { - width: root.width - config.button_width - config.button_border_width - height: root.height - contentWidth: root.width - config.button_width - config.button_border_width - contentHeight: config.font_size * 44.5 - clip: true - - MouseArea { - anchors.fill: parent - onClicked: settingsArea.close() - } - Text { - y: config.font_size - anchors.horizontalCenter: parent.horizontalCenter - text: main_window_str - font.pixelSize: config.font_size * 1.5 - color: "#" + config.foreground - } - Rectangle { - id: action_scrolling_labels_button - property bool checked - checked: action_scrolling_labels.checked - y: config.font_size * 3.5 - anchors.horizontalCenter: parent.horizontalCenter - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - width: parent.width / 2 - height: config.font_size * 4 - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_scrolling_labels.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { if (action_scrolling_labels_button.checked) { - action_scrolling_labels_button.checked = false - } - else { - action_scrolling_labels_button.checked = true - } - } - } - } - Rectangle { - id: action_lock_progress_button - property bool checked - checked: action_lock_progress.checked - y: config.font_size * 8.5 - anchors.horizontalCenter: parent.horizontalCenter - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - width: parent.width / 2 - height: config.font_size * 4 - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_lock_progress.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { if (action_lock_progress_button.checked) { - action_lock_progress_button.checked = false - } - else { - action_lock_progress_button.checked = true - } - } - } - } - Rectangle { - id: action_dual_action_button - property bool checked - checked: action_dual_action.checked - y: config.font_size * 13.5 - anchors.horizontalCenter: parent.horizontalCenter - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - width: parent.width / 2 - height: config.font_size * 4 - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_dual_action.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { if (action_dual_action_button.checked) { - action_dual_action_button.checked = false - } - else { - action_dual_action_button.checked = true - } - } - } - } - Text { - y: config.font_size * 19 - anchors.horizontalCenter: parent.horizontalCenter - text: playback_str - font.pixelSize: config.font_size * 1.5 - color: "#" + config.foreground - } - - Rectangle { - id: action_stay_at_end_button - property bool checked - checked: action_stay_at_end.checked - y: config.font_size * 21.5 - anchors.horizontalCenter: parent.horizontalCenter - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - width: parent.width / 2 - height: config.font_size * 4 - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_stay_at_end.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { if (action_stay_at_end_button.checked) { - action_stay_at_end_button.checked = false - } - else { - action_stay_at_end_button.checked = true - } - } - } - } - Rectangle { - id: action_seek_back_button - property bool checked - checked: action_seek_back.checked - y: config.font_size * 26.5 - anchors.horizontalCenter: parent.horizontalCenter - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - width: parent.width / 2 - height: config.font_size * 4 - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_seek_back.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { if (action_seek_back_button.checked) { - action_seek_back_button.checked = false - } - else { - action_seek_back_button.checked = true - } - } - } - } - Rectangle { - id: action_resume_all_button - property bool checked - checked: action_resume_all.checked - y: config.font_size * 31.5 - anchors.horizontalCenter: parent.horizontalCenter - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - width: parent.width / 2 - height: config.font_size * 4 - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_resume_all.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { if (action_resume_all_button.checked) { - action_resume_all_button.checked = false - } - else { - action_resume_all_button.checked = true - } - } - } - } - Text { - y: config.font_size * 37 - anchors.horizontalCenter: parent.horizontalCenter - text: play_mode_str - font.pixelSize: config.font_size * 1.5 - color: "#" + config.foreground - } - Rectangle { - id: action_play_mode_all_button - property bool checked - checked: action_play_mode_all.checked - y: config.font_size * 39.5 - x: parent.width / 25 - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - width: parent.width / 5 - height: config.font_size * 4 - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_play_mode_all.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { action_play_mode_all_button.checked = true - action_play_mode_single_button.checked = false - action_play_mode_random_button.checked = false - action_play_mode_repeat_button.checked = false - } - } - } - Rectangle { - id: action_play_mode_single_button - property bool checked - checked: action_play_mode_single.checked - width: parent.width / 5 - height: config.font_size * 4 - y: config.font_size * 39.5 - x: (parent.width / 25 * 2) + width - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_play_mode_single.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { action_play_mode_all_button.checked = false - action_play_mode_single_button.checked = true - action_play_mode_random_button.checked = false - action_play_mode_repeat_button.checked = false - } - } - } - Rectangle { - id: action_play_mode_random_button - property bool checked - checked: action_play_mode_random.checked - width: parent.width / 5 - height: config.font_size * 4 - y: config.font_size * 39.5 - x: (parent.width / 25 * 3) + (width * 2) - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_play_mode_random.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { action_play_mode_all_button.checked = false - action_play_mode_single_button.checked = false - action_play_mode_random_button.checked = true - action_play_mode_repeat_button.checked = false - } - } - } - Rectangle { - id: action_play_mode_repeat_button - property bool checked - checked: action_play_mode_repeat.checked - width: parent.width / 5 - height: config.font_size * 4 - y: config.font_size * 39.5 - x: (parent.width / 25 * 4) + (width * 3) - color: checked ? "#" + config.progress_color : "#" + config.progress_bg_color - radius: config.button_radius - smooth: true - - Text { - anchors.centerIn: parent - text: action_play_mode_repeat.text - font.pixelSize: config.font_size - color: "#" + config.foreground - } - MouseArea { - anchors.fill: parent - onClicked: { action_play_mode_all_button.checked = false - action_play_mode_single_button.checked = false - action_play_mode_random_button.checked = false - action_play_mode_repeat_button.checked = true - } - } - } - } - AppButton { - x: root.width - config.button_width - config.button_border_width - y: root.height - config.button_height - image: "apply.png" - onClicked: { var i=0 - for (i=0;i