Queue size and duration is now displayed in queue manager && Album Cover Popup fixes (#6086)
This commit is contained in:
parent
e2f63e3945
commit
fcf96cb6ff
|
@ -12,7 +12,7 @@ def main():
|
||||||
description='Reformats C++ source files that have changed from a given '
|
description='Reformats C++ source files that have changed from a given '
|
||||||
'git ref.')
|
'git ref.')
|
||||||
parser.add_argument('--url',
|
parser.add_argument('--url',
|
||||||
default='http://clang.clementine-player.org/format',
|
default='https://clang.clementine-player.org/format',
|
||||||
help='a URL of a Clang-in-the-cloud service')
|
help='a URL of a Clang-in-the-cloud service')
|
||||||
parser.add_argument('--ref', default='origin/master',
|
parser.add_argument('--ref', default='origin/master',
|
||||||
help='the git-ref to compare against')
|
help='the git-ref to compare against')
|
||||||
|
|
|
@ -110,7 +110,7 @@ signals:
|
||||||
|
|
||||||
// The toggle parameter is true when user requests to toggle visibility for
|
// The toggle parameter is true when user requests to toggle visibility for
|
||||||
// Pretty OSD
|
// Pretty OSD
|
||||||
void ForceShowOSD(Song, bool toogle);
|
void ForceShowOSD(Song, bool toggle);
|
||||||
};
|
};
|
||||||
|
|
||||||
class Player : public PlayerInterface {
|
class Player : public PlayerInterface {
|
||||||
|
|
|
@ -21,9 +21,17 @@
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
#include <QtDebug>
|
#include <QtDebug>
|
||||||
|
|
||||||
|
#include "core/utilities.h"
|
||||||
|
|
||||||
const char* Queue::kRowsMimetype = "application/x-clementine-queue-rows";
|
const char* Queue::kRowsMimetype = "application/x-clementine-queue-rows";
|
||||||
|
|
||||||
Queue::Queue(QObject* parent) : QAbstractProxyModel(parent) {}
|
Queue::Queue(Playlist* parent)
|
||||||
|
: QAbstractProxyModel(parent), playlist_(parent), total_length_ns_(0) {
|
||||||
|
connect(this, SIGNAL(ItemCountChanged(int)), SLOT(UpdateTotalLength()));
|
||||||
|
connect(this, SIGNAL(TotalLengthChanged(quint64)), SLOT(UpdateSummaryText()));
|
||||||
|
|
||||||
|
UpdateSummaryText();
|
||||||
|
}
|
||||||
|
|
||||||
QModelIndex Queue::mapFromSource(const QModelIndex& source_index) const {
|
QModelIndex Queue::mapFromSource(const QModelIndex& source_index) const {
|
||||||
if (!source_index.isValid()) return QModelIndex();
|
if (!source_index.isValid()) return QModelIndex();
|
||||||
|
@ -77,6 +85,7 @@ void Queue::SourceDataChanged(const QModelIndex& top_left,
|
||||||
|
|
||||||
emit dataChanged(proxy_index, proxy_index);
|
emit dataChanged(proxy_index, proxy_index);
|
||||||
}
|
}
|
||||||
|
emit ItemCountChanged(this->ItemCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
void Queue::SourceLayoutChanged() {
|
void Queue::SourceLayoutChanged() {
|
||||||
|
@ -89,6 +98,7 @@ void Queue::SourceLayoutChanged() {
|
||||||
--i;
|
--i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
emit ItemCountChanged(this->ItemCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
QModelIndex Queue::index(int row, int column, const QModelIndex& parent) const {
|
QModelIndex Queue::index(int row, int column, const QModelIndex& parent) const {
|
||||||
|
@ -180,6 +190,41 @@ int Queue::PositionOf(const QModelIndex& source_index) const {
|
||||||
|
|
||||||
bool Queue::is_empty() const { return source_indexes_.isEmpty(); }
|
bool Queue::is_empty() const { return source_indexes_.isEmpty(); }
|
||||||
|
|
||||||
|
int Queue::ItemCount() const { return source_indexes_.length(); }
|
||||||
|
|
||||||
|
quint64 Queue::GetTotalLength() const { return total_length_ns_; }
|
||||||
|
|
||||||
|
void Queue::UpdateTotalLength() {
|
||||||
|
quint64 total = 0;
|
||||||
|
|
||||||
|
for (QPersistentModelIndex row : source_indexes_) {
|
||||||
|
int id = row.row();
|
||||||
|
|
||||||
|
Q_ASSERT(playlist_->has_item_at(id));
|
||||||
|
|
||||||
|
quint64 length = playlist_->item_at(id)->Metadata().length_nanosec();
|
||||||
|
if (length > 0) total += length;
|
||||||
|
}
|
||||||
|
|
||||||
|
total_length_ns_ = total;
|
||||||
|
|
||||||
|
emit TotalLengthChanged(total);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Queue::UpdateSummaryText() {
|
||||||
|
QString summary;
|
||||||
|
int tracks = this->ItemCount();
|
||||||
|
quint64 nanoseconds = this->GetTotalLength();
|
||||||
|
|
||||||
|
// TODO: Make the plurals translatable
|
||||||
|
summary += tracks == 1 ? tr("1 track") : tr("%1 tracks").arg(tracks);
|
||||||
|
|
||||||
|
if (nanoseconds)
|
||||||
|
summary += " - [ " + Utilities::WordyTimeNanosec(nanoseconds) + " ]";
|
||||||
|
|
||||||
|
emit SummaryTextChanged(summary);
|
||||||
|
}
|
||||||
|
|
||||||
void Queue::Clear() {
|
void Queue::Clear() {
|
||||||
if (source_indexes_.isEmpty()) return;
|
if (source_indexes_.isEmpty()) return;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ class Queue : public QAbstractProxyModel {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Queue(QObject* parent = nullptr);
|
Queue(Playlist* parent);
|
||||||
|
|
||||||
static const char* kRowsMimetype;
|
static const char* kRowsMimetype;
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ class Queue : public QAbstractProxyModel {
|
||||||
int PositionOf(const QModelIndex& source_index) const;
|
int PositionOf(const QModelIndex& source_index) const;
|
||||||
bool ContainsSourceRow(int source_row) const;
|
bool ContainsSourceRow(int source_row) const;
|
||||||
int PeekNext() const;
|
int PeekNext() const;
|
||||||
|
int ItemCount() const;
|
||||||
|
quint64 GetTotalLength() const;
|
||||||
|
|
||||||
// Modify the queue
|
// Modify the queue
|
||||||
int TakeNext();
|
int TakeNext();
|
||||||
|
@ -66,13 +68,24 @@ class Queue : public QAbstractProxyModel {
|
||||||
int column, const QModelIndex& parent);
|
int column, const QModelIndex& parent);
|
||||||
Qt::ItemFlags flags(const QModelIndex& index) const;
|
Qt::ItemFlags flags(const QModelIndex& index) const;
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void UpdateSummaryText();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void TotalLengthChanged(const quint64 length);
|
||||||
|
void ItemCountChanged(const int count);
|
||||||
|
void SummaryTextChanged(const QString& message);
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void SourceDataChanged(const QModelIndex& top_left,
|
void SourceDataChanged(const QModelIndex& top_left,
|
||||||
const QModelIndex& bottom_right);
|
const QModelIndex& bottom_right);
|
||||||
void SourceLayoutChanged();
|
void SourceLayoutChanged();
|
||||||
|
void UpdateTotalLength();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QPersistentModelIndex> source_indexes_;
|
QList<QPersistentModelIndex> source_indexes_;
|
||||||
|
const Playlist* playlist_;
|
||||||
|
quint64 total_length_ns_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QUEUE_H
|
#endif // QUEUE_H
|
||||||
|
|
|
@ -73,6 +73,8 @@ void QueueManager::CurrentPlaylistChanged(Playlist* playlist) {
|
||||||
SLOT(UpdateButtonState()));
|
SLOT(UpdateButtonState()));
|
||||||
disconnect(current_playlist_->queue(), SIGNAL(layoutChanged()), this,
|
disconnect(current_playlist_->queue(), SIGNAL(layoutChanged()), this,
|
||||||
SLOT(UpdateButtonState()));
|
SLOT(UpdateButtonState()));
|
||||||
|
disconnect(current_playlist_->queue(), SIGNAL(SummaryTextChanged(QString)),
|
||||||
|
ui_->queue_summary, SLOT(setText(QString)));
|
||||||
disconnect(current_playlist_, SIGNAL(destroyed()), this,
|
disconnect(current_playlist_, SIGNAL(destroyed()), this,
|
||||||
SLOT(PlaylistDestroyed()));
|
SLOT(PlaylistDestroyed()));
|
||||||
}
|
}
|
||||||
|
@ -87,6 +89,8 @@ void QueueManager::CurrentPlaylistChanged(Playlist* playlist) {
|
||||||
SLOT(UpdateButtonState()));
|
SLOT(UpdateButtonState()));
|
||||||
connect(current_playlist_->queue(), SIGNAL(layoutChanged()), this,
|
connect(current_playlist_->queue(), SIGNAL(layoutChanged()), this,
|
||||||
SLOT(UpdateButtonState()));
|
SLOT(UpdateButtonState()));
|
||||||
|
connect(current_playlist_->queue(), SIGNAL(SummaryTextChanged(QString)),
|
||||||
|
ui_->queue_summary, SLOT(setText(QString)));
|
||||||
connect(current_playlist_, SIGNAL(destroyed()), this,
|
connect(current_playlist_, SIGNAL(destroyed()), this,
|
||||||
SLOT(PlaylistDestroyed()));
|
SLOT(PlaylistDestroyed()));
|
||||||
|
|
||||||
|
@ -95,6 +99,8 @@ void QueueManager::CurrentPlaylistChanged(Playlist* playlist) {
|
||||||
connect(ui_->list->selectionModel(),
|
connect(ui_->list->selectionModel(),
|
||||||
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
|
SIGNAL(currentChanged(QModelIndex, QModelIndex)),
|
||||||
SLOT(UpdateButtonState()));
|
SLOT(UpdateButtonState()));
|
||||||
|
|
||||||
|
QTimer::singleShot(0, current_playlist_->queue(), SLOT(UpdateSummaryText()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void QueueManager::MoveUp() {
|
void QueueManager::MoveUp() {
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<iconset resource="../../data/data.qrc">
|
<iconset resource="../../data/data.qrc">
|
||||||
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
<normaloff>:/icon.png</normaloff>:/icon.png</iconset>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_2">
|
<layout class="QVBoxLayout" name="verticalLayout_5">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
|
@ -143,6 +143,15 @@
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="queue_summary">
|
||||||
|
<property name="text">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
|
@ -154,6 +163,8 @@
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<resources>
|
<resources>
|
||||||
<include location="../../data/data.qrc"/>
|
<include location="../../data/data.qrc"/>
|
||||||
|
|
|
@ -55,7 +55,8 @@ AlbumCoverChoiceController::AlbumCoverChoiceController(QWidget* parent)
|
||||||
cover_searcher_(nullptr),
|
cover_searcher_(nullptr),
|
||||||
cover_fetcher_(nullptr),
|
cover_fetcher_(nullptr),
|
||||||
save_file_dialog_(nullptr),
|
save_file_dialog_(nullptr),
|
||||||
cover_from_url_dialog_(nullptr) {
|
cover_from_url_dialog_(nullptr),
|
||||||
|
album_cover_popup_(nullptr) {
|
||||||
cover_from_file_ =
|
cover_from_file_ =
|
||||||
new QAction(IconLoader::Load("document-open", IconLoader::Base),
|
new QAction(IconLoader::Load("document-open", IconLoader::Base),
|
||||||
tr("Load cover from disk..."), this);
|
tr("Load cover from disk..."), this);
|
||||||
|
@ -203,7 +204,27 @@ QString AlbumCoverChoiceController::UnsetCover(Song* song) {
|
||||||
return cover;
|
return cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool AlbumCoverChoiceController::ToggleCover(const Song& song) {
|
||||||
|
if (album_cover_popup_ != nullptr) {
|
||||||
|
album_cover_popup_->accept();
|
||||||
|
album_cover_popup_ = nullptr;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
album_cover_popup_ = ShowCoverPrivate(song);
|
||||||
|
|
||||||
|
// keep track of our window to prevent endless stacking
|
||||||
|
connect(album_cover_popup_, SIGNAL(finished(int)), this,
|
||||||
|
SLOT(AlbumCoverPopupClosed()));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
void AlbumCoverChoiceController::ShowCover(const Song& song) {
|
void AlbumCoverChoiceController::ShowCover(const Song& song) {
|
||||||
|
ShowCoverPrivate(song);
|
||||||
|
}
|
||||||
|
|
||||||
|
QDialog* AlbumCoverChoiceController::ShowCoverPrivate(const Song& song) {
|
||||||
QDialog* dialog = new QDialog(this);
|
QDialog* dialog = new QDialog(this);
|
||||||
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
dialog->setAttribute(Qt::WA_DeleteOnClose, true);
|
||||||
|
|
||||||
|
@ -245,6 +266,12 @@ void AlbumCoverChoiceController::ShowCover(const Song& song) {
|
||||||
dialog->setWindowTitle(title_text);
|
dialog->setWindowTitle(title_text);
|
||||||
dialog->setFixedSize(label->pixmap()->size());
|
dialog->setFixedSize(label->pixmap()->size());
|
||||||
dialog->show();
|
dialog->show();
|
||||||
|
|
||||||
|
return dialog;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AlbumCoverChoiceController::AlbumCoverPopupClosed() {
|
||||||
|
album_cover_popup_ = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AlbumCoverChoiceController::SearchCoverAutomatically(const Song& song) {
|
void AlbumCoverChoiceController::SearchCoverAutomatically(const Song& song) {
|
||||||
|
|
|
@ -96,6 +96,7 @@ class AlbumCoverChoiceController : public QWidget {
|
||||||
|
|
||||||
// Shows the cover of given song in it's original size.
|
// Shows the cover of given song in it's original size.
|
||||||
void ShowCover(const Song& song);
|
void ShowCover(const Song& song);
|
||||||
|
bool ToggleCover(const Song& song);
|
||||||
|
|
||||||
// Search for covers automatically
|
// Search for covers automatically
|
||||||
void SearchCoverAutomatically(const Song& song);
|
void SearchCoverAutomatically(const Song& song);
|
||||||
|
@ -119,8 +120,10 @@ signals:
|
||||||
private slots:
|
private slots:
|
||||||
void AlbumCoverFetched(quint64 id, const QImage& image,
|
void AlbumCoverFetched(quint64 id, const QImage& image,
|
||||||
const CoverSearchStatistics& statistics);
|
const CoverSearchStatistics& statistics);
|
||||||
|
void AlbumCoverPopupClosed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QDialog* ShowCoverPrivate(const Song& song);
|
||||||
QString GetInitialPathForFileDialog(const Song& song,
|
QString GetInitialPathForFileDialog(const Song& song,
|
||||||
const QString& filename);
|
const QString& filename);
|
||||||
|
|
||||||
|
@ -144,6 +147,8 @@ signals:
|
||||||
QAction* search_cover_auto_;
|
QAction* search_cover_auto_;
|
||||||
|
|
||||||
QMap<quint64, Song> cover_fetching_tasks_;
|
QMap<quint64, Song> cover_fetching_tasks_;
|
||||||
|
|
||||||
|
QDialog* album_cover_popup_;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ALBUMCOVERCHOICECONTROLLER_H
|
#endif // ALBUMCOVERCHOICECONTROLLER_H
|
||||||
|
|
|
@ -641,7 +641,7 @@ void NowPlayingWidget::UnsetCover() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void NowPlayingWidget::ShowCover() {
|
void NowPlayingWidget::ShowCover() {
|
||||||
album_cover_choice_controller_->ShowCover(metadata_);
|
album_cover_choice_controller_->ToggleCover(metadata_);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NowPlayingWidget::SearchCoverAutomatically() {
|
void NowPlayingWidget::SearchCoverAutomatically() {
|
||||||
|
|
Loading…
Reference in New Issue