user-friendly name for 'Open in new playlist' playlists (fixes issue #1445)
This commit is contained in:
parent
e67f39cedb
commit
0182829223
@ -10,7 +10,7 @@ class DigitallyImportedService(DigitallyImportedServiceBase):
|
|||||||
HOMEPAGE_NAME = "di.fm"
|
HOMEPAGE_NAME = "di.fm"
|
||||||
STREAM_LIST_URL = QUrl("http://listen.di.fm/")
|
STREAM_LIST_URL = QUrl("http://listen.di.fm/")
|
||||||
ICON_FILENAME = "icon-small.png"
|
ICON_FILENAME = "icon-small.png"
|
||||||
SERVICE_NAME = "digitally_imported"
|
SERVICE_NAME = "DigitallyImported"
|
||||||
SERVICE_DESCRIPTION = "Digitally Imported"
|
SERVICE_DESCRIPTION = "Digitally Imported"
|
||||||
|
|
||||||
# These have to be in the same order as in the settings dialog
|
# These have to be in the same order as in the settings dialog
|
||||||
|
@ -12,7 +12,7 @@ class SkyFmService(DigitallyImportedServiceBase):
|
|||||||
HOMEPAGE_NAME = "sky.fm"
|
HOMEPAGE_NAME = "sky.fm"
|
||||||
STREAM_LIST_URL = QUrl("http://listen.sky.fm/")
|
STREAM_LIST_URL = QUrl("http://listen.sky.fm/")
|
||||||
ICON_FILENAME = "icon-sky.png"
|
ICON_FILENAME = "icon-sky.png"
|
||||||
SERVICE_NAME = "sky_fm"
|
SERVICE_NAME = "SKY.fm"
|
||||||
SERVICE_DESCRIPTION = "SKY.fm"
|
SERVICE_DESCRIPTION = "SKY.fm"
|
||||||
|
|
||||||
HASHKEY_RE = re.compile(r'hashKey\s*=\s*\'([0-9a-f]+)\'')
|
HASHKEY_RE = re.compile(r'hashKey\s*=\s*\'([0-9a-f]+)\'')
|
||||||
|
@ -25,11 +25,11 @@ class MimeData : public QMimeData {
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
MimeData(bool clear = false, bool play_now = false,
|
MimeData(bool clear = false, bool play_now = false,
|
||||||
bool enqueue = false, bool new_playlist = false)
|
bool enqueue = false, const QString& name_for_new_playlist_ = QString())
|
||||||
: clear_first_(clear),
|
: clear_first_(clear),
|
||||||
play_now_(play_now),
|
play_now_(play_now),
|
||||||
enqueue_now_(enqueue),
|
enqueue_now_(enqueue),
|
||||||
new_playlist_(new_playlist),
|
name_for_new_playlist_(name_for_new_playlist_),
|
||||||
from_doubleclick_(false) {}
|
from_doubleclick_(false) {}
|
||||||
|
|
||||||
// If this is set then the playlist will be cleared before these songs
|
// If this is set then the playlist will be cleared before these songs
|
||||||
@ -44,8 +44,9 @@ public:
|
|||||||
// If this is set then the items are added to the queue after being inserted.
|
// If this is set then the items are added to the queue after being inserted.
|
||||||
bool enqueue_now_;
|
bool enqueue_now_;
|
||||||
|
|
||||||
// If this is set then the items are inserted into a newly created playlist.
|
// If this is not empty then the items are inserted into a newly created playlist
|
||||||
bool new_playlist_;
|
// with this name.
|
||||||
|
QString name_for_new_playlist_;
|
||||||
|
|
||||||
// This can be set if this MimeData goes via MainWindow (ie. it is created
|
// This can be set if this MimeData goes via MainWindow (ie. it is created
|
||||||
// manually in a double-click). The MainWindow will set the above three
|
// manually in a double-click). The MainWindow will set the above three
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "core/mimedata.h"
|
#include "core/mimedata.h"
|
||||||
#include "library/librarydirectorymodel.h"
|
#include "library/librarydirectorymodel.h"
|
||||||
#include "library/librarymodel.h"
|
#include "library/librarymodel.h"
|
||||||
|
#include "library/libraryview.h"
|
||||||
#include "ui/iconloader.h"
|
#include "ui/iconloader.h"
|
||||||
#include "ui/organisedialog.h"
|
#include "ui/organisedialog.h"
|
||||||
#include "ui/organiseerrordialog.h"
|
#include "ui/organiseerrordialog.h"
|
||||||
@ -370,7 +371,7 @@ void DeviceView::AddToPlaylist() {
|
|||||||
void DeviceView::OpenInNewPlaylist() {
|
void DeviceView::OpenInNewPlaylist() {
|
||||||
QMimeData* data = model()->mimeData(selectedIndexes());
|
QMimeData* data = model()->mimeData(selectedIndexes());
|
||||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||||
mime_data->new_playlist_ = true;
|
mime_data->name_for_new_playlist_ = LibraryView::GetNameForNewPlaylist(GetSelectedSongs());
|
||||||
}
|
}
|
||||||
emit AddToPlaylistSignal(data);
|
emit AddToPlaylistSignal(data);
|
||||||
}
|
}
|
||||||
|
@ -37,8 +37,9 @@
|
|||||||
#include <QHelpEvent>
|
#include <QHelpEvent>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QSortFilterProxyModel>
|
#include <QSet>
|
||||||
#include <QSettings>
|
#include <QSettings>
|
||||||
|
#include <QSortFilterProxyModel>
|
||||||
#include <QToolTip>
|
#include <QToolTip>
|
||||||
#include <QWhatsThis>
|
#include <QWhatsThis>
|
||||||
|
|
||||||
@ -374,7 +375,7 @@ void LibraryView::AddToPlaylistEnqueue() {
|
|||||||
void LibraryView::OpenInNewPlaylist() {
|
void LibraryView::OpenInNewPlaylist() {
|
||||||
QMimeData* data = model()->mimeData(selectedIndexes());
|
QMimeData* data = model()->mimeData(selectedIndexes());
|
||||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||||
mime_data->new_playlist_ = true;
|
mime_data->name_for_new_playlist_ = LibraryView::GetNameForNewPlaylist(GetSelectedSongs());
|
||||||
}
|
}
|
||||||
emit AddToPlaylistSignal(data);
|
emit AddToPlaylistSignal(data);
|
||||||
}
|
}
|
||||||
@ -529,3 +530,36 @@ void LibraryView::EditSmartPlaylistFinished() {
|
|||||||
const Wizard* wizard = qobject_cast<Wizard*>(sender());
|
const Wizard* wizard = qobject_cast<Wizard*>(sender());
|
||||||
library_->UpdateGenerator(context_menu_index_, wizard->CreateGenerator());
|
library_->UpdateGenerator(context_menu_index_, wizard->CreateGenerator());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString LibraryView::GetNameForNewPlaylist(const SongList& songs) {
|
||||||
|
QSet<QString> artists;
|
||||||
|
QSet<QString> albums;
|
||||||
|
|
||||||
|
foreach(const Song& song, songs) {
|
||||||
|
artists << (song.artist().isEmpty()
|
||||||
|
? tr("Unknown")
|
||||||
|
: song.artist());
|
||||||
|
albums << (song.album().isEmpty()
|
||||||
|
? tr("Unknown")
|
||||||
|
: song.album());
|
||||||
|
|
||||||
|
if(artists.size() > 1) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool various_artists = artists.size() > 1;
|
||||||
|
|
||||||
|
QString result;
|
||||||
|
if(various_artists) {
|
||||||
|
result = tr("Various artists");
|
||||||
|
} else {
|
||||||
|
result = artists.values().at(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!various_artists && albums.size() == 1) {
|
||||||
|
result += " - " + albums.toList()[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@ -70,6 +70,10 @@ class LibraryView : public AutoExpandingTreeView {
|
|||||||
void keyboardSearch(const QString &search);
|
void keyboardSearch(const QString &search);
|
||||||
void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
|
void scrollTo(const QModelIndex& index, ScrollHint hint = EnsureVisible);
|
||||||
|
|
||||||
|
// Returns a pretty automatic name for playlist created from the given list of
|
||||||
|
// songs.
|
||||||
|
static QString GetNameForNewPlaylist(const SongList& songs);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void TotalSongCountUpdated(int count);
|
void TotalSongCountUpdated(int count);
|
||||||
void ReloadSettings();
|
void ReloadSettings();
|
||||||
|
@ -94,7 +94,9 @@ void RadioService::AddItemsToPlaylist(const QModelIndexList& indexes, AddMode ad
|
|||||||
model()->merged_model()->mapFromSource(indexes));
|
model()->merged_model()->mapFromSource(indexes));
|
||||||
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
if (MimeData* mime_data = qobject_cast<MimeData*>(data)) {
|
||||||
mime_data->clear_first_ = add_mode == AddMode_Replace;
|
mime_data->clear_first_ = add_mode == AddMode_Replace;
|
||||||
mime_data->new_playlist_ = add_mode == AddMode_OpenInNew;
|
if(add_mode == AddMode_OpenInNew) {
|
||||||
|
mime_data->name_for_new_playlist_ = name();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
emit AddToPlaylistSignal(data);
|
emit AddToPlaylistSignal(data);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ class RadioService : public QObject {
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
// Constructs a new radio service with the given name and model. The name
|
||||||
|
// should be user-friendly (like 'DigitallyImported' or 'Last.fm').
|
||||||
RadioService(const QString& name, RadioModel* model);
|
RadioService(const QString& name, RadioModel* model);
|
||||||
virtual ~RadioService() {}
|
virtual ~RadioService() {}
|
||||||
|
|
||||||
|
@ -985,7 +985,7 @@ void MainWindow::ApplyAddBehaviour(MainWindow::AddBehaviour b, MimeData* data) c
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case AddBehaviour_OpenInNew:
|
case AddBehaviour_OpenInNew:
|
||||||
data->new_playlist_ = true;
|
data->name_for_new_playlist_ = tr("Playlist");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1020,8 +1020,8 @@ void MainWindow::AddToPlaylist(QMimeData* data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Should we create a new playlist for the songs?
|
// Should we create a new playlist for the songs?
|
||||||
if(mime_data->new_playlist_) {
|
if(!mime_data->name_for_new_playlist_.isEmpty()) {
|
||||||
playlists_->New(tr("Playlist"));
|
playlists_->New(mime_data->name_for_new_playlist_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ void FileViewList::AddToPlaylistSlot() {
|
|||||||
|
|
||||||
void FileViewList::OpenInNewPlaylistSlot() {
|
void FileViewList::OpenInNewPlaylistSlot() {
|
||||||
MimeData* data = MimeDataFromSelection();
|
MimeData* data = MimeDataFromSelection();
|
||||||
data->new_playlist_ = true;
|
data->name_for_new_playlist_ = static_cast<QFileSystemModel*>(model())->rootPath();
|
||||||
emit AddToPlaylist(data);
|
emit AddToPlaylist(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user