1
0
mirror of https://github.com/clementine-player/Clementine synced 2025-01-31 11:35:24 +01:00

Reuse some work from Alan from pull request #4484

This commit is contained in:
Alan Briolat 2014-10-06 22:40:11 +02:00 committed by Arnaud Bienner
parent c35e573637
commit c69f2e5561
4 changed files with 221 additions and 0 deletions

View File

@ -247,6 +247,7 @@ set(SOURCES
playlist/playlistlistmodel.cpp
playlist/playlistlistview.cpp
playlist/playlistmanager.cpp
playlist/playlistsaveoptionsdialog.cpp
playlist/playlistsequence.cpp
playlist/playlisttabbar.cpp
playlist/playlistundocommands.cpp
@ -544,6 +545,7 @@ set(HEADERS
playlist/playlistlistmodel.h
playlist/playlistlistview.h
playlist/playlistmanager.h
playlist/playlistsaveoptionsdialog.h
playlist/playlistsequence.h
playlist/playlisttabbar.h
playlist/playlistview.h
@ -707,6 +709,7 @@ set(UI
playlist/dynamicplaylistcontrols.ui
playlist/playlistcontainer.ui
playlist/playlistsaveoptionsdialog.ui
playlist/playlistlistcontainer.ui
playlist/playlistsequence.ui
playlist/queuemanager.ui

View File

@ -0,0 +1,72 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine 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.
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#include "playlistsaveoptionsdialog.h"
#include "ui_playlistsaveoptionsdialog.h"
#include "playlistparsers/parserbase.h"
#include <QSettings>
const char* PlaylistSaveOptionsDialog::kSettingsGroup =
"PlaylistSaveOptionsDialog";
PlaylistSaveOptionsDialog::PlaylistSaveOptionsDialog(QWidget* parent)
: QDialog(parent), ui(new Ui::PlaylistSaveOptionsDialog) {
ui->setupUi(this);
ui->filePaths->addItem(tr("Automatic"), PlaylistSaveOptions::Paths_Automatic);
ui->filePaths->addItem(tr("Relative"), PlaylistSaveOptions::Paths_Relative);
ui->filePaths->addItem(tr("Absolute"), PlaylistSaveOptions::Paths_Absolute);
ui->pathSeparators->addItem(tr("Automatic"),
PlaylistSaveOptions::Separators_Automatic);
ui->pathSeparators->addItem(tr("Windows-style") + " (\\)",
PlaylistSaveOptions::Separators_Windows);
ui->pathSeparators->addItem(tr("Unix-style") + " (/)",
PlaylistSaveOptions::Separators_Unix);
QSettings s;
s.beginGroup(kSettingsGroup);
ui->filePaths->setCurrentIndex(ui->filePaths->findData(
s.value("file_paths", PlaylistSaveOptions::Paths_Automatic)));
ui->pathSeparators->setCurrentIndex(ui->pathSeparators->findData(
s.value("path_separators", PlaylistSaveOptions::Separators_Automatic)));
}
PlaylistSaveOptionsDialog::~PlaylistSaveOptionsDialog() { delete ui; }
void PlaylistSaveOptionsDialog::accept() {
QSettings s;
s.beginGroup(kSettingsGroup);
s.setValue("file_paths",
ui->filePaths->itemData(ui->filePaths->currentIndex()).toInt());
s.setValue(
"path_separators",
ui->pathSeparators->itemData(ui->pathSeparators->currentIndex()).toInt());
QDialog::accept();
}
PlaylistSaveOptions PlaylistSaveOptionsDialog::options() const {
PlaylistSaveOptions o;
o.filePathStyle = static_cast<PlaylistSaveOptions::FilePathStyle>(
ui->filePaths->itemData(ui->filePaths->currentIndex()).toInt());
o.pathSeparatorStyle = static_cast<PlaylistSaveOptions::PathSeparatorStyle>(
ui->pathSeparators->itemData(ui->pathSeparators->currentIndex()).toInt());
return o;
}

View File

@ -0,0 +1,45 @@
/* This file is part of Clementine.
Copyright 2010, David Sansome <me@davidsansome.com>
Clementine 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.
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLAYLISTSAVEOPTIONSDIALOG_H
#define PLAYLISTSAVEOPTIONSDIALOG_H
#include <QDialog>
struct PlaylistSaveOptions;
namespace Ui {
class PlaylistSaveOptionsDialog;
}
class PlaylistSaveOptionsDialog : public QDialog {
Q_OBJECT
public:
explicit PlaylistSaveOptionsDialog(QWidget* parent = 0);
~PlaylistSaveOptionsDialog();
void accept();
PlaylistSaveOptions options() const;
private:
static const char* kSettingsGroup;
Ui::PlaylistSaveOptionsDialog* ui;
};
#endif // PLAYLISTSAVEOPTIONSDIALOG_H

View File

@ -0,0 +1,101 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PlaylistSaveOptionsDialog</class>
<widget class="QDialog" name="PlaylistSaveOptionsDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>348</width>
<height>114</height>
</rect>
</property>
<property name="windowTitle">
<string>Playlist options</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout" columnstretch="0,1">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>File paths</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
<string>Path separators</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QComboBox" name="filePaths"/>
</item>
<item row="1" column="1">
<widget class="QComboBox" name="pathSeparators"/>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections>
<connection>
<sender>buttonBox</sender>
<signal>accepted()</signal>
<receiver>PlaylistSaveOptionsDialog</receiver>
<slot>accept()</slot>
<hints>
<hint type="sourcelabel">
<x>248</x>
<y>254</y>
</hint>
<hint type="destinationlabel">
<x>157</x>
<y>274</y>
</hint>
</hints>
</connection>
<connection>
<sender>buttonBox</sender>
<signal>rejected()</signal>
<receiver>PlaylistSaveOptionsDialog</receiver>
<slot>reject()</slot>
<hints>
<hint type="sourcelabel">
<x>316</x>
<y>260</y>
</hint>
<hint type="destinationlabel">
<x>286</x>
<y>274</y>
</hint>
</hints>
</connection>
</connections>
</ui>