2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
|
|
|
* Copyright 2013, Jonas Kvinge <jonas@strawbs.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/>.
|
2018-08-09 18:10:03 +02:00
|
|
|
*
|
2018-02-27 18:06:05 +01:00
|
|
|
*/
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
#ifndef CONTEXTVIEW_H
|
|
|
|
#define CONTEXTVIEW_H
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QString>
|
|
|
|
#include <QImage>
|
|
|
|
#include <QPixmap>
|
|
|
|
#include <QPainter>
|
2018-08-29 21:42:24 +02:00
|
|
|
#include <QMovie>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QTimeLine>
|
|
|
|
#include <QAction>
|
|
|
|
#include <QMenu>
|
2018-08-29 21:42:24 +02:00
|
|
|
#include <QLabel>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QtEvents>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "core/song.h"
|
|
|
|
#include "covermanager/albumcoverloaderoptions.h"
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
#include "ui_contextviewcontainer.h"
|
|
|
|
|
|
|
|
using std::unique_ptr;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
class Application;
|
|
|
|
class CollectionView;
|
2018-08-29 21:42:24 +02:00
|
|
|
class CollectionModel;
|
2018-05-01 00:41:33 +02:00
|
|
|
class AlbumCoverChoiceController;
|
2018-08-29 21:42:24 +02:00
|
|
|
class Ui_ContextViewContainer;
|
|
|
|
class ContextAlbumsView;
|
|
|
|
class LyricsFetcher;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
class ContextView : public QWidget {
|
2018-02-27 18:06:05 +01:00
|
|
|
Q_OBJECT
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
public:
|
|
|
|
ContextView(QWidget *parent = nullptr);
|
|
|
|
~ContextView();
|
2018-05-01 00:41:33 +02:00
|
|
|
|
2019-06-06 18:22:41 +02:00
|
|
|
void Init(Application *app, CollectionView *collectionview, AlbumCoverChoiceController *album_cover_choice_controller);
|
2018-05-01 00:41:33 +02:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
ContextAlbumsView *albums() { return ui_->widget_play_albums; }
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
void UpdateNoSong();
|
|
|
|
void Playing();
|
|
|
|
void Stopped();
|
|
|
|
void Error();
|
2018-02-27 18:06:05 +01:00
|
|
|
void SongChanged(const Song &song);
|
2019-12-22 12:09:05 +01:00
|
|
|
void ReloadSettings();
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
private:
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
Ui_ContextViewContainer *ui_;
|
2018-09-04 21:43:44 +02:00
|
|
|
Application *app_;
|
2018-08-29 21:42:24 +02:00
|
|
|
CollectionView *collectionview_;
|
2018-09-04 21:43:44 +02:00
|
|
|
AlbumCoverChoiceController *album_cover_choice_controller_;
|
|
|
|
LyricsFetcher *lyrics_fetcher_;
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
QMenu *menu_;
|
|
|
|
QTimeLine *timeline_fade_;
|
|
|
|
QImage image_strawberry_;
|
|
|
|
bool active_;
|
|
|
|
bool downloading_covers_;
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
QAction *action_show_data_;
|
|
|
|
QAction *action_show_output_;
|
|
|
|
QAction *action_show_albums_;
|
|
|
|
QAction *action_show_lyrics_;
|
|
|
|
AlbumCoverLoaderOptions cover_loader_options_;
|
|
|
|
Song song_;
|
2018-09-04 21:43:44 +02:00
|
|
|
Song song_playing_;
|
2018-09-22 23:13:56 +02:00
|
|
|
Song song_prev_;
|
2018-08-29 21:42:24 +02:00
|
|
|
QImage image_original_;
|
|
|
|
QImage image_previous_;
|
2018-02-27 18:06:05 +01:00
|
|
|
QPixmap pixmap_current_;
|
|
|
|
QPixmap pixmap_previous_;
|
|
|
|
qreal pixmap_previous_opacity_;
|
|
|
|
std::unique_ptr<QMovie> spinner_animation_;
|
2018-09-22 23:13:56 +02:00
|
|
|
qint64 lyrics_id_;
|
2018-08-29 21:42:24 +02:00
|
|
|
QString lyrics_;
|
2019-12-22 12:09:05 +01:00
|
|
|
QString title_fmt_;
|
|
|
|
QString summary_fmt_;
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
void AddActions();
|
2018-09-22 23:13:56 +02:00
|
|
|
void SetLabelEnabled(QLabel *label);
|
|
|
|
void SetLabelDisabled(QLabel *label);
|
|
|
|
void SetLabelText(QLabel *label, int value, const QString &suffix, const QString &def = QString());
|
2018-08-29 21:42:24 +02:00
|
|
|
void NoSong();
|
2018-09-22 23:13:56 +02:00
|
|
|
void SetSong(const Song &song);
|
|
|
|
void UpdateSong(const Song &song);
|
2018-08-29 21:42:24 +02:00
|
|
|
void SetImage(const QImage &image);
|
|
|
|
void DrawImage(QPainter *p);
|
|
|
|
void ScaleCover();
|
2018-09-04 21:43:44 +02:00
|
|
|
void GetCoverAutomatically();
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
protected:
|
2018-02-27 18:06:05 +01:00
|
|
|
bool eventFilter(QObject *, QEvent *);
|
|
|
|
void handlePaintEvent(QObject *object, QEvent *event);
|
2018-08-29 21:42:24 +02:00
|
|
|
void PaintEventAlbum(QEvent *event);
|
2018-02-27 18:06:05 +01:00
|
|
|
void contextMenuEvent(QContextMenuEvent *e);
|
|
|
|
void mouseReleaseEvent(QMouseEvent *);
|
|
|
|
void dragEnterEvent(QDragEnterEvent *e);
|
|
|
|
void dropEvent(QDropEvent *e);
|
|
|
|
|
|
|
|
private slots:
|
2018-08-29 21:42:24 +02:00
|
|
|
void ActionShowData();
|
|
|
|
void ActionShowOutput();
|
|
|
|
void ActionShowAlbums();
|
|
|
|
void ActionShowLyrics();
|
2019-06-06 18:22:41 +02:00
|
|
|
void UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics);
|
2019-07-07 21:14:24 +02:00
|
|
|
void SearchCoverInProgress();
|
2018-09-04 21:43:44 +02:00
|
|
|
void AutomaticCoverSearchDone();
|
2019-07-07 21:14:24 +02:00
|
|
|
void AlbumCoverLoaded(const Song &song, const QUrl &cover_url, const QImage &image);
|
2018-08-29 21:42:24 +02:00
|
|
|
void FadePreviousTrack(qreal value);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
#endif // CONTEXTVIEW_H
|
2018-08-09 18:10:03 +02:00
|
|
|
|