2018-02-27 18:06:05 +01:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
2022-06-05 04:39:45 +02:00
|
|
|
* Copyright 2013-2022, Jonas Kvinge <jonas@jkvinge.net>
|
2018-02-27 18:06:05 +01:00
|
|
|
*
|
|
|
|
* 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 <QtGlobal>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
2020-04-28 01:11:00 +02:00
|
|
|
#include <QList>
|
2018-05-01 00:41:33 +02:00
|
|
|
#include <QString>
|
|
|
|
#include <QImage>
|
2020-06-19 17:32:08 +02:00
|
|
|
#include <QAction>
|
2018-02-27 18:06:05 +01:00
|
|
|
|
|
|
|
#include "core/song.h"
|
2020-04-06 02:47:57 +02:00
|
|
|
#include "contextalbum.h"
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2020-02-08 03:40:30 +01:00
|
|
|
class QMenu;
|
|
|
|
class QLabel;
|
2020-04-06 02:47:57 +02:00
|
|
|
class QStackedWidget;
|
|
|
|
class QVBoxLayout;
|
|
|
|
class QGridLayout;
|
|
|
|
class QScrollArea;
|
|
|
|
class QSpacerItem;
|
|
|
|
class QResizeEvent;
|
2020-02-08 03:40:30 +01:00
|
|
|
class QContextMenuEvent;
|
|
|
|
class QDragEnterEvent;
|
|
|
|
class QDropEvent;
|
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
class ResizableTextEdit;
|
2018-02-27 18:06:05 +01:00
|
|
|
class Application;
|
|
|
|
class CollectionView;
|
2018-05-01 00:41:33 +02:00
|
|
|
class AlbumCoverChoiceController;
|
2018-08-29 21:42:24 +02:00
|
|
|
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:
|
2020-04-07 16:49:15 +02:00
|
|
|
explicit ContextView(QWidget *parent = nullptr);
|
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
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
ContextAlbum *album_widget() const { return widget_album_; }
|
2020-06-19 17:32:08 +02:00
|
|
|
bool album_enabled() const { return action_show_album_->isChecked(); }
|
2020-04-25 14:48:43 +02:00
|
|
|
Song song_playing() const { return song_playing_; }
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
protected:
|
2022-06-06 20:54:15 +02:00
|
|
|
void resizeEvent(QResizeEvent *e) override;
|
2020-06-15 21:55:05 +02:00
|
|
|
void contextMenuEvent(QContextMenuEvent*) override;
|
|
|
|
void dragEnterEvent(QDragEnterEvent*) override;
|
|
|
|
void dropEvent(QDropEvent*) override;
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void AddActions();
|
2021-06-22 13:41:38 +02:00
|
|
|
static void SetLabelText(QLabel *label, int value, const QString &suffix, const QString &def = QString());
|
2020-04-06 02:47:57 +02:00
|
|
|
void NoSong();
|
|
|
|
void SetSong();
|
|
|
|
void UpdateSong(const Song &song);
|
|
|
|
void ResetSong();
|
|
|
|
void GetCoverAutomatically();
|
2020-04-25 14:48:43 +02:00
|
|
|
void SearchLyrics();
|
2020-04-28 01:11:00 +02:00
|
|
|
void UpdateFonts();
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
signals:
|
|
|
|
void AlbumEnabledChanged();
|
|
|
|
|
|
|
|
private slots:
|
|
|
|
void ActionShowAlbum();
|
|
|
|
void ActionShowData();
|
|
|
|
void ActionShowLyrics();
|
2020-04-25 14:48:43 +02:00
|
|
|
void ActionSearchLyrics();
|
2018-08-29 21:42:24 +02:00
|
|
|
void UpdateNoSong();
|
2020-04-06 02:47:57 +02:00
|
|
|
void FadeStopFinished();
|
2021-10-30 03:15:03 +02:00
|
|
|
void UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics);
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
public slots:
|
2019-12-22 12:09:05 +01:00
|
|
|
void ReloadSettings();
|
2021-01-26 16:48:04 +01:00
|
|
|
void Playing();
|
|
|
|
void Stopped();
|
|
|
|
void Error();
|
|
|
|
void SongChanged(const Song &song);
|
|
|
|
void AlbumCoverLoaded(const Song &song, const QImage &image);
|
2018-02-27 18:06:05 +01:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
private:
|
2022-06-06 20:54:15 +02:00
|
|
|
static const int kWidgetSpacing;
|
|
|
|
|
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_;
|
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
QMenu *menu_options_;
|
2020-04-06 02:47:57 +02:00
|
|
|
QAction *action_show_album_;
|
2018-08-29 21:42:24 +02:00
|
|
|
QAction *action_show_data_;
|
|
|
|
QAction *action_show_lyrics_;
|
2020-04-25 14:48:43 +02:00
|
|
|
QAction *action_search_lyrics_;
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
QVBoxLayout *layout_container_;
|
|
|
|
QWidget *widget_scrollarea_;
|
|
|
|
QVBoxLayout *layout_scrollarea_;
|
|
|
|
QScrollArea *scrollarea_;
|
2022-06-05 04:39:45 +02:00
|
|
|
ResizableTextEdit *textedit_top_;
|
2020-04-06 02:47:57 +02:00
|
|
|
ContextAlbum *widget_album_;
|
|
|
|
QStackedWidget *widget_stacked_;
|
|
|
|
QWidget *widget_stop_;
|
|
|
|
QWidget *widget_play_;
|
|
|
|
QVBoxLayout *layout_stop_;
|
|
|
|
QVBoxLayout *layout_play_;
|
|
|
|
QLabel *label_stop_summary_;
|
|
|
|
QWidget *widget_play_data_;
|
|
|
|
QGridLayout *layout_play_data_;
|
2022-06-05 04:39:45 +02:00
|
|
|
ResizableTextEdit *textedit_play_lyrics_;
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
QSpacerItem *spacer_play_data_;
|
|
|
|
|
|
|
|
QLabel *label_filetype_title_;
|
|
|
|
QLabel *label_length_title_;
|
|
|
|
QLabel *label_samplerate_title_;
|
|
|
|
QLabel *label_bitdepth_title_;
|
|
|
|
QLabel *label_bitrate_title_;
|
|
|
|
|
|
|
|
QLabel *label_filetype_;
|
|
|
|
QLabel *label_length_;
|
|
|
|
QLabel *label_samplerate_;
|
|
|
|
QLabel *label_bitdepth_;
|
|
|
|
QLabel *label_bitrate_;
|
|
|
|
|
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_;
|
2020-04-20 18:03:18 +02:00
|
|
|
bool lyrics_tried_;
|
2021-10-30 03:15:03 +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_;
|
2023-05-03 01:59:13 +02:00
|
|
|
QFont font_headline_;
|
|
|
|
QFont font_normal_;
|
|
|
|
QFont font_nosong_;
|
2020-04-28 01:11:00 +02:00
|
|
|
|
|
|
|
QList<QLabel*> labels_play_;
|
2022-06-05 04:39:45 +02:00
|
|
|
QList<ResizableTextEdit*> textedit_play_;
|
2020-04-28 01:11:00 +02:00
|
|
|
QList<QLabel*> labels_play_data_;
|
|
|
|
QList<QLabel*> labels_play_all_;
|
|
|
|
|
2018-02-27 18:06:05 +01:00
|
|
|
};
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
#endif // CONTEXTVIEW_H
|