From 5b7819f14dad917c58d7b04478eacac0f479c138 Mon Sep 17 00:00:00 2001 From: Gavin Howard Date: Tue, 12 Aug 2014 20:48:18 -0600 Subject: [PATCH] Added UI and QSettings support for playlist metadata and path types. --- src/playlist/playlist.h | 6 ++++ src/ui/behavioursettingspage.cpp | 24 +++++++++++++ src/ui/behavioursettingspage.ui | 61 +++++++++++++++++++++++++++++++- 3 files changed, 90 insertions(+), 1 deletion(-) diff --git a/src/playlist/playlist.h b/src/playlist/playlist.h index 8fab1101a..dfe8f5c4c 100644 --- a/src/playlist/playlist.h +++ b/src/playlist/playlist.h @@ -134,6 +134,12 @@ class Playlist : public QAbstractListModel { LastFM_Queued, // Track added to the queue for scrobbling }; + enum Path { + Path_Automatic = 0, // Automatically select path type + Path_Absolute, // Always use absolute paths + Path_Relative, // Always use relative paths + }; + static const char* kCddaMimeType; static const char* kRowsMimetype; static const char* kPlayNowMimetype; diff --git a/src/ui/behavioursettingspage.cpp b/src/ui/behavioursettingspage.cpp index 0e9ff9104..ef8397c57 100644 --- a/src/ui/behavioursettingspage.cpp +++ b/src/ui/behavioursettingspage.cpp @@ -133,6 +133,20 @@ void BehaviourSettingsPage::Load() { s.value("greyoutdeleted", false).toBool()); ui_->b_click_edit_inline_->setChecked( s.value("click_edit_inline", true).toBool()); + + Playlist::Path path = Playlist::Path(s.value("pathtype", Playlist::Path_Automatic).toInt()); + switch(path) { + case Playlist::Path_Automatic: + ui_->b_automatic_path->setChecked(true); + break; + case Playlist::Path_Absolute: + ui_->b_absolute_path->setChecked(true); + break; + case Playlist::Path_Relative: + ui_->b_relative_path->setChecked(true); + break; + } + ui_->b_write_metadata->setChecked(s.value("writemetadata", true).toBool()); s.endGroup(); s.beginGroup(PlaylistTabBar::kSettingsGroup); @@ -162,6 +176,14 @@ void BehaviourSettingsPage::Save() { MainWindow::PlayBehaviour menu_playmode = MainWindow::PlayBehaviour( ui_->menu_playmode->itemData(ui_->menu_playmode->currentIndex()).toInt()); + Playlist::Path path = Playlist::Path_Automatic; + if (ui_->b_automatic_path->isChecked()) + path = Playlist::Path_Automatic; + if (ui_->b_absolute_path->isChecked()) + path = Playlist::Path_Absolute; + if (ui_->b_relative_path->isChecked()) + path = Playlist::Path_Relative; + s.beginGroup(MainWindow::kSettingsGroup); s.setValue("showtray", ui_->b_show_tray_icon_->isChecked()); s.setValue("keeprunning", ui_->b_keep_running_->isChecked()); @@ -182,6 +204,8 @@ void BehaviourSettingsPage::Save() { s.beginGroup(Playlist::kSettingsGroup); s.setValue("greyoutdeleted", ui_->b_grey_out_deleted_->isChecked()); s.setValue("click_edit_inline", ui_->b_click_edit_inline_->isChecked()); + s.setValue("pathtype", int(path)); + s.setValue("writemetadata", ui_->b_write_metadata->isChecked()); s.endGroup(); s.beginGroup(PlaylistTabBar::kSettingsGroup); diff --git a/src/ui/behavioursettingspage.ui b/src/ui/behavioursettingspage.ui index 84ecd6162..5064b4934 100644 --- a/src/ui/behavioursettingspage.ui +++ b/src/ui/behavioursettingspage.ui @@ -7,7 +7,7 @@ 0 0 516 - 561 + 728 @@ -235,6 +235,65 @@ + + + + Playlist file paths should be + + + + + + Automatic + + + true + + + + + + + Absolute + + + + + + + Relative + + + + + + + Qt::Vertical + + + QSizePolicy::Fixed + + + + 20 + 10 + + + + + + + + Write Metadata + + + true + + + + + +