2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* This file was part of Clementine.
|
|
|
|
* Copyright 2010, David Sansome <me@davidsansome.com>
|
2021-03-20 21:14:47 +01:00
|
|
|
* Copyright 2019-2021, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* Strawberry is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Strawberry is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
|
2018-08-09 18:10:03 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QVariant>
|
|
|
|
#include <QSettings>
|
|
|
|
#include <QCheckBox>
|
|
|
|
#include <QRadioButton>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "core/iconloader.h"
|
|
|
|
#include "playlist/playlist.h"
|
2018-05-01 00:41:33 +02:00
|
|
|
#include "settingspage.h"
|
|
|
|
#include "playlistsettingspage.h"
|
|
|
|
#include "ui_playlistsettingspage.h"
|
|
|
|
|
|
|
|
class SettingsDialog;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
const char *PlaylistSettingsPage::kSettingsGroup = "Playlist";
|
|
|
|
|
2021-07-11 07:40:57 +02:00
|
|
|
PlaylistSettingsPage::PlaylistSettingsPage(SettingsDialog *dialog, QWidget *parent)
|
|
|
|
: SettingsPage(dialog, parent),
|
|
|
|
ui_(new Ui_PlaylistSettingsPage) {
|
2018-10-02 00:38:52 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
ui_->setupUi(this);
|
|
|
|
setWindowIcon(IconLoader::Load("document-new"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
PlaylistSettingsPage::~PlaylistSettingsPage() {
|
|
|
|
delete ui_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlaylistSettingsPage::Load() {
|
|
|
|
|
|
|
|
QSettings s;
|
2018-10-31 19:44:24 +01:00
|
|
|
s.beginGroup(kSettingsGroup);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2021-05-11 19:40:47 +02:00
|
|
|
ui_->checkbox_alternating_row_colors->setChecked(s.value("alternating_row_colors", true).toBool());
|
|
|
|
|
2019-08-17 00:00:12 +02:00
|
|
|
#ifdef Q_OS_MACOS
|
|
|
|
bool glow_effect = false;
|
|
|
|
#else
|
|
|
|
bool glow_effect = true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
ui_->checkbox_glowcurrenttrack->setChecked(s.value("glow_effect", glow_effect).toBool());
|
2018-10-31 19:44:24 +01:00
|
|
|
ui_->checkbox_warncloseplaylist->setChecked(s.value("warn_close_playlist", true).toBool());
|
2018-10-30 23:20:02 +01:00
|
|
|
ui_->checkbox_continueonerror->setChecked(s.value("continue_on_error", false).toBool());
|
|
|
|
ui_->checkbox_greyout_songs_startup->setChecked(s.value("greyout_songs_startup", true).toBool());
|
|
|
|
ui_->checkbox_greyout_songs_play->setChecked(s.value("greyout_songs_play", true).toBool());
|
2019-10-27 02:11:51 +01:00
|
|
|
ui_->checkbox_select_track->setChecked(s.value("select_track", false).toBool());
|
2020-01-04 06:38:25 +01:00
|
|
|
ui_->checkbox_playlist_clear->setChecked(s.value("playlist_clear", true).toBool());
|
2020-10-01 19:58:16 +02:00
|
|
|
ui_->checkbox_auto_sort->setChecked(s.value("auto_sort", false).toBool());
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
Playlist::Path path = Playlist::Path(s.value(Playlist::kPathType, Playlist::Path_Automatic).toInt());
|
|
|
|
switch (path) {
|
|
|
|
case Playlist::Path_Automatic:
|
|
|
|
ui_->radiobutton_automaticpath->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Playlist::Path_Absolute:
|
|
|
|
ui_->radiobutton_absolutepath->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Playlist::Path_Relative:
|
|
|
|
ui_->radiobutton_relativepath->setChecked(true);
|
|
|
|
break;
|
|
|
|
case Playlist::Path_Ask_User:
|
|
|
|
ui_->radiobutton_askpath->setChecked(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
ui_->checkbox_editmetadatainline->setChecked(s.value("editmetadatainline", false).toBool());
|
|
|
|
ui_->checkbox_writemetadata->setChecked(s.value(Playlist::kWriteMetadata, false).toBool());
|
2018-10-02 00:38:52 +02:00
|
|
|
|
2020-08-19 22:11:03 +02:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0)
|
2020-08-19 22:02:35 +02:00
|
|
|
ui_->checkbox_delete_files->setChecked(s.value("delete_files", false).toBool());
|
2020-08-19 22:11:03 +02:00
|
|
|
#else
|
|
|
|
ui_->checkbox_delete_files->setChecked(false);
|
|
|
|
ui_->checkbox_delete_files->hide();
|
|
|
|
#endif
|
2020-08-19 22:02:35 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
s.endGroup();
|
2018-10-02 00:38:52 +02:00
|
|
|
|
2020-05-25 23:56:54 +02:00
|
|
|
Init(ui_->layout_playlistsettingspage->parentWidget());
|
|
|
|
|
2020-10-12 17:20:18 +02:00
|
|
|
if (!QSettings().childGroups().contains(kSettingsGroup)) set_changed();
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlaylistSettingsPage::Save() {
|
2018-10-02 00:38:52 +02:00
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
Playlist::Path path = Playlist::Path_Automatic;
|
|
|
|
if (ui_->radiobutton_automaticpath->isChecked()) {
|
|
|
|
path = Playlist::Path_Automatic;
|
|
|
|
}
|
|
|
|
else if (ui_->radiobutton_absolutepath->isChecked()) {
|
|
|
|
path = Playlist::Path_Absolute;
|
|
|
|
}
|
|
|
|
else if (ui_->radiobutton_relativepath->isChecked()) {
|
|
|
|
path = Playlist::Path_Relative;
|
|
|
|
}
|
|
|
|
else if (ui_->radiobutton_askpath->isChecked()) {
|
|
|
|
path = Playlist::Path_Ask_User;
|
|
|
|
}
|
|
|
|
|
2021-02-02 21:08:58 +01:00
|
|
|
QSettings s;
|
2018-10-31 19:44:24 +01:00
|
|
|
s.beginGroup(kSettingsGroup);
|
2021-05-11 19:40:47 +02:00
|
|
|
s.setValue("alternating_row_colors", ui_->checkbox_alternating_row_colors->isChecked());
|
2018-10-31 19:44:24 +01:00
|
|
|
s.setValue("glow_effect", ui_->checkbox_glowcurrenttrack->isChecked());
|
|
|
|
s.setValue("warn_close_playlist", ui_->checkbox_warncloseplaylist->isChecked());
|
2018-10-30 23:20:02 +01:00
|
|
|
s.setValue("continue_on_error", ui_->checkbox_continueonerror->isChecked());
|
|
|
|
s.setValue("greyout_songs_startup", ui_->checkbox_greyout_songs_startup->isChecked());
|
|
|
|
s.setValue("greyout_songs_play", ui_->checkbox_greyout_songs_play->isChecked());
|
2019-10-27 02:11:51 +01:00
|
|
|
s.setValue("select_track", ui_->checkbox_select_track->isChecked());
|
2020-01-04 06:38:25 +01:00
|
|
|
s.setValue("playlist_clear", ui_->checkbox_playlist_clear->isChecked());
|
2018-02-27 18:06:05 +01:00
|
|
|
s.setValue(Playlist::kPathType, static_cast<int>(path));
|
|
|
|
s.setValue("editmetadatainline", ui_->checkbox_editmetadatainline->isChecked());
|
|
|
|
s.setValue(Playlist::kWriteMetadata, ui_->checkbox_writemetadata->isChecked());
|
2020-08-19 22:02:35 +02:00
|
|
|
s.setValue("delete_files", ui_->checkbox_delete_files->isChecked());
|
2020-10-01 19:58:16 +02:00
|
|
|
s.setValue("auto_sort", ui_->checkbox_auto_sort->isChecked());
|
2018-02-27 18:06:05 +01:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
}
|