mirror of
https://github.com/strawberrymusicplayer/strawberry
synced 2024-12-16 10:38:53 +01:00
Add search for lyrics as a seperate option
Double click album to show fullsize Fixes #299
This commit is contained in:
parent
ae05a61551
commit
f14c3654dc
@ -33,17 +33,22 @@
|
||||
#include <QTimeLine>
|
||||
#include <QPainter>
|
||||
#include <QSizePolicy>
|
||||
#include <QMenu>
|
||||
#include <QContextMenuEvent>
|
||||
#include <QPaintEvent>
|
||||
|
||||
#include "covermanager/albumcoverchoicecontroller.h"
|
||||
#include "covermanager/albumcoverloader.h"
|
||||
|
||||
#include "contextview.h"
|
||||
#include "contextalbum.h"
|
||||
|
||||
const int ContextAlbum::kWidgetSpacing = 40;
|
||||
|
||||
ContextAlbum::ContextAlbum(QWidget *parent) :
|
||||
QWidget(parent),
|
||||
menu_(new QMenu(this)),
|
||||
context_view_(nullptr),
|
||||
album_cover_choice_controller_(nullptr),
|
||||
downloading_covers_(false),
|
||||
timeline_fade_(new QTimeLine(1000, this)),
|
||||
@ -65,11 +70,31 @@ ContextAlbum::ContextAlbum(QWidget *parent) :
|
||||
|
||||
}
|
||||
|
||||
void ContextAlbum::Init(AlbumCoverChoiceController *album_cover_choice_controller) {
|
||||
void ContextAlbum::Init(ContextView *context_view, AlbumCoverChoiceController *album_cover_choice_controller) {
|
||||
|
||||
context_view_ = context_view;
|
||||
|
||||
album_cover_choice_controller_ = album_cover_choice_controller;
|
||||
connect(album_cover_choice_controller_, SIGNAL(AutomaticCoverSearchDone()), this, SLOT(AutomaticCoverSearchDone()));
|
||||
|
||||
QList<QAction*> cover_actions = album_cover_choice_controller_->GetAllActions();
|
||||
cover_actions.append(album_cover_choice_controller_->search_cover_auto_action());
|
||||
menu_->addActions(cover_actions);
|
||||
menu_->addSeparator();
|
||||
|
||||
}
|
||||
|
||||
void ContextAlbum::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (menu_ && image_original_ != image_strawberry_) menu_->popup(mapToGlobal(e->pos()));
|
||||
}
|
||||
|
||||
void ContextAlbum::mouseDoubleClickEvent(QMouseEvent *e) {
|
||||
|
||||
// Same behaviour as right-click > Show Fullsize
|
||||
if (image_original_ != image_strawberry_ && e->button() == Qt::LeftButton && context_view_->song_playing().is_valid()) {
|
||||
album_cover_choice_controller_->ShowCover(context_view_->song_playing(), image_original_);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void ContextAlbum::paintEvent(QPaintEvent*) {
|
||||
|
@ -34,10 +34,12 @@
|
||||
|
||||
#include "covermanager/albumcoverloaderoptions.h"
|
||||
|
||||
class QMenu;
|
||||
class QTimeLine;
|
||||
class QPainter;
|
||||
class QPaintEvent;
|
||||
|
||||
class ContextView;
|
||||
class AlbumCoverChoiceController;
|
||||
|
||||
class ContextAlbum : public QWidget {
|
||||
@ -46,11 +48,13 @@ class ContextAlbum : public QWidget {
|
||||
public:
|
||||
explicit ContextAlbum(QWidget *parent = nullptr);
|
||||
|
||||
void Init(AlbumCoverChoiceController *album_cover_choice_controller);
|
||||
void Init(ContextView *context_view, AlbumCoverChoiceController *album_cover_choice_controller);
|
||||
void SetImage(QImage image = QImage());
|
||||
|
||||
protected:
|
||||
void paintEvent(QPaintEvent*);
|
||||
void contextMenuEvent(QContextMenuEvent *e);
|
||||
void mouseDoubleClickEvent(QMouseEvent *e);
|
||||
|
||||
private:
|
||||
void DrawImage(QPainter *p);
|
||||
@ -67,6 +71,10 @@ class ContextAlbum : public QWidget {
|
||||
|
||||
private:
|
||||
static const int kWidgetSpacing;
|
||||
|
||||
private:
|
||||
QMenu *menu_;
|
||||
ContextView *context_view_;
|
||||
AlbumCoverChoiceController *album_cover_choice_controller_;
|
||||
AlbumCoverLoaderOptions cover_loader_options_;
|
||||
bool downloading_covers_;
|
||||
|
@ -80,6 +80,7 @@ ContextView::ContextView(QWidget *parent) :
|
||||
action_show_output_(nullptr),
|
||||
action_show_albums_(nullptr),
|
||||
action_show_lyrics_(nullptr),
|
||||
action_search_lyrics_(nullptr),
|
||||
layout_container_(new QVBoxLayout()),
|
||||
widget_scrollarea_(new QWidget(this)),
|
||||
layout_scrollarea_(new QVBoxLayout()),
|
||||
@ -271,7 +272,7 @@ void ContextView::Init(Application *app, CollectionView *collectionview, AlbumCo
|
||||
collectionview_ = collectionview;
|
||||
album_cover_choice_controller_ = album_cover_choice_controller;
|
||||
|
||||
widget_album_->Init(album_cover_choice_controller_);
|
||||
widget_album_->Init(this, album_cover_choice_controller_);
|
||||
widget_albums_->Init(app_);
|
||||
lyrics_fetcher_ = new LyricsFetcher(app_->lyrics_providers(), this);
|
||||
|
||||
@ -300,22 +301,22 @@ void ContextView::AddActions() {
|
||||
|
||||
action_show_albums_ = new QAction(tr("Show albums by artist"), this);
|
||||
action_show_albums_->setCheckable(true);
|
||||
action_show_albums_->setChecked(true);
|
||||
action_show_albums_->setChecked(false);
|
||||
|
||||
action_show_lyrics_ = new QAction(tr("Show song lyrics"), this);
|
||||
action_show_lyrics_->setCheckable(true);
|
||||
action_show_lyrics_->setChecked(false);
|
||||
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);
|
||||
|
||||
menu_->addAction(action_show_album_);
|
||||
menu_->addAction(action_show_data_);
|
||||
menu_->addAction(action_show_output_);
|
||||
menu_->addAction(action_show_albums_);
|
||||
menu_->addAction(action_show_lyrics_);
|
||||
menu_->addSeparator();
|
||||
|
||||
QList<QAction*> cover_actions = album_cover_choice_controller_->GetAllActions();
|
||||
cover_actions.append(album_cover_choice_controller_->search_cover_auto_action());
|
||||
menu_->addActions(cover_actions);
|
||||
menu_->addAction(action_search_lyrics_);
|
||||
menu_->addSeparator();
|
||||
|
||||
ReloadSettings();
|
||||
@ -325,6 +326,7 @@ void ContextView::AddActions() {
|
||||
connect(action_show_output_, SIGNAL(triggered()), this, SLOT(ActionShowOutput()));
|
||||
connect(action_show_albums_, SIGNAL(triggered()), this, SLOT(ActionShowAlbums()));
|
||||
connect(action_show_lyrics_, SIGNAL(triggered()), this, SLOT(ActionShowLyrics()));
|
||||
connect(action_search_lyrics_, SIGNAL(triggered()), this, SLOT(ActionSearchLyrics()));
|
||||
|
||||
}
|
||||
|
||||
@ -339,6 +341,7 @@ void ContextView::ReloadSettings() {
|
||||
action_show_output_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::ENGINE_AND_DEVICE], true).toBool());
|
||||
action_show_albums_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::ALBUMS_BY_ARTIST], false).toBool());
|
||||
action_show_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS], true).toBool());
|
||||
action_search_lyrics_->setChecked(s.value(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS], true).toBool());
|
||||
s.endGroup();
|
||||
|
||||
if (widget_stacked_->currentWidget() == widget_stop_) {
|
||||
@ -356,7 +359,7 @@ void ContextView::Stopped() {
|
||||
|
||||
song_playing_ = Song();
|
||||
song_prev_ = Song();
|
||||
lyrics_ = QString();
|
||||
lyrics_.clear();
|
||||
image_original_ = QImage();
|
||||
widget_album_->SetImage();
|
||||
|
||||
@ -378,10 +381,16 @@ void ContextView::SongChanged(const Song &song) {
|
||||
SetSong();
|
||||
}
|
||||
|
||||
if (lyrics_.isEmpty() && action_show_lyrics_->isChecked() && !song.artist().isEmpty() && !song.title().isEmpty() && !lyrics_tried_ && lyrics_id_ == -1) {
|
||||
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) {
|
||||
lyrics_fetcher_->Clear();
|
||||
lyrics_tried_ = true;
|
||||
lyrics_id_ = lyrics_fetcher_->Search(song.effective_albumartist(), song.album(), song.title());
|
||||
lyrics_id_ = lyrics_fetcher_->Search(song_playing_.effective_albumartist(), song_playing_.album(), song_playing_.title());
|
||||
}
|
||||
|
||||
}
|
||||
@ -685,7 +694,7 @@ void ContextView::UpdateLyrics(const quint64 id, const QString &provider, const
|
||||
}
|
||||
|
||||
void ContextView::contextMenuEvent(QContextMenuEvent *e) {
|
||||
if (menu_ && widget_stacked_->currentWidget() == widget_play_) menu_->popup(mapToGlobal(e->pos()));
|
||||
if (menu_) menu_->popup(mapToGlobal(e->pos()));
|
||||
}
|
||||
|
||||
void ContextView::dragEnterEvent(QDragEnterEvent *e) {
|
||||
@ -764,11 +773,22 @@ void ContextView::ActionShowLyrics() {
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SONG_LYRICS], action_show_lyrics_->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
|
||||
if (lyrics_.isEmpty() && action_show_lyrics_->isChecked() && !song_playing_.artist().isEmpty() && !song_playing_.title().isEmpty()) {
|
||||
lyrics_fetcher_->Clear();
|
||||
lyrics_id_ = lyrics_fetcher_->Search(song_playing_.artist(), song_playing_.album(), song_playing_.title());
|
||||
}
|
||||
SearchLyrics();
|
||||
|
||||
}
|
||||
|
||||
void ContextView::ActionSearchLyrics() {
|
||||
|
||||
QSettings s;
|
||||
s.beginGroup(ContextSettingsPage::kSettingsGroup);
|
||||
s.setValue(ContextSettingsPage::kSettingsGroupEnable[ContextSettingsPage::ContextSettingsOrder::SEARCH_LYRICS], action_search_lyrics_->isChecked());
|
||||
s.endGroup();
|
||||
|
||||
if (song_playing_.is_valid()) SetSong();
|
||||
|
||||
SearchLyrics();
|
||||
|
||||
}
|
||||
|
@ -61,6 +61,7 @@ class ContextView : public QWidget {
|
||||
ContextAlbum *album_widget() const { return widget_album_; }
|
||||
ContextAlbumsView *albums_widget() const { return widget_albums_; }
|
||||
bool album_enabled() const { return widget_album_->isVisible(); }
|
||||
Song song_playing() const { return song_playing_; }
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent*);
|
||||
@ -76,6 +77,7 @@ class ContextView : public QWidget {
|
||||
void UpdateSong(const Song &song);
|
||||
void ResetSong();
|
||||
void GetCoverAutomatically();
|
||||
void SearchLyrics();
|
||||
|
||||
signals:
|
||||
void AlbumEnabledChanged();
|
||||
@ -86,6 +88,7 @@ class ContextView : public QWidget {
|
||||
void ActionShowOutput();
|
||||
void ActionShowAlbums();
|
||||
void ActionShowLyrics();
|
||||
void ActionSearchLyrics();
|
||||
void UpdateNoSong();
|
||||
void Playing();
|
||||
void Stopped();
|
||||
@ -110,6 +113,7 @@ class ContextView : public QWidget {
|
||||
QAction *action_show_output_;
|
||||
QAction *action_show_albums_;
|
||||
QAction *action_show_lyrics_;
|
||||
QAction *action_search_lyrics_;
|
||||
|
||||
QVBoxLayout *layout_container_;
|
||||
QWidget *widget_scrollarea_;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* This code was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2019, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
@ -47,6 +47,7 @@ const char *ContextSettingsPage::kSettingsGroupLabels[ContextSettingsOrder::NELE
|
||||
"Albums by Artist",
|
||||
"Song Lyrics",
|
||||
"Album",
|
||||
"Automatically search for song lyrics",
|
||||
};
|
||||
const char *ContextSettingsPage::kSettingsGroupEnable[ContextSettingsOrder::NELEMS] = {
|
||||
"TechnicalDataEnable",
|
||||
@ -54,6 +55,7 @@ const char *ContextSettingsPage::kSettingsGroupEnable[ContextSettingsOrder::NELE
|
||||
"AlbumsByArtistEnable",
|
||||
"SongLyricsEnable",
|
||||
"AlbumEnable",
|
||||
"SearchLyricsEnable",
|
||||
};
|
||||
|
||||
ContextSettingsPage::ContextSettingsPage(SettingsDialog* dialog) : SettingsPage(dialog), ui_(new Ui_ContextSettingsPage) {
|
||||
@ -61,11 +63,12 @@ ContextSettingsPage::ContextSettingsPage(SettingsDialog* dialog) : SettingsPage(
|
||||
ui_->setupUi(this);
|
||||
setWindowIcon(IconLoader::Load("view-choose"));
|
||||
|
||||
checkboxes[ContextSettingsOrder::ALBUM] = ui_->context_item1_enable;
|
||||
checkboxes[ContextSettingsOrder::TECHNICAL_DATA] = ui_->context_item2_enable;
|
||||
checkboxes[ContextSettingsOrder::ENGINE_AND_DEVICE] = ui_->context_item3_enable;
|
||||
checkboxes[ContextSettingsOrder::ALBUMS_BY_ARTIST] = ui_->context_item4_enable;
|
||||
checkboxes[ContextSettingsOrder::SONG_LYRICS] = ui_->context_item5_enable;
|
||||
checkboxes[ContextSettingsOrder::ALBUM] = ui_->checkbox_album;
|
||||
checkboxes[ContextSettingsOrder::TECHNICAL_DATA] = ui_->checkbox_technical_data;
|
||||
checkboxes[ContextSettingsOrder::ENGINE_AND_DEVICE] = ui_->checkbox_engine_device;
|
||||
checkboxes[ContextSettingsOrder::ALBUMS_BY_ARTIST] = ui_->checkbox_albums;
|
||||
checkboxes[ContextSettingsOrder::SONG_LYRICS] = ui_->checkbox_song_lyrics;
|
||||
checkboxes[ContextSettingsOrder::SEARCH_LYRICS] = ui_->checkbox_search_lyrics;
|
||||
|
||||
// Create and populate the helper menus
|
||||
QMenu *menu = new QMenu(this);
|
||||
|
@ -1,6 +1,6 @@
|
||||
/*
|
||||
* Strawberry Music Player
|
||||
* This file was part of Clementine.
|
||||
* This code was part of Clementine.
|
||||
* Copyright 2010, David Sansome <me@davidsansome.com>
|
||||
* Copyright 2018-2019, Jonas Kvinge <jonas@jkvinge.net>
|
||||
*
|
||||
@ -48,6 +48,7 @@ public:
|
||||
ALBUMS_BY_ARTIST,
|
||||
SONG_LYRICS,
|
||||
ALBUM,
|
||||
SEARCH_LYRICS,
|
||||
NELEMS
|
||||
};
|
||||
|
||||
|
@ -147,7 +147,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="context_item1_enable">
|
||||
<widget class="QCheckBox" name="checkbox_album">
|
||||
<property name="text">
|
||||
<string>Album</string>
|
||||
</property>
|
||||
@ -157,7 +157,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="context_item2_enable">
|
||||
<widget class="QCheckBox" name="checkbox_technical_data">
|
||||
<property name="text">
|
||||
<string>Technical Data</string>
|
||||
</property>
|
||||
@ -167,7 +167,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="context_item3_enable">
|
||||
<widget class="QCheckBox" name="checkbox_engine_device">
|
||||
<property name="text">
|
||||
<string>Engine and Device</string>
|
||||
</property>
|
||||
@ -177,7 +177,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="context_item4_enable">
|
||||
<widget class="QCheckBox" name="checkbox_albums">
|
||||
<property name="text">
|
||||
<string>Albums by Artist</string>
|
||||
</property>
|
||||
@ -187,7 +187,7 @@
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="context_item5_enable">
|
||||
<widget class="QCheckBox" name="checkbox_song_lyrics">
|
||||
<property name="text">
|
||||
<string>Song Lyrics</string>
|
||||
</property>
|
||||
@ -196,6 +196,16 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QCheckBox" name="checkbox_search_lyrics">
|
||||
<property name="text">
|
||||
<string>Automatically search for song lyrics</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
|
Loading…
Reference in New Issue
Block a user