1 /*
2  * Strawberry Music Player
3  * This file was part of Clementine.
4  * Copyright 2014, David Sansome <me@davidsansome.com>
5  *
6  * Strawberry is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * Strawberry is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with Strawberry.  If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #include "config.h"
22 
23 #include <QWidget>
24 #include <QDialog>
25 #include <QVariant>
26 #include <QCheckBox>
27 #include <QComboBox>
28 #include <QSettings>
29 
30 #include "playlist.h"
31 #include "playlistsaveoptionsdialog.h"
32 #include "ui_playlistsaveoptionsdialog.h"
33 
34 const char *PlaylistSaveOptionsDialog::kSettingsGroup = "PlaylistSaveOptionsDialog";
35 
PlaylistSaveOptionsDialog(QWidget * parent)36 PlaylistSaveOptionsDialog::PlaylistSaveOptionsDialog(QWidget *parent) : QDialog(parent), ui(new Ui::PlaylistSaveOptionsDialog) {
37 
38   ui->setupUi(this);
39 
40   ui->filePaths->addItem(tr("Automatic"), Playlist::Path_Automatic);
41   ui->filePaths->addItem(tr("Relative"), Playlist::Path_Relative);
42   ui->filePaths->addItem(tr("Absolute"), Playlist::Path_Absolute);
43 }
44 
~PlaylistSaveOptionsDialog()45 PlaylistSaveOptionsDialog::~PlaylistSaveOptionsDialog() { delete ui; }
46 
accept()47 void PlaylistSaveOptionsDialog::accept() {
48 
49   if (ui->remember_user_choice->isChecked()) {
50     QSettings s;
51     s.beginGroup(Playlist::kSettingsGroup);
52     s.setValue(Playlist::kPathType, ui->filePaths->itemData(ui->filePaths->currentIndex()).toInt());
53   }
54 
55   QDialog::accept();
56 
57 }
58 
path_type() const59 Playlist::Path PlaylistSaveOptionsDialog::path_type() const {
60   return static_cast<Playlist::Path>(ui->filePaths->itemData(ui->filePaths->currentIndex()).toInt());
61 }
62