Finished the changes to the quick change menu. Everything should work.

This commit is contained in:
Gavin Howard 2014-08-15 18:52:01 -06:00
parent 1cddc696ae
commit a468085c3a
8 changed files with 65 additions and 18 deletions

View File

@ -89,6 +89,10 @@ const QRgb Playlist::kDynamicHistoryColor = qRgb(0x80, 0x80, 0x80);
const char* Playlist::kSettingsGroup = "Playlist";
const char* Playlist::kPathType = "path_type";
const char* Playlist::kWriteMetadata = "write_metadata";
const char* Playlist::kQuickChangeMenu = "quick_change_menu";
const int Playlist::kUndoStackSize = 20;
const int Playlist::kUndoItemLimit = 500;

View File

@ -152,6 +152,10 @@ class Playlist : public QAbstractListModel {
static const char* kSettingsGroup;
static const char* kPathType;
static const char* kWriteMetadata;
static const char* kQuickChangeMenu;
static const int kUndoStackSize;
static const int kUndoItemLimit;

View File

@ -48,10 +48,16 @@ PlaylistContainer::PlaylistContainer(QWidget* parent)
tab_bar_visible_(false),
tab_bar_animation_(new QTimeLine(500, this)),
no_matches_label_(nullptr),
filter_timer_(new QTimer(this)),
path_(Playlist::Path_Automatic) {
filter_timer_(new QTimer(this)) {
ui_->setupUi(this);
ui_->file_path_box->addItem("Automatic");
ui_->file_path_box->addItem("Absolute");
ui_->file_path_box->addItem("Relative");
connect(ui_->file_path_box, SIGNAL(currentIndexChanged(int)),
SLOT(PathSettingChanged()));
no_matches_label_ = new QLabel(ui_->playlist);
no_matches_label_->setAlignment(Qt::AlignTop | Qt::AlignHCenter);
no_matches_label_->setAttribute(Qt::WA_TransparentForMouseEvents);
@ -76,6 +82,8 @@ PlaylistContainer::PlaylistContainer(QWidget* parent)
settings_.beginGroup(kSettingsGroup);
ReloadSettings();
// Tab bar
ui_->tab_bar->setExpanding(false);
ui_->tab_bar->setMovable(true);
@ -102,6 +110,28 @@ PlaylistContainer::PlaylistContainer(QWidget* parent)
PlaylistContainer::~PlaylistContainer() { delete ui_; }
void PlaylistContainer::ReloadSettings() {
bool show_menu = settings_.value(Playlist::kQuickChangeMenu, true).toBool();
ui_->line->setVisible(show_menu);
ui_->file_path_label->setVisible(show_menu);
ui_->file_path_box->setVisible(show_menu);
int value = settings_.value(Playlist::kPathType, Playlist::Path_Automatic).toInt();
Playlist::Path path = static_cast<Playlist::Path>(value);
switch (path) {
case Playlist::Path_Automatic:
ui_->file_path_box->setCurrentIndex(0);
break;
case Playlist::Path_Absolute:
ui_->file_path_box->setCurrentIndex(1);
break;
case Playlist::Path_Relative:
ui_->file_path_box->setCurrentIndex(2);
break;
}
}
PlaylistView* PlaylistContainer::view() const { return ui_->playlist; }
void PlaylistContainer::SetActions(QAction* new_playlist,
@ -439,3 +469,9 @@ bool PlaylistContainer::eventFilter(QObject* objectWatched, QEvent* event) {
}
return QWidget::eventFilter(objectWatched, event);
}
void PlaylistContainer::PathSettingChanged() {
int value = ui_->file_path_box->currentIndex();
Playlist::Path path = static_cast<Playlist::Path>(value);
settings_.setValue(Playlist::kPathType, int(path));
}

View File

@ -48,6 +48,8 @@ class PlaylistContainer : public QWidget {
QAction* previous_playlist);
void SetManager(PlaylistManager* manager);
void ReloadSettings();
PlaylistView* view() const;
bool eventFilter(QObject* objectWatched, QEvent* event);
@ -92,6 +94,8 @@ signals:
void UpdateNoMatchesLabel();
void PathSettingChanged();
private:
void UpdateActiveIcon(const QIcon& icon);
void RepositionNoMatchesLabel(bool force = false);
@ -116,8 +120,6 @@ signals:
QLabel* no_matches_label_;
QTimer* filter_timer_;
Playlist::Path path_;
};
#endif // PLAYLISTCONTAINER_H

View File

@ -50,6 +50,8 @@ PlaylistManager::PlaylistManager(Application* app, QObject* parent)
connect(app_->player(), SIGNAL(Paused()), SLOT(SetActivePaused()));
connect(app_->player(), SIGNAL(Playing()), SLOT(SetActivePlaying()));
connect(app_->player(), SIGNAL(Stopped()), SLOT(SetActiveStopped()));
settings_.beginGroup(Playlist::kSettingsGroup);
}
PlaylistManager::~PlaylistManager() {
@ -196,10 +198,7 @@ void PlaylistManager::ItemsLoadedForSavePlaylist(QFutureWatcher<Song>* watcher,
}
void PlaylistManager::SaveWithUI(int id, const QString& suggested_filename) {
QSettings settings;
settings.beginGroup(Playlist::kSettingsGroup);
QString filename = settings.value("last_save_playlist").toString();
settings.endGroup();
QString filename = settings_.value("last_save_playlist").toString();
// We want to use the playlist tab name as a default filename, but in the
// same directory as the last saved file.
@ -224,13 +223,9 @@ void PlaylistManager::SaveWithUI(int id, const QString& suggested_filename) {
nullptr, tr("Save playlist", "Title of the playlist save dialog."),
filename, parser()->filters(), &default_filter);
if (filename.isNull()) {
settings.endGroup();
return;
}
if (filename.isNull()) return;
settings.setValue("last_save_playlist", filename);
settings.endGroup();
settings_.setValue("last_save_playlist", filename);
Save(id == -1 ? current_id() : id, filename);
}

View File

@ -253,6 +253,8 @@ class PlaylistManager : public PlaylistManagerInterface {
PlaylistParser* parser_;
PlaylistContainer* playlist_container_;
QSettings settings_;
// key = id
QMap<int, Data> playlists_;

View File

@ -134,7 +134,8 @@ void BehaviourSettingsPage::Load() {
ui_->b_click_edit_inline_->setChecked(
s.value("click_edit_inline", true).toBool());
Playlist::Path path = Playlist::Path(s.value("path_type", Playlist::Path_Automatic).toInt());
Playlist::Path path = Playlist::Path(s.value(Playlist::kPathType,
Playlist::Path_Automatic).toInt());
switch(path) {
case Playlist::Path_Automatic:
ui_->b_automatic_path->setChecked(true);
@ -146,7 +147,8 @@ void BehaviourSettingsPage::Load() {
ui_->b_relative_path->setChecked(true);
break;
}
ui_->b_write_metadata->setChecked(s.value("write_metadata", true).toBool());
ui_->b_write_metadata->setChecked(s.value(Playlist::kWriteMetadata, true).toBool());
ui_->b_quickchange_menu->setChecked(s.value(Playlist::kQuickChangeMenu, true).toBool());
s.endGroup();
s.beginGroup(PlaylistTabBar::kSettingsGroup);
@ -204,8 +206,9 @@ 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("path_type", int(path));
s.setValue("write_metadata", ui_->b_write_metadata->isChecked());
s.setValue(Playlist::kPathType, int(path));
s.setValue(Playlist::kWriteMetadata, ui_->b_write_metadata->isChecked());
s.setValue(Playlist::kQuickChangeMenu, ui_->b_quickchange_menu->isChecked());
s.endGroup();
s.beginGroup(PlaylistTabBar::kSettingsGroup);

View File

@ -976,6 +976,7 @@ void MainWindow::ReloadAllSettings() {
library_view_->ReloadSettings();
song_info_view_->ReloadSettings();
app_->player()->engine()->ReloadSettings();
ui_->playlist->ReloadSettings();
ui_->playlist->view()->ReloadSettings();
app_->internet_model()->ReloadSettings();
#ifdef HAVE_WIIMOTEDEV