final refactoring stage of cover changing code (common QAction*s)
reset URL in 'Cover from URL' dialog on reentrance
This commit is contained in:
parent
ebfbdba8a9
commit
4a9d38bbdd
@ -53,6 +53,15 @@ AlbumCoverChoiceController::~AlbumCoverChoiceController()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QList<QAction*> AlbumCoverChoiceController::PrepareAlbumChoiceMenu(QObject* parent) {
|
||||||
|
return QList<QAction*>()
|
||||||
|
<< new QAction(IconLoader::Load("document-open"), tr("Load cover from disk..."), parent)
|
||||||
|
<< new QAction(IconLoader::Load("download"), tr("Load cover from URL..."), parent)
|
||||||
|
<< new QAction(IconLoader::Load("find"), tr("Search for album covers..."), parent)
|
||||||
|
<< new QAction(IconLoader::Load("list-remove"), tr("Unset cover"), parent)
|
||||||
|
<< new QAction(IconLoader::Load("zoom-in"), tr("Show fullsize..."), parent);
|
||||||
|
}
|
||||||
|
|
||||||
QString AlbumCoverChoiceController::LoadCoverFromFile(Song* song) {
|
QString AlbumCoverChoiceController::LoadCoverFromFile(Song* song) {
|
||||||
QString dir;
|
QString dir;
|
||||||
|
|
||||||
|
@ -18,6 +18,8 @@
|
|||||||
#ifndef ALBUMCOVERCHOICECONTROLLER_H
|
#ifndef ALBUMCOVERCHOICECONTROLLER_H
|
||||||
#define ALBUMCOVERCHOICECONTROLLER_H
|
#define ALBUMCOVERCHOICECONTROLLER_H
|
||||||
|
|
||||||
|
#include <QAction>
|
||||||
|
#include <QList>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
|
||||||
class AlbumCoverFetcher;
|
class AlbumCoverFetcher;
|
||||||
@ -26,12 +28,7 @@ class CoverFromURLDialog;
|
|||||||
class LibraryBackend;
|
class LibraryBackend;
|
||||||
class Song;
|
class Song;
|
||||||
|
|
||||||
// Controller for the common album cover related menu options. This includes:
|
// Controller for the common album cover related menu options.
|
||||||
// - loading cover from file
|
|
||||||
// - loading cover from URL
|
|
||||||
// - searching for cover using last.fm
|
|
||||||
// - unsetting the cover manually
|
|
||||||
// - showing the cover in original size
|
|
||||||
class AlbumCoverChoiceController : public QWidget {
|
class AlbumCoverChoiceController : public QWidget {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -42,6 +39,15 @@ class AlbumCoverChoiceController : public QWidget {
|
|||||||
static const char* kImageFileFilter;
|
static const char* kImageFileFilter;
|
||||||
static const char* kAllFilesFilter;
|
static const char* kAllFilesFilter;
|
||||||
|
|
||||||
|
// Returns QAction* for every operation implemented by this controller.
|
||||||
|
// The list contains QAction* for:
|
||||||
|
// 1. loading cover from file
|
||||||
|
// 2. loading cover from URL
|
||||||
|
// 3. searching for cover using last.fm
|
||||||
|
// 4. unsetting the cover manually
|
||||||
|
// 5. showing the cover in original size
|
||||||
|
QList<QAction*> PrepareAlbumChoiceMenu(QObject* parent);
|
||||||
|
|
||||||
// All of the methods below require a currently selected song as an
|
// All of the methods below require a currently selected song as an
|
||||||
// input parameter. Also - LoadCoverFromFile, LoadCoverFromURL,
|
// input parameter. Also - LoadCoverFromFile, LoadCoverFromURL,
|
||||||
// SearchForCover, UnsetCover and SaveCover all update manual path
|
// SearchForCover, UnsetCover and SaveCover all update manual path
|
||||||
|
@ -121,25 +121,26 @@ void AlbumCoverManager::Init() {
|
|||||||
ui_->view->setMenu(view_menu);
|
ui_->view->setMenu(view_menu);
|
||||||
|
|
||||||
// Context menu
|
// Context menu
|
||||||
cover_from_file_ = context_menu_->addAction(
|
|
||||||
IconLoader::Load("document-open"), tr("Load cover from disk..."),
|
|
||||||
this, SLOT(LoadCoverFromFile()));
|
|
||||||
cover_from_url_ = context_menu_->addAction(
|
|
||||||
IconLoader::Load("download"), tr("Load cover from URL..."),
|
|
||||||
this, SLOT(LoadCoverFromURL()));
|
|
||||||
search_for_cover_ = context_menu_->addAction(
|
|
||||||
IconLoader::Load("find"), tr("Search for album covers..."),
|
|
||||||
this, SLOT(SearchForCover()));
|
|
||||||
unset_cover_ = context_menu_->addAction(
|
|
||||||
IconLoader::Load("list-remove"), tr("Unset cover"),
|
|
||||||
this, SLOT(UnsetCover()));
|
|
||||||
show_cover_ = context_menu_->addAction(
|
|
||||||
IconLoader::Load("zoom-in"), tr("Show fullsize..."),
|
|
||||||
this, SLOT(ShowCover()));
|
|
||||||
|
|
||||||
|
QList<QAction*> actions = album_cover_choice_controller_->PrepareAlbumChoiceMenu(this);
|
||||||
|
|
||||||
|
cover_from_file_ = actions[0];
|
||||||
|
cover_from_url_ = actions[1];
|
||||||
|
search_for_cover_ = actions[2];
|
||||||
|
unset_cover_ = actions[3];
|
||||||
|
show_cover_ = actions[4];
|
||||||
|
|
||||||
|
connect(cover_from_file_, SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
|
||||||
|
connect(cover_from_url_, SIGNAL(triggered()), this, SLOT(LoadCoverFromURL()));
|
||||||
|
connect(search_for_cover_, SIGNAL(triggered()), this, SLOT(SearchForCover()));
|
||||||
|
connect(unset_cover_, SIGNAL(triggered()), this, SLOT(UnsetCover()));
|
||||||
|
connect(show_cover_, SIGNAL(triggered()), this, SLOT(ShowCover()));
|
||||||
|
|
||||||
|
context_menu_->addActions(actions);
|
||||||
context_menu_->addSeparator();
|
context_menu_->addSeparator();
|
||||||
context_menu_->addAction(ui_->action_load);
|
context_menu_->addAction(ui_->action_load);
|
||||||
context_menu_->addAction(ui_->action_add_to_playlist);
|
context_menu_->addAction(ui_->action_add_to_playlist);
|
||||||
|
|
||||||
ui_->albums->installEventFilter(this);
|
ui_->albums->installEventFilter(this);
|
||||||
|
|
||||||
// Connections
|
// Connections
|
||||||
|
@ -39,7 +39,10 @@ CoverFromURLDialog::~CoverFromURLDialog() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QImage CoverFromURLDialog::Exec() {
|
QImage CoverFromURLDialog::Exec() {
|
||||||
|
// reset state
|
||||||
|
ui_->url->setText("");;
|
||||||
last_image_ = QImage();
|
last_image_ = QImage();
|
||||||
|
|
||||||
exec();
|
exec();
|
||||||
return last_image_;
|
return last_image_;
|
||||||
}
|
}
|
||||||
|
@ -132,21 +132,23 @@ EditTagDialog::EditTagDialog(QWidget* parent)
|
|||||||
|
|
||||||
// Set up the album cover menu
|
// Set up the album cover menu
|
||||||
cover_menu_ = new QMenu(this);
|
cover_menu_ = new QMenu(this);
|
||||||
cover_from_file_ = cover_menu_->addAction(
|
|
||||||
IconLoader::Load("document-open"), tr("Load cover from disk..."),
|
QList<QAction*> actions = album_cover_choice_controller_->PrepareAlbumChoiceMenu(this);
|
||||||
this, SLOT(LoadCoverFromFile()));
|
|
||||||
cover_from_url_ = cover_menu_->addAction(
|
cover_from_file_ = actions[0];
|
||||||
IconLoader::Load("download"), tr("Load cover from URL..."),
|
cover_from_url_ = actions[1];
|
||||||
this, SLOT(LoadCoverFromURL()));
|
search_for_cover_ = actions[2];
|
||||||
search_for_cover_ = cover_menu_->addAction(
|
unset_cover_ = actions[3];
|
||||||
IconLoader::Load("find"), tr("Search for album covers..."),
|
show_cover_ = actions[4];
|
||||||
this, SLOT(SearchForCover()));
|
|
||||||
unset_cover_ = cover_menu_->addAction(
|
connect(cover_from_file_, SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
|
||||||
IconLoader::Load("list-remove"), tr("Unset cover"),
|
connect(cover_from_url_, SIGNAL(triggered()), this, SLOT(LoadCoverFromURL()));
|
||||||
this, SLOT(UnsetCover()));
|
connect(search_for_cover_, SIGNAL(triggered()), this, SLOT(SearchForCover()));
|
||||||
show_cover_ = cover_menu_->addAction(
|
connect(unset_cover_, SIGNAL(triggered()), this, SLOT(UnsetCover()));
|
||||||
IconLoader::Load("zoom-in"), tr("Show fullsize..."),
|
connect(show_cover_, SIGNAL(triggered()), this, SLOT(ShowCover()));
|
||||||
this, SLOT(ShowCover()));
|
|
||||||
|
cover_menu_->addActions(actions);
|
||||||
|
|
||||||
ui_->summary_art_button->setMenu(cover_menu_);
|
ui_->summary_art_button->setMenu(cover_menu_);
|
||||||
|
|
||||||
ui_->art->installEventFilter(this);
|
ui_->art->installEventFilter(this);
|
||||||
|
@ -93,24 +93,24 @@ NowPlayingWidget::NowPlayingWidget(QWidget *parent)
|
|||||||
menu_->addActions(mode_group->actions());
|
menu_->addActions(mode_group->actions());
|
||||||
menu_->addSeparator();
|
menu_->addSeparator();
|
||||||
|
|
||||||
cover_from_file_ = menu_->addAction(
|
QList<QAction*> actions = album_cover_choice_controller_->PrepareAlbumChoiceMenu(this);
|
||||||
IconLoader::Load("document-open"), tr("Load cover from disk..."),
|
|
||||||
this, SLOT(LoadCoverFromFile()));
|
|
||||||
cover_from_url_ = menu_->addAction(
|
|
||||||
IconLoader::Load("download"), tr("Load cover from URL..."),
|
|
||||||
this, SLOT(LoadCoverFromURL()));
|
|
||||||
search_for_cover_ = menu_->addAction(
|
|
||||||
IconLoader::Load("find"), tr("Search for album covers..."),
|
|
||||||
this, SLOT(SearchForCover()));
|
|
||||||
unset_cover_ = menu_->addAction(
|
|
||||||
IconLoader::Load("list-remove"), tr("Unset cover"),
|
|
||||||
this, SLOT(UnsetCover()));
|
|
||||||
show_cover_ = menu_->addAction(
|
|
||||||
IconLoader::Load("zoom-in"), tr("Show fullsize..."),
|
|
||||||
this, SLOT(ShowCover()));
|
|
||||||
|
|
||||||
|
cover_from_file_ = actions[0];
|
||||||
|
cover_from_url_ = actions[1];
|
||||||
|
search_for_cover_ = actions[2];
|
||||||
|
unset_cover_ = actions[3];
|
||||||
|
show_cover_ = actions[4];
|
||||||
|
|
||||||
|
connect(cover_from_file_, SIGNAL(triggered()), this, SLOT(LoadCoverFromFile()));
|
||||||
|
connect(cover_from_url_, SIGNAL(triggered()), this, SLOT(LoadCoverFromURL()));
|
||||||
|
connect(search_for_cover_, SIGNAL(triggered()), this, SLOT(SearchForCover()));
|
||||||
|
connect(unset_cover_, SIGNAL(triggered()), this, SLOT(UnsetCover()));
|
||||||
|
connect(show_cover_, SIGNAL(triggered()), this, SLOT(ShowCover()));
|
||||||
|
|
||||||
|
menu_->addActions(actions);
|
||||||
menu_->addSeparator();
|
menu_->addSeparator();
|
||||||
above_statusbar_action_ = menu_->addAction(tr("Show above status bar"));
|
above_statusbar_action_ = menu_->addAction(tr("Show above status bar"));
|
||||||
|
|
||||||
above_statusbar_action_->setCheckable(true);
|
above_statusbar_action_->setCheckable(true);
|
||||||
connect(above_statusbar_action_, SIGNAL(toggled(bool)), SLOT(ShowAboveStatusBar(bool)));
|
connect(above_statusbar_action_, SIGNAL(toggled(bool)), SLOT(ShowAboveStatusBar(bool)));
|
||||||
above_statusbar_action_->setChecked(s.value("above_status_bar", false).toBool());
|
above_statusbar_action_->setChecked(s.value("above_status_bar", false).toBool());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user