Add back save all playlists action
This commit is contained in:
parent
21f1fe52c0
commit
3ffcc29249
@ -186,6 +186,7 @@ set(SOURCES
|
||||
dialogs/deleteconfirmationdialog.cpp
|
||||
dialogs/lastfmimportdialog.cpp
|
||||
dialogs/snapdialog.cpp
|
||||
dialogs/saveplaylistsdialog.cpp
|
||||
|
||||
widgets/autoexpandingtreeview.cpp
|
||||
widgets/busyindicator.cpp
|
||||
@ -417,6 +418,7 @@ set(HEADERS
|
||||
dialogs/deleteconfirmationdialog.h
|
||||
dialogs/lastfmimportdialog.h
|
||||
dialogs/snapdialog.h
|
||||
dialogs/saveplaylistsdialog.h
|
||||
|
||||
widgets/autoexpandingtreeview.h
|
||||
widgets/busyindicator.h
|
||||
@ -542,6 +544,7 @@ set(UI
|
||||
dialogs/userpassdialog.ui
|
||||
dialogs/lastfmimportdialog.ui
|
||||
dialogs/snapdialog.ui
|
||||
dialogs/saveplaylistsdialog.ui
|
||||
|
||||
widgets/trackslider.ui
|
||||
widgets/fileview.ui
|
||||
|
@ -460,6 +460,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
ui_->action_remove_duplicates->setIcon(IconLoader::Load("list-remove"));
|
||||
ui_->action_remove_unavailable->setIcon(IconLoader::Load("list-remove"));
|
||||
ui_->action_remove_from_playlist->setIcon(IconLoader::Load("list-remove"));
|
||||
ui_->action_save_all_playlists->setIcon(IconLoader::Load("document-save-all"));
|
||||
|
||||
// Configure
|
||||
|
||||
@ -565,7 +566,7 @@ MainWindow::MainWindow(Application *app, std::shared_ptr<SystemTrayIcon> tray_ic
|
||||
ui_->button_scrobble->setDefaultAction(ui_->action_toggle_scrobbling);
|
||||
ui_->button_love->setDefaultAction(ui_->action_love);
|
||||
|
||||
ui_->playlist->SetActions(ui_->action_new_playlist, ui_->action_load_playlist, ui_->action_save_playlist, ui_->action_clear_playlist, ui_->action_next_playlist, /* These two actions aren't associated */ ui_->action_previous_playlist /* to a button but to the main window */);
|
||||
ui_->playlist->SetActions(ui_->action_new_playlist, ui_->action_load_playlist, ui_->action_save_playlist, ui_->action_clear_playlist, ui_->action_next_playlist, /* These two actions aren't associated */ ui_->action_previous_playlist /* to a button but to the main window */, ui_->action_save_all_playlists);
|
||||
// Add the shuffle and repeat action groups to the menu
|
||||
ui_->action_shuffle_mode->setMenu(ui_->playlist_sequence->shuffle_menu());
|
||||
ui_->action_repeat_mode->setMenu(ui_->playlist_sequence->repeat_menu());
|
||||
|
@ -448,7 +448,7 @@
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>1131</width>
|
||||
<height>26</height>
|
||||
<height>23</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menu_music">
|
||||
@ -483,6 +483,7 @@
|
||||
<addaction name="action_new_playlist"/>
|
||||
<addaction name="action_save_playlist"/>
|
||||
<addaction name="action_load_playlist"/>
|
||||
<addaction name="action_save_all_playlists"/>
|
||||
<addaction name="separator"/>
|
||||
<addaction name="action_jump"/>
|
||||
<addaction name="action_clear_playlist"/>
|
||||
@ -747,6 +748,11 @@
|
||||
<string>Ctrl+Shift+O</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_save_all_playlists">
|
||||
<property name="text">
|
||||
<string>&Save all playlists...</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="action_next_playlist">
|
||||
<property name="text">
|
||||
<string>Go to next playlist tab</string>
|
||||
@ -897,7 +903,6 @@
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources>
|
||||
<include location="../../data/data.qrc"/>
|
||||
<include location="../../data/icons.qrc"/>
|
||||
</resources>
|
||||
<connections/>
|
||||
|
90
src/dialogs/saveplaylistsdialog.cpp
Normal file
90
src/dialogs/saveplaylistsdialog.cpp
Normal file
@ -0,0 +1,90 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2022, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include <QDir>
|
||||
#include <QSettings>
|
||||
#include <QFileDialog>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
#include <QMessageBox>
|
||||
|
||||
#include "saveplaylistsdialog.h"
|
||||
#include "ui_saveplaylistsdialog.h"
|
||||
|
||||
#include "playlist/playlist.h"
|
||||
|
||||
SavePlaylistsDialog::SavePlaylistsDialog(const QStringList &types, const QString &default_extension) : ui_(new Ui_SavePlaylistsDialog) {
|
||||
|
||||
ui_->setupUi(this);
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(Playlist::kSettingsGroup);
|
||||
QString last_save_path = s.value("last_save_all_path", QDir::homePath()).toString();
|
||||
QString last_save_extension = s.value("last_save_all_extension", default_extension).toString();
|
||||
s.endGroup();
|
||||
|
||||
ui_->lineedit_path->setText(last_save_path);
|
||||
ui_->combobox_type->addItems(types);
|
||||
|
||||
int index = ui_->combobox_type->findText(last_save_extension);
|
||||
if (index >= 0) {
|
||||
ui_->combobox_type->setCurrentIndex(index);
|
||||
}
|
||||
|
||||
QObject::connect(ui_->button_path, &QPushButton::clicked, this, &SavePlaylistsDialog::SelectPath);
|
||||
|
||||
}
|
||||
|
||||
SavePlaylistsDialog::~SavePlaylistsDialog() {
|
||||
delete ui_;
|
||||
}
|
||||
|
||||
void SavePlaylistsDialog::SelectPath() {
|
||||
|
||||
const QString path = QFileDialog::getExistingDirectory(nullptr, tr("Select directory for the playlists"), ui_->lineedit_path->text(), QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
|
||||
|
||||
if (path.isEmpty()) return;
|
||||
|
||||
ui_->lineedit_path->setText(path);
|
||||
|
||||
}
|
||||
|
||||
void SavePlaylistsDialog::accept() {
|
||||
|
||||
const QString path = ui_->lineedit_path->text();
|
||||
if (path.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!QDir().exists(path)) {
|
||||
QMessageBox(QMessageBox::Warning, tr("Directory does not exist."), tr("Directory does not exist."), QMessageBox::Ok).exec();
|
||||
return;
|
||||
}
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(Playlist::kSettingsGroup);
|
||||
s.setValue("last_save_all_path", path);
|
||||
s.setValue("last_save_all_extension", ui_->combobox_type->currentText());
|
||||
s.endGroup();
|
||||
|
||||
QDialog::accept();
|
||||
|
||||
}
|
50
src/dialogs/saveplaylistsdialog.h
Normal file
50
src/dialogs/saveplaylistsdialog.h
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* Copyright 2022, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
* 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/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SAVEPLAYLISTSDIALOG_H
|
||||
#define SAVEPLAYLISTSDIALOG_H
|
||||
|
||||
#include <QDialog>
|
||||
#include <QString>
|
||||
#include <QLineEdit>
|
||||
#include <QComboBox>
|
||||
|
||||
#include "ui_saveplaylistsdialog.h"
|
||||
|
||||
class SavePlaylistsDialog : public QDialog {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit SavePlaylistsDialog(const QStringList &types, const QString &default_extension);
|
||||
~SavePlaylistsDialog();
|
||||
|
||||
QString path() const { return ui_->lineedit_path->text(); }
|
||||
QString extension() const { return ui_->combobox_type->currentText(); };
|
||||
|
||||
protected:
|
||||
void accept() override;
|
||||
|
||||
private slots:
|
||||
void SelectPath();
|
||||
|
||||
private:
|
||||
Ui_SavePlaylistsDialog *ui_;
|
||||
};
|
||||
|
||||
#endif // SAVEPLAYLISTSDIALOG_H
|
145
src/dialogs/saveplaylistsdialog.ui
Normal file
145
src/dialogs/saveplaylistsdialog.ui
Normal file
@ -0,0 +1,145 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>SavePlaylistsDialog</class>
|
||||
<widget class="QDialog" name="SavePlaylistsDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>440</width>
|
||||
<height>140</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string>Select directory for saving playlists</string>
|
||||
</property>
|
||||
<property name="windowIcon">
|
||||
<iconset resource="../../data/icons.qrc">
|
||||
<normaloff>:/icons/128x128/strawberry.png</normaloff>:/icons/128x128/strawberry.png</iconset>
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_path">
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineedit_path"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="button_path">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="maximumSize">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>16777215</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="../../data/icons.qrc">
|
||||
<normaloff>:/icons/64x64/folder.png</normaloff>:/icons/64x64/folder.png</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="layout_type">
|
||||
<item>
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Type</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combobox_type"/>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</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>
|
||||
<tabstops>
|
||||
<tabstop>lineedit_path</tabstop>
|
||||
<tabstop>button_path</tabstop>
|
||||
<tabstop>combobox_type</tabstop>
|
||||
</tabstops>
|
||||
<resources>
|
||||
<include location="../../data/icons.qrc"/>
|
||||
</resources>
|
||||
<connections>
|
||||
<connection>
|
||||
<sender>buttonBox</sender>
|
||||
<signal>accepted()</signal>
|
||||
<receiver>SavePlaylistsDialog</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>SavePlaylistsDialog</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>
|
@ -132,7 +132,7 @@ PlaylistContainer::~PlaylistContainer() { delete ui_; }
|
||||
|
||||
PlaylistView *PlaylistContainer::view() const { return ui_->playlist; }
|
||||
|
||||
void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist) {
|
||||
void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *save_all_playlists) {
|
||||
|
||||
ui_->create_new->setDefaultAction(new_playlist);
|
||||
ui_->load->setDefaultAction(load_playlist);
|
||||
@ -148,6 +148,7 @@ void PlaylistContainer::SetActions(QAction *new_playlist, QAction *load_playlist
|
||||
QObject::connect(next_playlist, &QAction::triggered, this, &PlaylistContainer::GoToNextPlaylistTab);
|
||||
QObject::connect(previous_playlist, &QAction::triggered, this, &PlaylistContainer::GoToPreviousPlaylistTab);
|
||||
QObject::connect(clear_playlist, &QAction::triggered, this, &PlaylistContainer::ClearPlaylist);
|
||||
QObject::connect(save_all_playlists, &QAction::triggered, manager_, &PlaylistManager::SaveAllPlaylists);
|
||||
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ class PlaylistContainer : public QWidget {
|
||||
|
||||
static const char *kSettingsGroup;
|
||||
|
||||
void SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist);
|
||||
void SetActions(QAction *new_playlist, QAction *load_playlist, QAction *save_playlist, QAction *clear_playlist, QAction *next_playlist, QAction *previous_playlist, QAction *save_all_playlists);
|
||||
void SetManager(PlaylistManager *manager);
|
||||
void ReloadSettings();
|
||||
|
||||
|
@ -65,6 +65,7 @@
|
||||
#include "playlistview.h"
|
||||
#include "playlistsaveoptionsdialog.h"
|
||||
#include "playlistparsers/playlistparser.h"
|
||||
#include "dialogs/saveplaylistsdialog.h"
|
||||
|
||||
class ParserBase;
|
||||
|
||||
@ -271,7 +272,7 @@ void PlaylistManager::SaveWithUI(const int id, const QString &playlist_name) {
|
||||
PlaylistSettingsPage::PathType path_type = static_cast<PlaylistSettingsPage::PathType>(s.value("path_type", PlaylistSettingsPage::PathType_Automatic).toInt());
|
||||
s.endGroup();
|
||||
if (path_type == PlaylistSettingsPage::PathType_Ask_User) {
|
||||
PlaylistSaveOptionsDialog optionsdialog(nullptr);
|
||||
PlaylistSaveOptionsDialog optionsdialog;
|
||||
optionsdialog.setModal(true);
|
||||
if (optionsdialog.exec() != QDialog::Accepted) return;
|
||||
path_type = optionsdialog.path_type();
|
||||
@ -628,3 +629,35 @@ void PlaylistManager::RateCurrentSong(const float rating) {
|
||||
void PlaylistManager::RateCurrentSong2(const int rating) {
|
||||
RateCurrentSong(static_cast<float>(rating) / 5.0F);
|
||||
}
|
||||
|
||||
void PlaylistManager::SaveAllPlaylists() {
|
||||
|
||||
SavePlaylistsDialog dialog(parser()->file_extensions(PlaylistParser::Type_Save), parser()->default_extension());
|
||||
if (dialog.exec() != QDialog::Accepted) {
|
||||
return;
|
||||
}
|
||||
|
||||
const QString path = dialog.path();
|
||||
if (path.isEmpty() || !QDir().exists(path)) return;
|
||||
|
||||
QString extension = dialog.extension();
|
||||
if (extension.isEmpty()) extension = parser()->default_extension();
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(PlaylistSettingsPage::kSettingsGroup);
|
||||
PlaylistSettingsPage::PathType path_type = static_cast<PlaylistSettingsPage::PathType>(s.value("path_type", PlaylistSettingsPage::PathType_Automatic).toInt());
|
||||
s.endGroup();
|
||||
if (path_type == PlaylistSettingsPage::PathType_Ask_User) {
|
||||
PlaylistSaveOptionsDialog optionsdialog;
|
||||
optionsdialog.setModal(true);
|
||||
if (optionsdialog.exec() != QDialog::Accepted) return;
|
||||
path_type = optionsdialog.path_type();
|
||||
}
|
||||
|
||||
for (QMap<int, Data>::const_iterator it = playlists_.constBegin(); it != playlists_.constEnd(); ++it) {
|
||||
const Data &data = *it;
|
||||
const QString filepath = path + "/" + data.name + "." + extension;
|
||||
Save(it.key(), filepath, path_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -223,6 +223,8 @@ class PlaylistManager : public PlaylistManagerInterface {
|
||||
// Rate current song using 0 - 5 scale.
|
||||
void RateCurrentSong2(const int rating) override;
|
||||
|
||||
void SaveAllPlaylists();
|
||||
|
||||
private slots:
|
||||
void SetActivePlaying() override;
|
||||
void SetActivePaused() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user