Center cover manager on same screen as mainwindow

This commit is contained in:
Jonas Kvinge
2020-04-06 22:30:03 +02:00
parent 8321a48af7
commit 7f39a38d6c
3 changed files with 111 additions and 56 deletions

View File

@@ -40,7 +40,6 @@
class QWidget;
class QMimeData;
class QNetworkAccessManager;
class QMenu;
class QAction;
class QProgressBar;
@@ -63,7 +62,7 @@ class Ui_CoverManager;
class AlbumCoverManager : public QMainWindow {
Q_OBJECT
public:
AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QWidget *parent = nullptr, QNetworkAccessManager *network = 0);
explicit AlbumCoverManager(Application *app, CollectionBackend *collection_backend, QMainWindow *mainwindow, QWidget *parent = nullptr);
~AlbumCoverManager();
static const char *kSettingsGroup;
@@ -82,16 +81,55 @@ class AlbumCoverManager : public QMainWindow {
SongList GetSongsInAlbums(const QModelIndexList &indexes) const;
SongMimeData *GetMimeDataForAlbums(const QModelIndexList &indexes) const;
signals:
void AddToPlaylist(QMimeData *data);
protected:
void showEvent(QShowEvent *);
void closeEvent(QCloseEvent *);
void showEvent(QShowEvent*);
void closeEvent(QCloseEvent*);
// For the album view context menu events
bool eventFilter(QObject *obj, QEvent *event);
private:
enum ArtistItemType {
All_Artists,
Various_Artists,
Specific_Artist
};
enum Role {
Role_ArtistName = Qt::UserRole + 1,
Role_AlbumArtistName,
Role_AlbumName,
Role_PathAutomatic,
Role_PathManual,
Role_FirstUrl
};
enum HideCovers {
Hide_None,
Hide_WithCovers,
Hide_WithoutCovers
};
void LoadGeometry();
void SaveGeometry();
QString InitialPathForOpenCoverDialog(const QString &path_automatic, const QString &first_file_name) const;
QString EffectiveAlbumArtistName(const QListWidgetItem &item) const;
// Returns the selected element in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing or multiple elements selected.
Song GetSingleSelectionAsSong();
// Returns the first of the selected elements in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing selected.
Song GetFirstSelectedAsSong();
Song ItemAsSong(QListWidgetItem *item);
void UpdateStatusText();
bool ShouldHide(const QListWidgetItem &item, const QString &filter, HideCovers hide) const;
void SaveAndSetCover(QListWidgetItem *item, const QUrl &cover_url, const QImage &image);
signals:
void AddToPlaylist(QMimeData *data);
private slots:
void ArtistChanged(QListWidgetItem *current);
void CoverImageLoaded(const quint64 id, const QUrl &cover_url, const QImage &image);
@@ -119,44 +157,9 @@ class AlbumCoverManager : public QMainWindow {
void UpdateCoverInList(QListWidgetItem *item, const QUrl &cover);
void UpdateExportStatus(int exported, int bad, int count);
private:
enum ArtistItemType {
All_Artists,
Various_Artists,
Specific_Artist
};
enum Role {
Role_ArtistName = Qt::UserRole + 1,
Role_AlbumArtistName,
Role_AlbumName,
Role_PathAutomatic,
Role_PathManual,
Role_FirstUrl
};
enum HideCovers {
Hide_None,
Hide_WithCovers,
Hide_WithoutCovers
};
QString InitialPathForOpenCoverDialog(const QString &path_automatic, const QString &first_file_name) const;
QString EffectiveAlbumArtistName(const QListWidgetItem &item) const;
// Returns the selected element in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing or multiple elements selected.
Song GetSingleSelectionAsSong();
// Returns the first of the selected elements in form of a Song ready to be used by AlbumCoverChoiceController or invalid song if there's nothing selected.
Song GetFirstSelectedAsSong();
Song ItemAsSong(QListWidgetItem *item);
void UpdateStatusText();
bool ShouldHide(const QListWidgetItem &item, const QString &filter, HideCovers hide) const;
void SaveAndSetCover(QListWidgetItem *item, const QUrl &cover_url, const QImage &image);
private:
Ui_CoverManager *ui_;
QMainWindow *mainwindow_;
Application *app_;
AlbumCoverChoiceController *album_cover_choice_controller_;