mirror of
https://github.com/clementine-player/Clementine
synced 2025-01-31 11:35:24 +01:00
Add an "Expand" button to add more tracks to a dynamic playlist. Fixes issue 1268
This commit is contained in:
parent
128b91d60d
commit
94a7ceb898
@ -24,6 +24,7 @@ DynamicPlaylistControls::DynamicPlaylistControls(QWidget *parent)
|
||||
{
|
||||
ui_->setupUi(this);
|
||||
|
||||
connect(ui_->expand, SIGNAL(clicked()), SIGNAL(Expand()));
|
||||
connect(ui_->repopulate, SIGNAL(clicked()), SIGNAL(Repopulate()));
|
||||
connect(ui_->off, SIGNAL(clicked()), SIGNAL(TurnOff()));
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ public:
|
||||
~DynamicPlaylistControls();
|
||||
|
||||
signals:
|
||||
void Expand();
|
||||
void Repopulate();
|
||||
void TurnOff();
|
||||
|
||||
|
@ -59,6 +59,13 @@
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="expand">
|
||||
<property name="text">
|
||||
<string>Expand</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="repopulate">
|
||||
<property name="text">
|
||||
|
@ -576,11 +576,7 @@ void Playlist::set_current_row(int i) {
|
||||
// Add more dynamic playlist items
|
||||
const int count = current_item_index_.row() + dynamic_playlist_->GetDynamicFuture() - items_.count();
|
||||
if (count > 0) {
|
||||
GeneratorInserter* inserter = new GeneratorInserter(task_manager_, library_, this);
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(LoadTracksError(QString)));
|
||||
connect(inserter, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex)));
|
||||
|
||||
inserter->Load(this, -1, false, false, dynamic_playlist_, count);
|
||||
InsertDynamicItems(count);
|
||||
}
|
||||
|
||||
// Remove the first item
|
||||
@ -592,6 +588,14 @@ void Playlist::set_current_row(int i) {
|
||||
UpdateScrobblePoint();
|
||||
}
|
||||
|
||||
void Playlist::InsertDynamicItems(int count) {
|
||||
GeneratorInserter* inserter = new GeneratorInserter(task_manager_, library_, this);
|
||||
connect(inserter, SIGNAL(Error(QString)), SIGNAL(LoadTracksError(QString)));
|
||||
connect(inserter, SIGNAL(PlayRequested(QModelIndex)), SIGNAL(PlayRequested(QModelIndex)));
|
||||
|
||||
inserter->Load(this, -1, false, false, dynamic_playlist_, count);
|
||||
}
|
||||
|
||||
Qt::ItemFlags Playlist::flags(const QModelIndex &index) const {
|
||||
Qt::ItemFlags flags = Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||
|
||||
@ -1498,6 +1502,13 @@ void Playlist::RepopulateDynamicPlaylist() {
|
||||
InsertSmartPlaylist(dynamic_playlist_);
|
||||
}
|
||||
|
||||
void Playlist::ExpandDynamicPlaylist() {
|
||||
if (!dynamic_playlist_)
|
||||
return;
|
||||
|
||||
InsertDynamicItems(5);
|
||||
}
|
||||
|
||||
void Playlist::RemoveItemsNotInQueue() {
|
||||
if (queue_->is_empty()) {
|
||||
RemoveItemsWithoutUndo(0, items_.count());
|
||||
|
@ -276,6 +276,7 @@ class Playlist : public QAbstractListModel {
|
||||
|
||||
void ShuffleModeChanged(PlaylistSequence::ShuffleMode mode);
|
||||
|
||||
void ExpandDynamicPlaylist();
|
||||
void RepopulateDynamicPlaylist();
|
||||
void TurnOffDynamicPlaylist();
|
||||
|
||||
@ -308,6 +309,8 @@ class Playlist : public QAbstractListModel {
|
||||
template<typename T>
|
||||
void InsertSongItems(const SongList& songs, int pos, bool play_now, bool enqueue);
|
||||
|
||||
void InsertDynamicItems(int count) ;
|
||||
|
||||
// Modify the playlist without changing the undo stack. These are used by
|
||||
// our friends in PlaylistUndoCommands
|
||||
void InsertItemsWithoutUndo(const PlaylistItemList& items, int pos,
|
||||
|
@ -175,6 +175,8 @@ void PlaylistView::SetPlaylist(Playlist* playlist) {
|
||||
this, SLOT(DynamicModeChanged(bool)));
|
||||
disconnect(playlist_, SIGNAL(destroyed()), this, SLOT(PlaylistDestroyed()));
|
||||
|
||||
disconnect(dynamic_controls_, SIGNAL(Expand()),
|
||||
playlist_, SLOT(ExpandDynamicPlaylist()));
|
||||
disconnect(dynamic_controls_, SIGNAL(Repopulate()),
|
||||
playlist_, SLOT(RepopulateDynamicPlaylist()));
|
||||
disconnect(dynamic_controls_, SIGNAL(TurnOff()),
|
||||
@ -193,6 +195,7 @@ void PlaylistView::SetPlaylist(Playlist* playlist) {
|
||||
connect(playlist_, SIGNAL(CurrentSongChanged(Song)), SLOT(MaybeAutoscroll()));
|
||||
connect(playlist_, SIGNAL(DynamicModeChanged(bool)), SLOT(DynamicModeChanged(bool)));
|
||||
connect(playlist_, SIGNAL(destroyed()), SLOT(PlaylistDestroyed()));
|
||||
connect(dynamic_controls_, SIGNAL(Expand()), playlist_, SLOT(ExpandDynamicPlaylist()));
|
||||
connect(dynamic_controls_, SIGNAL(Repopulate()), playlist_, SLOT(RepopulateDynamicPlaylist()));
|
||||
connect(dynamic_controls_, SIGNAL(TurnOff()), playlist_, SLOT(TurnOffDynamicPlaylist()));
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user