2018-08-29 21:42:24 +02:00
|
|
|
/*
|
|
|
|
* Strawberry Music Player
|
2022-06-05 04:39:45 +02:00
|
|
|
* Copyright 2013-2022, Jonas Kvinge <jonas@jkvinge.net>
|
2018-08-29 21:42:24 +02: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/>.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QObject>
|
|
|
|
#include <QWidget>
|
|
|
|
#include <QList>
|
|
|
|
#include <QVariant>
|
|
|
|
#include <QString>
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QUrl>
|
2018-08-29 21:42:24 +02:00
|
|
|
#include <QImage>
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QIcon>
|
2020-04-28 01:11:00 +02:00
|
|
|
#include <QFont>
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QSize>
|
2020-04-06 02:47:57 +02:00
|
|
|
#include <QSizePolicy>
|
2018-08-29 21:42:24 +02:00
|
|
|
#include <QMenu>
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QAction>
|
2018-08-29 21:42:24 +02:00
|
|
|
#include <QFontDatabase>
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QLayoutItem>
|
2020-04-06 02:47:57 +02:00
|
|
|
#include <QVBoxLayout>
|
2020-02-08 03:40:30 +01:00
|
|
|
#include <QGridLayout>
|
|
|
|
#include <QStackedWidget>
|
2020-04-06 02:47:57 +02:00
|
|
|
#include <QScrollArea>
|
|
|
|
#include <QSpacerItem>
|
|
|
|
#include <QLabel>
|
2022-06-05 04:39:45 +02:00
|
|
|
#include <QTextEdit>
|
2020-04-06 02:47:57 +02:00
|
|
|
#include <QSettings>
|
|
|
|
#include <QResizeEvent>
|
|
|
|
#include <QContextMenuEvent>
|
|
|
|
#include <QDragEnterEvent>
|
|
|
|
#include <QDropEvent>
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
#include "core/application.h"
|
|
|
|
#include "core/player.h"
|
|
|
|
#include "core/song.h"
|
|
|
|
#include "core/iconloader.h"
|
2022-12-28 03:12:00 +01:00
|
|
|
#include "utilities/strutils.h"
|
|
|
|
#include "utilities/timeutils.h"
|
2022-06-05 04:39:45 +02:00
|
|
|
#include "widgets/resizabletextedit.h"
|
2018-08-29 21:42:24 +02:00
|
|
|
#include "engine/engine_fwd.h"
|
|
|
|
#include "engine/enginebase.h"
|
|
|
|
#include "engine/enginetype.h"
|
2019-11-03 19:53:08 +01:00
|
|
|
#include "engine/devicefinders.h"
|
2018-08-29 21:42:24 +02:00
|
|
|
#include "engine/devicefinder.h"
|
|
|
|
#include "collection/collectionbackend.h"
|
|
|
|
#include "collection/collectionquery.h"
|
|
|
|
#include "collection/collectionview.h"
|
|
|
|
#include "covermanager/albumcoverchoicecontroller.h"
|
|
|
|
#include "lyrics/lyricsfetcher.h"
|
2019-12-22 12:09:05 +01:00
|
|
|
#include "settings/contextsettingspage.h"
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
#include "contextview.h"
|
2020-04-06 02:47:57 +02:00
|
|
|
#include "contextalbum.h"
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2022-06-09 00:46:39 +02:00
|
|
|
const int ContextView::kWidgetSpacing = 50;
|
2022-06-06 20:54:15 +02:00
|
|
|
|
2021-07-11 07:40:57 +02:00
|
|
|
ContextView::ContextView(QWidget *parent)
|
|
|
|
: QWidget(parent),
|
|
|
|
app_(nullptr),
|
|
|
|
collectionview_(nullptr),
|
|
|
|
album_cover_choice_controller_(nullptr),
|
|
|
|
lyrics_fetcher_(nullptr),
|
2022-06-05 04:39:45 +02:00
|
|
|
menu_options_(new QMenu(this)),
|
2021-07-11 07:40:57 +02:00
|
|
|
action_show_album_(nullptr),
|
|
|
|
action_show_data_(nullptr),
|
|
|
|
action_show_output_(nullptr),
|
|
|
|
action_show_lyrics_(nullptr),
|
|
|
|
action_search_lyrics_(nullptr),
|
|
|
|
layout_container_(new QVBoxLayout()),
|
|
|
|
widget_scrollarea_(new QWidget(this)),
|
|
|
|
layout_scrollarea_(new QVBoxLayout()),
|
|
|
|
scrollarea_(new QScrollArea(this)),
|
2022-06-05 04:39:45 +02:00
|
|
|
textedit_top_(new ResizableTextEdit(this)),
|
2021-07-11 07:40:57 +02:00
|
|
|
widget_album_(new ContextAlbum(this)),
|
|
|
|
widget_stacked_(new QStackedWidget(this)),
|
|
|
|
widget_stop_(new QWidget(this)),
|
|
|
|
widget_play_(new QWidget(this)),
|
|
|
|
layout_stop_(new QVBoxLayout()),
|
|
|
|
layout_play_(new QVBoxLayout()),
|
|
|
|
label_stop_summary_(new QLabel(this)),
|
|
|
|
widget_play_data_(new QWidget(this)),
|
|
|
|
widget_play_output_(new QWidget(this)),
|
|
|
|
layout_play_data_(new QGridLayout()),
|
|
|
|
layout_play_output_(new QGridLayout()),
|
2022-06-05 04:39:45 +02:00
|
|
|
textedit_play_lyrics_(new ResizableTextEdit(this)),
|
2021-07-11 07:40:57 +02:00
|
|
|
spacer_play_output_(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)),
|
|
|
|
spacer_play_data_(new QSpacerItem(20, 20, QSizePolicy::Fixed, QSizePolicy::Fixed)),
|
|
|
|
label_filetype_title_(new QLabel(this)),
|
|
|
|
label_length_title_(new QLabel(this)),
|
|
|
|
label_samplerate_title_(new QLabel(this)),
|
|
|
|
label_bitdepth_title_(new QLabel(this)),
|
|
|
|
label_bitrate_title_(new QLabel(this)),
|
|
|
|
label_filetype_(new QLabel(this)),
|
|
|
|
label_length_(new QLabel(this)),
|
|
|
|
label_samplerate_(new QLabel(this)),
|
|
|
|
label_bitdepth_(new QLabel(this)),
|
|
|
|
label_bitrate_(new QLabel(this)),
|
|
|
|
label_device_title_(new QLabel(this)),
|
|
|
|
label_engine_title_(new QLabel(this)),
|
|
|
|
label_device_space_(new QLabel(this)),
|
|
|
|
label_engine_space_(new QLabel(this)),
|
|
|
|
label_device_(new QLabel(this)),
|
|
|
|
label_engine_(new QLabel(this)),
|
|
|
|
label_device_icon_(new QLabel(this)),
|
|
|
|
label_engine_icon_(new QLabel(this)),
|
|
|
|
lyrics_tried_(false),
|
|
|
|
lyrics_id_(-1),
|
|
|
|
font_size_headline_(0),
|
2022-06-09 00:46:39 +02:00
|
|
|
font_size_normal_(0) {
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
setLayout(layout_container_);
|
|
|
|
|
|
|
|
layout_container_->setObjectName("context-layout-container");
|
|
|
|
layout_container_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
layout_container_->addWidget(scrollarea_);
|
|
|
|
|
|
|
|
scrollarea_->setObjectName("context-scrollarea");
|
|
|
|
scrollarea_->setWidgetResizable(true);
|
|
|
|
scrollarea_->setWidget(widget_scrollarea_);
|
|
|
|
scrollarea_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
scrollarea_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
2022-06-09 00:46:39 +02:00
|
|
|
scrollarea_->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
widget_scrollarea_->setObjectName("context-widget-scrollarea");
|
|
|
|
widget_scrollarea_->setLayout(layout_scrollarea_);
|
|
|
|
widget_scrollarea_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
textedit_top_->setReadOnly(true);
|
|
|
|
textedit_top_->setFrameShape(QFrame::NoFrame);
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
layout_scrollarea_->setObjectName("context-layout-scrollarea");
|
|
|
|
layout_scrollarea_->setContentsMargins(15, 15, 15, 15);
|
2022-06-05 04:39:45 +02:00
|
|
|
layout_scrollarea_->addWidget(textedit_top_);
|
2020-04-06 02:47:57 +02:00
|
|
|
layout_scrollarea_->addWidget(widget_album_);
|
|
|
|
layout_scrollarea_->addWidget(widget_stacked_);
|
2022-06-09 23:09:24 +02:00
|
|
|
layout_scrollarea_->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding));
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
widget_stacked_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
widget_stacked_->addWidget(widget_stop_);
|
|
|
|
widget_stacked_->addWidget(widget_play_);
|
|
|
|
widget_stacked_->setCurrentWidget(widget_stop_);
|
|
|
|
|
|
|
|
widget_stop_->setLayout(layout_stop_);
|
|
|
|
widget_stop_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
widget_play_->setLayout(layout_play_);
|
|
|
|
widget_play_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
layout_stop_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
layout_play_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
// Stopped
|
|
|
|
|
2022-06-09 23:09:24 +02:00
|
|
|
label_stop_summary_->setAlignment(Qt::AlignLeft | Qt::AlignTop);
|
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
layout_stop_->setContentsMargins(0, 0, 0, 0);
|
2020-04-06 02:47:57 +02:00
|
|
|
layout_stop_->addWidget(label_stop_summary_);
|
|
|
|
|
|
|
|
// Playing
|
|
|
|
|
|
|
|
label_engine_title_->setText(tr("Engine"));
|
|
|
|
label_device_title_->setText(tr("Device"));
|
|
|
|
label_engine_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_device_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_engine_space_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_device_space_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_engine_space_->setMinimumWidth(24);
|
|
|
|
label_device_space_->setMinimumWidth(24);
|
|
|
|
label_engine_icon_->setMinimumSize(32, 32);
|
|
|
|
label_device_icon_->setMaximumSize(32, 32);
|
|
|
|
label_engine_icon_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_device_icon_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
label_engine_->setWordWrap(true);
|
|
|
|
label_device_->setWordWrap(true);
|
|
|
|
|
|
|
|
layout_play_output_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
|
|
|
|
layout_play_output_->addWidget(label_engine_title_, 0, 0);
|
|
|
|
layout_play_output_->addWidget(label_engine_space_, 0, 1);
|
|
|
|
layout_play_output_->addWidget(label_engine_icon_, 0, 2);
|
|
|
|
layout_play_output_->addWidget(label_engine_, 0, 3);
|
|
|
|
|
|
|
|
layout_play_output_->addWidget(label_device_title_, 1, 0);
|
|
|
|
layout_play_output_->addWidget(label_device_space_, 1, 1);
|
|
|
|
layout_play_output_->addWidget(label_device_icon_, 1, 2);
|
|
|
|
layout_play_output_->addWidget(label_device_, 1, 3);
|
|
|
|
|
2020-04-08 22:32:01 +02:00
|
|
|
widget_play_output_->setLayout(layout_play_output_);
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
label_filetype_title_->setText(tr("Filetype"));
|
|
|
|
label_length_title_->setText(tr("Length"));
|
|
|
|
label_samplerate_title_->setText(tr("Samplerate"));
|
|
|
|
label_bitdepth_title_->setText(tr("Bit depth"));
|
|
|
|
label_bitrate_title_->setText(tr("Bitrate"));
|
|
|
|
|
|
|
|
label_filetype_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_length_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_samplerate_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_bitdepth_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
label_bitrate_title_->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
|
|
|
|
|
|
|
|
label_filetype_->setWordWrap(true);
|
|
|
|
label_length_->setWordWrap(true);
|
|
|
|
label_samplerate_->setWordWrap(true);
|
|
|
|
label_bitdepth_->setWordWrap(true);
|
|
|
|
label_bitrate_->setWordWrap(true);
|
|
|
|
|
|
|
|
layout_play_data_->setContentsMargins(0, 0, 0, 0);
|
|
|
|
layout_play_data_->addWidget(label_filetype_title_, 0, 0);
|
|
|
|
layout_play_data_->addWidget(label_filetype_, 0, 1);
|
|
|
|
layout_play_data_->addWidget(label_length_title_, 1, 0);
|
|
|
|
layout_play_data_->addWidget(label_length_, 1, 1);
|
|
|
|
layout_play_data_->addWidget(label_samplerate_title_, 2, 0);
|
|
|
|
layout_play_data_->addWidget(label_samplerate_, 2, 1);
|
|
|
|
layout_play_data_->addWidget(label_bitdepth_title_, 3, 0);
|
|
|
|
layout_play_data_->addWidget(label_bitdepth_, 3, 1);
|
|
|
|
layout_play_data_->addWidget(label_bitrate_title_, 4, 0);
|
|
|
|
layout_play_data_->addWidget(label_bitrate_, 4, 1);
|
|
|
|
|
|
|
|
widget_play_data_->setLayout(layout_play_data_);
|
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
textedit_play_lyrics_->setReadOnly(true);
|
|
|
|
textedit_play_lyrics_->setFrameShape(QFrame::NoFrame);
|
|
|
|
textedit_play_lyrics_->hide();
|
2020-04-06 02:47:57 +02:00
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
layout_play_->setContentsMargins(0, 0, 0, 0);
|
2020-04-08 22:32:01 +02:00
|
|
|
layout_play_->addWidget(widget_play_output_);
|
2020-04-06 02:47:57 +02:00
|
|
|
layout_play_->addSpacerItem(spacer_play_output_);
|
|
|
|
layout_play_->addWidget(widget_play_data_);
|
|
|
|
layout_play_->addSpacerItem(spacer_play_data_);
|
2022-06-05 04:39:45 +02:00
|
|
|
layout_play_->addWidget(textedit_play_lyrics_);
|
2022-06-09 23:09:24 +02:00
|
|
|
layout_play_->addSpacerItem(new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Expanding));
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2022-03-22 21:09:05 +01:00
|
|
|
labels_play_ << label_engine_title_
|
|
|
|
<< label_device_title_
|
|
|
|
<< label_filetype_title_
|
|
|
|
<< label_length_title_
|
|
|
|
<< label_samplerate_title_
|
|
|
|
<< label_bitdepth_title_
|
2022-06-05 11:58:53 +02:00
|
|
|
<< label_bitrate_title_;
|
2020-04-28 01:11:00 +02:00
|
|
|
|
|
|
|
labels_play_data_ << label_engine_icon_
|
|
|
|
<< label_engine_
|
|
|
|
<< label_device_
|
|
|
|
<< label_device_icon_
|
|
|
|
<< label_filetype_
|
|
|
|
<< label_length_
|
|
|
|
<< label_samplerate_
|
|
|
|
<< label_bitdepth_
|
2022-06-05 11:58:53 +02:00
|
|
|
<< label_bitrate_;
|
2020-04-28 01:11:00 +02:00
|
|
|
|
|
|
|
labels_play_all_ = labels_play_ << labels_play_data_;
|
|
|
|
|
2022-06-09 23:09:24 +02:00
|
|
|
textedit_play_ << textedit_play_lyrics_;
|
2020-04-06 02:47:57 +02:00
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
QObject::connect(widget_album_, &ContextAlbum::FadeStopFinished, this, &ContextView::FadeStopFinished);
|
2020-04-06 02:47:57 +02:00
|
|
|
|
|
|
|
}
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2019-06-06 18:22:41 +02:00
|
|
|
void ContextView::Init(Application *app, CollectionView *collectionview, AlbumCoverChoiceController *album_cover_choice_controller) {
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
app_ = app;
|
2018-09-04 21:43:44 +02:00
|
|
|
collectionview_ = collectionview;
|
|
|
|
album_cover_choice_controller_ = album_cover_choice_controller;
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-25 14:48:43 +02:00
|
|
|
widget_album_->Init(this, album_cover_choice_controller_);
|
2018-08-29 21:42:24 +02:00
|
|
|
lyrics_fetcher_ = new LyricsFetcher(app_->lyrics_providers(), this);
|
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
QObject::connect(collectionview_, &CollectionView::TotalSongCountUpdated_, this, &ContextView::UpdateNoSong);
|
|
|
|
QObject::connect(collectionview_, &CollectionView::TotalArtistCountUpdated_, this, &ContextView::UpdateNoSong);
|
|
|
|
QObject::connect(collectionview_, &CollectionView::TotalAlbumCountUpdated_, this, &ContextView::UpdateNoSong);
|
|
|
|
QObject::connect(lyrics_fetcher_, &LyricsFetcher::LyricsFetched, this, &ContextView::UpdateLyrics);
|
2018-09-04 21:43:44 +02:00
|
|
|
|
|
|
|
AddActions();
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::AddActions() {
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
action_show_album_ = new QAction(tr("Show album cover"), this);
|
|
|
|
action_show_album_->setCheckable(true);
|
|
|
|
action_show_album_->setChecked(true);
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
action_show_data_ = new QAction(tr("Show song technical data"), this);
|
|
|
|
action_show_data_->setCheckable(true);
|
|
|
|
action_show_data_->setChecked(true);
|
|
|
|
|
|
|
|
action_show_output_ = new QAction(tr("Show engine and device"), this);
|
|
|
|
action_show_output_->setCheckable(true);
|
2018-10-02 00:46:54 +02:00
|
|
|
action_show_output_->setChecked(true);
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
action_show_lyrics_ = new QAction(tr("Show song lyrics"), this);
|
|
|
|
action_show_lyrics_->setCheckable(true);
|
2020-04-25 14:48:43 +02:00
|
|
|
action_show_lyrics_->setChecked(true);
|
|
|
|
|
|
|
|
action_search_lyrics_ = new QAction(tr("Automatically search for song lyrics"), this);
|
|
|
|
action_search_lyrics_->setCheckable(true);
|
|
|
|
action_search_lyrics_->setChecked(true);
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
menu_options_->addAction(action_show_album_);
|
|
|
|
menu_options_->addAction(action_show_data_);
|
|
|
|
menu_options_->addAction(action_show_output_);
|
|
|
|
menu_options_->addAction(action_show_lyrics_);
|
|
|
|
menu_options_->addAction(action_search_lyrics_);
|
|
|
|
menu_options_->addSeparator();
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2019-12-22 12:09:05 +01:00
|
|
|
ReloadSettings();
|
2018-09-04 21:43:44 +02:00
|
|
|
|
2022-06-05 11:58:53 +02:00
|
|
|
QObject::connect(action_show_album_, &QAction::triggered, this, &ContextView::ActionShowAlbum);
|
2021-01-26 16:48:04 +01:00
|
|
|
QObject::connect(action_show_data_, &QAction::triggered, this, &ContextView::ActionShowData);
|
|
|
|
QObject::connect(action_show_output_, &QAction::triggered, this, &ContextView::ActionShowOutput);
|
|
|
|
QObject::connect(action_show_lyrics_, &QAction::triggered, this, &ContextView::ActionShowLyrics);
|
|
|
|
QObject::connect(action_search_lyrics_, &QAction::triggered, this, &ContextView::ActionSearchLyrics);
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::ReloadSettings() {
|
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
|
|
|
title_fmt_ = s.value(ContextSettingsPage::kSettingsTitleFmt, "%title% - %artist%").toString();
|
|
|
|
summary_fmt_ = s.value(ContextSettingsPage::kSettingsSummaryFmt, "%album%").toString();
|
2023-02-18 14:09:27 +01:00
|
|
|
action_show_album_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ALBUM)], true).toBool());
|
|
|
|
action_show_data_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::TECHNICAL_DATA)], false).toBool());
|
|
|
|
action_show_output_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE)], false).toBool());
|
|
|
|
action_show_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS)], true).toBool());
|
|
|
|
action_search_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS)], true).toBool());
|
2020-04-28 01:11:00 +02:00
|
|
|
font_headline_ = s.value("font_headline", font().family()).toString();
|
|
|
|
font_normal_ = s.value("font_normal", font().family()).toString();
|
2022-03-22 21:09:05 +01:00
|
|
|
font_size_headline_ = s.value("font_size_headline", ContextSettingsPage::kDefaultFontSizeHeadline).toReal();
|
2020-04-28 01:11:00 +02:00
|
|
|
font_size_normal_ = s.value("font_size_normal", font().pointSizeF()).toReal();
|
2020-04-06 02:47:57 +02:00
|
|
|
s.endGroup();
|
|
|
|
|
2020-04-28 01:11:00 +02:00
|
|
|
UpdateFonts();
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
if (widget_stacked_->currentWidget() == widget_stop_) {
|
|
|
|
NoSong();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
SetSong();
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2022-06-06 20:54:15 +02:00
|
|
|
void ContextView::resizeEvent(QResizeEvent *e) {
|
|
|
|
|
2022-06-09 00:46:39 +02:00
|
|
|
if (e->size().width() != e->oldSize().width()) {
|
|
|
|
widget_album_->UpdateWidth(width() - kWidgetSpacing);
|
2022-06-06 20:54:15 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::resizeEvent(e);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-04 21:43:44 +02:00
|
|
|
void ContextView::Playing() {}
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
void ContextView::Stopped() {
|
|
|
|
|
2018-09-22 23:13:56 +02:00
|
|
|
song_playing_ = Song();
|
|
|
|
song_prev_ = Song();
|
2020-04-25 14:48:43 +02:00
|
|
|
lyrics_.clear();
|
2020-04-06 02:47:57 +02:00
|
|
|
image_original_ = QImage();
|
|
|
|
widget_album_->SetImage();
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-04 21:43:44 +02:00
|
|
|
void ContextView::Error() {}
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
void ContextView::SongChanged(const Song &song) {
|
|
|
|
|
2020-04-20 18:03:18 +02:00
|
|
|
if (widget_stacked_->currentWidget() == widget_play_ && song_playing_.is_valid() && song == song_playing_ && song.title() == song_playing_.title() && song.album() == song_playing_.album() && song.artist() == song_playing_.artist()) {
|
2018-09-22 23:13:56 +02:00
|
|
|
UpdateSong(song);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
song_prev_ = song_playing_;
|
2020-04-20 18:03:18 +02:00
|
|
|
song_playing_ = song;
|
2018-09-22 23:13:56 +02:00
|
|
|
lyrics_ = song.lyrics();
|
|
|
|
lyrics_id_ = -1;
|
2020-04-20 18:03:18 +02:00
|
|
|
lyrics_tried_ = false;
|
2020-04-06 02:47:57 +02:00
|
|
|
SetSong();
|
2020-04-20 18:03:18 +02:00
|
|
|
}
|
|
|
|
|
2020-04-25 14:48:43 +02:00
|
|
|
SearchLyrics();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::SearchLyrics() {
|
|
|
|
|
|
|
|
if (lyrics_.isEmpty() && action_show_lyrics_->isChecked() && action_search_lyrics_->isChecked() && !song_playing_.artist().isEmpty() && !song_playing_.title().isEmpty() && !lyrics_tried_ && lyrics_id_ == -1) {
|
2020-04-20 18:03:18 +02:00
|
|
|
lyrics_fetcher_->Clear();
|
|
|
|
lyrics_tried_ = true;
|
2023-03-06 21:42:59 +01:00
|
|
|
lyrics_id_ = static_cast<qint64>(lyrics_fetcher_->Search(song_playing_.effective_albumartist(), song_playing_.artist(), song_playing_.album(), song_playing_.title()));
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::FadeStopFinished() {
|
2019-12-22 12:09:05 +01:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
widget_stacked_->setCurrentWidget(widget_stop_);
|
|
|
|
NoSong();
|
|
|
|
ResetSong();
|
2022-06-09 23:09:24 +02:00
|
|
|
widget_stacked_->updateGeometry();
|
2019-12-22 12:09:05 +01:00
|
|
|
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::SetLabelText(QLabel *label, int value, const QString &suffix, const QString &def) {
|
2018-08-29 21:42:24 +02:00
|
|
|
label->setText(value <= 0 ? def : (QString::number(value) + " " + suffix));
|
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::UpdateNoSong() {
|
|
|
|
if (widget_stacked_->currentWidget() == widget_stop_) NoSong();
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
void ContextView::NoSong() {
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
if (!widget_album_->isVisible()) {
|
|
|
|
widget_album_->show();
|
|
|
|
}
|
|
|
|
|
2022-09-23 18:10:01 +02:00
|
|
|
textedit_top_->setFont(QFont(font_headline_, font_size_headline_ * 1.6));
|
2022-11-16 21:10:23 +01:00
|
|
|
textedit_top_->SetText(tr("No song playing"));
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2019-12-29 23:37:48 +01:00
|
|
|
QString html;
|
|
|
|
if (collectionview_->TotalSongs() == 1) html += tr("%1 song").arg(collectionview_->TotalSongs());
|
|
|
|
else html += tr("%1 songs").arg(collectionview_->TotalSongs());
|
|
|
|
html += "<br />";
|
|
|
|
|
|
|
|
if (collectionview_->TotalArtists() == 1) html += tr("%1 artist").arg(collectionview_->TotalArtists());
|
|
|
|
else html += tr("%1 artists").arg(collectionview_->TotalArtists());
|
|
|
|
html += "<br />";
|
|
|
|
|
|
|
|
if (collectionview_->TotalAlbums() == 1) html += tr("%1 album").arg(collectionview_->TotalAlbums());
|
|
|
|
else html += tr("%1 albums").arg(collectionview_->TotalAlbums());
|
|
|
|
html += "<br />";
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2022-09-23 18:10:01 +02:00
|
|
|
label_stop_summary_->setFont(QFont(font_normal_, font_size_normal_));
|
2020-04-06 02:47:57 +02:00
|
|
|
label_stop_summary_->setText(html);
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-28 01:11:00 +02:00
|
|
|
void ContextView::UpdateFonts() {
|
|
|
|
|
2022-09-23 18:10:01 +02:00
|
|
|
QFont font(font_normal_, font_size_normal_);
|
|
|
|
font.setBold(false);
|
2021-07-11 09:49:38 +02:00
|
|
|
for (QLabel *l : labels_play_all_) {
|
2022-09-23 18:10:01 +02:00
|
|
|
l->setFont(font);
|
2022-06-05 04:39:45 +02:00
|
|
|
}
|
|
|
|
for (QTextEdit *e : textedit_play_) {
|
2022-09-23 18:10:01 +02:00
|
|
|
e->setFont(font);
|
2020-04-28 01:11:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::SetSong() {
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2022-09-23 18:10:01 +02:00
|
|
|
textedit_top_->setFont(QFont(font_headline_, font_size_headline_));
|
2022-11-16 21:10:23 +01:00
|
|
|
textedit_top_->SetText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song_playing_, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song_playing_, "<br />", true)));
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
label_stop_summary_->clear();
|
|
|
|
|
|
|
|
bool widget_album_changed = !song_prev_.is_valid();
|
|
|
|
if (action_show_album_->isChecked() && !widget_album_->isVisible()) {
|
|
|
|
widget_album_->show();
|
|
|
|
widget_album_changed = true;
|
|
|
|
}
|
|
|
|
else if (!action_show_album_->isChecked() && widget_album_->isVisible()) {
|
|
|
|
widget_album_->hide();
|
|
|
|
widget_album_changed = true;
|
|
|
|
}
|
|
|
|
if (widget_album_changed) emit AlbumEnabledChanged();
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
if (action_show_data_->isChecked()) {
|
2020-04-06 02:47:57 +02:00
|
|
|
widget_play_data_->show();
|
|
|
|
label_filetype_->setText(song_playing_.TextForFiletype());
|
2020-04-20 18:46:26 +02:00
|
|
|
if (song_playing_.length_nanosec() <= 0) {
|
|
|
|
label_length_title_->hide();
|
|
|
|
label_length_->hide();
|
|
|
|
label_length_->clear();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
label_length_title_->show();
|
|
|
|
label_length_->show();
|
|
|
|
label_length_->setText(Utilities::PrettyTimeNanosec(song_playing_.length_nanosec()));
|
|
|
|
}
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.samplerate() <= 0) {
|
|
|
|
label_samplerate_title_->hide();
|
|
|
|
label_samplerate_->hide();
|
|
|
|
label_samplerate_->clear();
|
2018-09-08 13:25:40 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_samplerate_title_->show();
|
|
|
|
label_samplerate_->show();
|
|
|
|
SetLabelText(label_samplerate_, song_playing_.samplerate(), "Hz");
|
2018-09-08 13:25:40 +02:00
|
|
|
}
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.bitdepth() <= 0) {
|
|
|
|
label_bitdepth_title_->hide();
|
|
|
|
label_bitdepth_->hide();
|
|
|
|
label_bitdepth_->clear();
|
2018-09-08 13:25:40 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_bitdepth_title_->show();
|
|
|
|
label_bitdepth_->show();
|
|
|
|
SetLabelText(label_bitdepth_, song_playing_.bitdepth(), "Bit");
|
2018-09-08 13:25:40 +02:00
|
|
|
}
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.bitrate() <= 0) {
|
|
|
|
label_bitrate_title_->hide();
|
|
|
|
label_bitrate_->hide();
|
|
|
|
label_bitrate_->clear();
|
2018-09-08 13:25:40 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_bitrate_title_->show();
|
|
|
|
label_bitrate_->show();
|
|
|
|
SetLabelText(label_bitrate_, song_playing_.bitrate(), tr("kbps"));
|
2018-09-08 13:25:40 +02:00
|
|
|
}
|
2020-04-06 02:47:57 +02:00
|
|
|
spacer_play_data_->changeSize(20, 20, QSizePolicy::Fixed);
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
widget_play_data_->hide();
|
|
|
|
label_filetype_->clear();
|
|
|
|
label_length_->clear();
|
|
|
|
label_samplerate_->clear();
|
|
|
|
label_bitdepth_->clear();
|
|
|
|
label_bitrate_->clear();
|
|
|
|
spacer_play_data_->changeSize(0, 0, QSizePolicy::Fixed);
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (action_show_output_->isChecked()) {
|
2020-04-08 22:32:01 +02:00
|
|
|
widget_play_output_->show();
|
2023-02-18 14:09:27 +01:00
|
|
|
Engine::EngineType enginetype(Engine::EngineType::None);
|
2018-08-29 21:42:24 +02:00
|
|
|
if (app_->player()->engine()) enginetype = app_->player()->engine()->type();
|
2023-01-01 16:02:17 +01:00
|
|
|
QIcon icon_engine = IconLoader::Load(EngineName(enginetype), true, 32);
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-27 21:36:49 +02:00
|
|
|
label_engine_icon_->setPixmap(icon_engine.pixmap(QSize(32, 32)));
|
2020-04-06 02:47:57 +02:00
|
|
|
label_engine_->setText(EngineDescription(enginetype));
|
|
|
|
spacer_play_output_->changeSize(20, 20, QSizePolicy::Fixed);
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
DeviceFinder::Device device;
|
2019-11-03 19:53:08 +01:00
|
|
|
for (DeviceFinder *f : app_->device_finders()->ListFinders()) {
|
2018-08-29 21:42:24 +02:00
|
|
|
for (const DeviceFinder::Device &d : f->ListDevices()) {
|
|
|
|
if (d.value != app_->player()->engine()->device()) continue;
|
|
|
|
device = d;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (device.value.isValid()) {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_device_title_->show();
|
|
|
|
label_device_icon_->show();
|
|
|
|
label_device_->show();
|
2023-01-01 16:02:17 +01:00
|
|
|
QIcon icon_device = IconLoader::Load(device.iconname, true, 32);
|
2020-04-27 21:36:49 +02:00
|
|
|
label_device_icon_->setPixmap(icon_device.pixmap(QSize(32, 32)));
|
2020-04-06 02:47:57 +02:00
|
|
|
label_device_->setText(device.description);
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_device_title_->hide();
|
|
|
|
label_device_icon_->hide();
|
|
|
|
label_device_->hide();
|
|
|
|
label_device_icon_->clear();
|
|
|
|
label_device_->clear();
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
2020-04-08 22:32:01 +02:00
|
|
|
widget_play_output_->hide();
|
2020-04-06 02:47:57 +02:00
|
|
|
label_engine_icon_->clear();
|
|
|
|
label_engine_->clear();
|
|
|
|
label_device_icon_->clear();
|
|
|
|
label_device_->clear();
|
|
|
|
spacer_play_output_->changeSize(0, 0, QSizePolicy::Fixed);
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
2022-06-05 04:39:45 +02:00
|
|
|
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {
|
2022-11-16 21:10:23 +01:00
|
|
|
textedit_play_lyrics_->SetText(lyrics_);
|
2022-06-05 04:39:45 +02:00
|
|
|
textedit_play_lyrics_->show();
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
else {
|
2022-06-05 04:39:45 +02:00
|
|
|
textedit_play_lyrics_->clear();
|
|
|
|
textedit_play_lyrics_->hide();
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
widget_stacked_->setCurrentWidget(widget_play_);
|
2022-06-09 23:09:24 +02:00
|
|
|
widget_stacked_->updateGeometry();
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2018-09-22 23:13:56 +02:00
|
|
|
void ContextView::UpdateSong(const Song &song) {
|
|
|
|
|
2022-11-16 21:10:23 +01:00
|
|
|
textedit_top_->SetText(QString("<b>%1</b><br />%2").arg(Utilities::ReplaceMessage(title_fmt_, song, "<br />", true), Utilities::ReplaceMessage(summary_fmt_, song, "<br />", true)));
|
2018-09-22 23:13:56 +02:00
|
|
|
|
|
|
|
if (action_show_data_->isChecked()) {
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song.filetype() != song_playing_.filetype()) label_filetype_->setText(song.TextForFiletype());
|
2021-07-11 09:49:38 +02:00
|
|
|
if (song.length_nanosec() != song_playing_.length_nanosec()) {
|
2020-04-20 18:52:59 +02:00
|
|
|
if (song.length_nanosec() <= 0) {
|
2020-04-20 18:46:26 +02:00
|
|
|
label_length_title_->hide();
|
|
|
|
label_length_->hide();
|
|
|
|
label_length_->clear();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
label_length_title_->show();
|
|
|
|
label_length_->show();
|
|
|
|
label_length_->setText(Utilities::PrettyTimeNanosec(song.length_nanosec()));
|
|
|
|
}
|
|
|
|
}
|
2018-09-22 23:13:56 +02:00
|
|
|
if (song.samplerate() != song_playing_.samplerate()) {
|
|
|
|
if (song.samplerate() <= 0) {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_samplerate_title_->hide();
|
|
|
|
label_samplerate_->hide();
|
|
|
|
label_samplerate_->clear();
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_samplerate_title_->show();
|
|
|
|
label_samplerate_->show();
|
|
|
|
SetLabelText(label_samplerate_, song.samplerate(), "Hz");
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (song.bitdepth() != song_playing_.bitdepth()) {
|
|
|
|
if (song.bitdepth() <= 0) {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_bitdepth_title_->hide();
|
|
|
|
label_bitdepth_->hide();
|
|
|
|
label_bitdepth_->clear();
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_bitdepth_title_->show();
|
|
|
|
label_bitdepth_->show();
|
|
|
|
SetLabelText(label_bitdepth_, song.bitdepth(), "Bit");
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (song.bitrate() != song_playing_.bitrate()) {
|
|
|
|
if (song.bitrate() <= 0) {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_bitrate_title_->hide();
|
|
|
|
label_bitrate_->hide();
|
|
|
|
label_bitrate_->clear();
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
else {
|
2020-04-06 02:47:57 +02:00
|
|
|
label_bitrate_title_->show();
|
|
|
|
label_bitrate_->show();
|
|
|
|
SetLabelText(label_bitrate_, song.bitrate(), tr("kbps"));
|
2018-09-22 23:13:56 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
song_playing_ = song;
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2022-11-16 21:10:23 +01:00
|
|
|
widget_stacked_->updateGeometry();
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::ResetSong() {
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2021-07-11 09:49:38 +02:00
|
|
|
for (QLabel *l : labels_play_data_) {
|
2020-04-06 02:47:57 +02:00
|
|
|
l->clear();
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
2018-10-02 00:38:52 +02:00
|
|
|
|
2022-06-09 23:09:24 +02:00
|
|
|
for (QTextEdit *l : textedit_play_) {
|
|
|
|
l->clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
widget_play_output_->hide();
|
|
|
|
widget_play_data_->hide();
|
|
|
|
textedit_play_lyrics_->hide();
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
2021-10-30 03:15:03 +02:00
|
|
|
void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const QString &lyrics) {
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2021-10-30 03:15:03 +02:00
|
|
|
if (static_cast<qint64>(id) != lyrics_id_) return;
|
2022-06-05 04:39:45 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
lyrics_ = lyrics + "\n\n(Lyrics from " + provider + ")\n";
|
|
|
|
lyrics_id_ = -1;
|
2022-06-05 04:39:45 +02:00
|
|
|
|
|
|
|
if (action_show_lyrics_->isChecked() && !lyrics_.isEmpty()) {
|
2022-11-16 21:10:23 +01:00
|
|
|
textedit_play_lyrics_->SetText(lyrics_);
|
2022-06-05 04:39:45 +02:00
|
|
|
textedit_play_lyrics_->show();
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
textedit_play_lyrics_->clear();
|
|
|
|
textedit_play_lyrics_->hide();
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
2019-09-15 20:27:32 +02:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::contextMenuEvent(QContextMenuEvent *e) {
|
2022-06-05 04:39:45 +02:00
|
|
|
|
2022-06-05 18:19:14 +02:00
|
|
|
if (menu_options_ && widget_stacked_->currentWidget() == widget_stop_) {
|
2022-06-05 04:39:45 +02:00
|
|
|
menu_options_->popup(mapToGlobal(e->pos()));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
QWidget::contextMenuEvent(e);
|
|
|
|
}
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::dragEnterEvent(QDragEnterEvent *e) {
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.is_valid() && AlbumCoverChoiceController::CanAcceptDrag(e)) {
|
|
|
|
e->acceptProposedAction();
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
QWidget::dragEnterEvent(e);
|
2020-04-06 02:47:57 +02:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::dropEvent(QDropEvent *e) {
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.is_valid()) {
|
|
|
|
album_cover_choice_controller_->SaveCover(&song_playing_, e);
|
|
|
|
}
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
QWidget::dropEvent(e);
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-20 18:03:18 +02:00
|
|
|
void ContextView::AlbumCoverLoaded(const Song &song, const QImage &image) {
|
2019-09-15 20:27:32 +02:00
|
|
|
|
2019-07-31 22:26:51 +02:00
|
|
|
if (song != song_playing_ || image == image_original_) return;
|
2018-08-29 21:42:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
widget_album_->SetImage(image);
|
2018-08-29 21:42:24 +02:00
|
|
|
image_original_ = image;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
void ContextView::ActionShowAlbum() {
|
2019-07-07 21:14:24 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
2023-02-18 14:09:27 +01:00
|
|
|
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ALBUM)], action_show_album_->isChecked());
|
2020-04-06 02:47:57 +02:00
|
|
|
s.endGroup();
|
|
|
|
if (song_playing_.is_valid()) SetSong();
|
2018-08-29 21:42:24 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::ActionShowData() {
|
2020-04-06 02:47:57 +02:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
QSettings s;
|
2019-12-22 12:09:05 +01:00
|
|
|
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
2023-02-18 14:09:27 +01:00
|
|
|
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::TECHNICAL_DATA)], action_show_data_->isChecked());
|
2018-08-29 21:42:24 +02:00
|
|
|
s.endGroup();
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.is_valid()) SetSong();
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::ActionShowOutput() {
|
2020-04-06 02:47:57 +02:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
QSettings s;
|
2019-12-22 12:09:05 +01:00
|
|
|
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
2023-02-18 14:09:27 +01:00
|
|
|
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE)], action_show_output_->isChecked());
|
2018-08-29 21:42:24 +02:00
|
|
|
s.endGroup();
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.is_valid()) SetSong();
|
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::ActionShowLyrics() {
|
2020-04-06 02:47:57 +02:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
QSettings s;
|
2019-12-22 12:09:05 +01:00
|
|
|
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
2023-02-18 14:09:27 +01:00
|
|
|
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS)], action_show_lyrics_->isChecked());
|
2018-08-29 21:42:24 +02:00
|
|
|
s.endGroup();
|
2020-04-25 14:48:43 +02:00
|
|
|
|
2020-04-06 02:47:57 +02:00
|
|
|
if (song_playing_.is_valid()) SetSong();
|
|
|
|
|
2020-04-25 14:48:43 +02:00
|
|
|
SearchLyrics();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void ContextView::ActionSearchLyrics() {
|
|
|
|
|
|
|
|
QSettings s;
|
|
|
|
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
2023-02-18 14:09:27 +01:00
|
|
|
s.setValue(ContextSettingsPage::kSettingsGroupEnable[static_cast<int>(ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS)], action_search_lyrics_->isChecked());
|
2020-04-25 14:48:43 +02:00
|
|
|
s.endGroup();
|
|
|
|
|
|
|
|
if (song_playing_.is_valid()) SetSong();
|
|
|
|
|
|
|
|
SearchLyrics();
|
2020-04-06 02:47:57 +02:00
|
|
|
|
2018-08-29 21:42:24 +02:00
|
|
|
}
|