diff --git a/src/globals/ImageDialog.cpp b/src/globals/ImageDialog.cpp index bd98a43ac8..fec4ab5096 100644 --- a/src/globals/ImageDialog.cpp +++ b/src/globals/ImageDialog.cpp @@ -233,17 +233,6 @@ void ImageDialog::reject() QDialog::reject(); } -/** - * @brief Returns an instance of ImageDialog - * @param parent Parent widget (used the first time for constructing) - * @return Instance of ImageDialog - */ -ImageDialog* ImageDialog::instance(QWidget* parent) -{ - static ImageDialog* s_instance = new ImageDialog(parent); - return s_instance; -} - /** * @brief Clears the dialogs contents and cancels outstanding downloads */ @@ -271,7 +260,6 @@ void ImageDialog::clearSearch() */ QUrl ImageDialog::imageUrl() { - qDebug() << "Entered, returning" << m_imageUrl; return m_imageUrl; } diff --git a/src/globals/ImageDialog.h b/src/globals/ImageDialog.h index 12914d4caa..9e6e1632e2 100644 --- a/src/globals/ImageDialog.h +++ b/src/globals/ImageDialog.h @@ -36,7 +36,7 @@ class ImageDialog : public QDialog public: explicit ImageDialog(QWidget* parent = nullptr); ~ImageDialog() override; - static ImageDialog* instance(QWidget* parent = nullptr); + void setDownloads(QVector downloads, bool initial = true); QUrl imageUrl(); QVector imageUrls(); diff --git a/src/ui/concerts/ConcertWidget.cpp b/src/ui/concerts/ConcertWidget.cpp index f628dd4397..aa59904d24 100644 --- a/src/ui/concerts/ConcertWidget.cpp +++ b/src/ui/concerts/ConcertWidget.cpp @@ -591,17 +591,22 @@ void ConcertWidget::onAddExtraFanart() return; } - ImageDialog::instance()->setImageType(ImageType::ConcertExtraFanart); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMultiSelection(true); - ImageDialog::instance()->setConcert(m_concert); - ImageDialog::instance()->setDownloads(m_concert->backdrops()); - ImageDialog::instance()->exec(ImageType::ConcertBackdrop); - - if (ImageDialog::instance()->result() == QDialog::Accepted && !ImageDialog::instance()->imageUrls().isEmpty()) { + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::ConcertExtraFanart); + imageDialog->clear(); + imageDialog->setMultiSelection(true); + imageDialog->setConcert(m_concert); + imageDialog->setDownloads(m_concert->backdrops()); + + imageDialog->exec(ImageType::ConcertBackdrop); + const int exitCode = imageDialog->result(); + const QVector imageUrls = imageDialog->imageUrls(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted && !imageUrls.isEmpty()) { ui->fanarts->setLoading(true); emit setActionSaveEnabled(false, MainWidgets::Concerts); - m_concert->controller()->loadImages(ImageType::ConcertExtraFanart, ImageDialog::instance()->imageUrls()); + m_concert->controller()->loadImages(ImageType::ConcertExtraFanart, imageUrls); onInfoChanged(); } } @@ -628,21 +633,26 @@ void ConcertWidget::onChooseImage() return; } - ImageDialog::instance()->setImageType(image->imageType()); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setConcert(m_concert); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(image->imageType()); + imageDialog->clear(); + imageDialog->setConcert(m_concert); if (image->imageType() == ImageType::ConcertPoster) { - ImageDialog::instance()->setDownloads(m_concert->posters()); + imageDialog->setDownloads(m_concert->posters()); } else if (image->imageType() == ImageType::ConcertBackdrop) { - ImageDialog::instance()->setDownloads(m_concert->backdrops()); + imageDialog->setDownloads(m_concert->backdrops()); } else { - ImageDialog::instance()->setDownloads(QVector()); + imageDialog->setDownloads(QVector()); } - ImageDialog::instance()->exec(image->imageType()); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + imageDialog->exec(image->imageType()); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted) { emit setActionSaveEnabled(false, MainWidgets::Concerts); - m_concert->controller()->loadImage(image->imageType(), ImageDialog::instance()->imageUrl()); + m_concert->controller()->loadImage(image->imageType(), imageUrl); onInfoChanged(); } } diff --git a/src/ui/main/MainWindow.cpp b/src/ui/main/MainWindow.cpp index 9f5670ca14..f3087a180a 100644 --- a/src/ui/main/MainWindow.cpp +++ b/src/ui/main/MainWindow.cpp @@ -94,6 +94,8 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi NotificationBox::instance(this)->reposition(this->size()); Manager::instance(); + TvShowSearch::instance(this); + Notificator::instance(nullptr, ui->centralWidget); if (!m_settings->mainSplitterState().isNull()) { ui->movieSplitter->restoreState(m_settings->mainSplitterState()); @@ -214,10 +216,6 @@ MainWindow::MainWindow(QWidget* parent) : QMainWindow(parent), ui(new Ui::MainWi connect(ui->movieDuplicatesWidget, &MovieDuplicates::sigJumpToMovie, this, &MainWindow::onJumpToMovie); // clang-format on - TvShowSearch::instance(this); - ImageDialog::instance(this); - Notificator::instance(nullptr, ui->centralWidget); - #ifdef Q_OS_WIN setStyleSheet(styleSheet() + " #centralWidget { border-bottom: 1px solid rgba(0, 0, 0, 100); } "); diff --git a/src/ui/movie_sets/SetsWidget.cpp b/src/ui/movie_sets/SetsWidget.cpp index fed6f1586a..eefd6413e1 100644 --- a/src/ui/movie_sets/SetsWidget.cpp +++ b/src/ui/movie_sets/SetsWidget.cpp @@ -363,7 +363,7 @@ void SetsWidget::onRemoveMovie() void SetsWidget::chooseSetPoster() { if (ui->sets->currentRow() < 0 || ui->sets->currentRow() >= ui->sets->rowCount()) { - qDebug() << "Invalid current row in sets"; + qDebug() << "[SetsWidget] Invalid current row in sets"; return; } @@ -374,15 +374,21 @@ void SetsWidget::chooseSetPoster() QString setName = ui->sets->item(ui->sets->currentRow(), 0)->data(Qt::UserRole).toString(); Movie* movie = new Movie(QStringList()); movie->setName(setName); - ImageDialog::instance()->setImageType(ImageType::MovieSetPoster); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMovie(movie); - ImageDialog::instance()->exec(ImageType::MoviePoster); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::MovieSetPoster); + imageDialog->clear(); + imageDialog->setMovie(movie); + imageDialog->exec(ImageType::MoviePoster); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted) { DownloadManagerElement d; d.movie = movie; d.imageType = ImageType::MovieSetPoster; - d.url = ImageDialog::instance()->imageUrl(); + d.url = imageUrl; m_downloadManager->addDownload(d); ui->poster->setPixmap(QPixmap()); ui->poster->setMovie(m_loadingMovie); @@ -407,15 +413,21 @@ void SetsWidget::chooseSetBackdrop() QString setName = ui->sets->item(ui->sets->currentRow(), 0)->data(Qt::UserRole).toString(); Movie* movie = new Movie(QStringList()); movie->setName(setName); - ImageDialog::instance()->setImageType(ImageType::MovieSetBackdrop); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMovie(movie); - ImageDialog::instance()->exec(ImageType::MovieBackdrop); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::MovieSetBackdrop); + imageDialog->clear(); + imageDialog->setMovie(movie); + imageDialog->exec(ImageType::MovieBackdrop); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted) { DownloadManagerElement d; d.movie = movie; d.imageType = ImageType::MovieSetBackdrop; - d.url = ImageDialog::instance()->imageUrl(); + d.url = imageUrl; m_downloadManager->addDownload(d); ui->backdrop->setPixmap(QPixmap()); ui->backdrop->setMovie(m_loadingMovie); diff --git a/src/ui/movies/MovieWidget.cpp b/src/ui/movies/MovieWidget.cpp index 0934c9c4a3..66956103fa 100644 --- a/src/ui/movies/MovieWidget.cpp +++ b/src/ui/movies/MovieWidget.cpp @@ -1545,17 +1545,22 @@ void MovieWidget::onAddExtraFanart() return; } - ImageDialog::instance()->setImageType(ImageType::MovieExtraFanart); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMultiSelection(true); - ImageDialog::instance()->setMovie(m_movie); - ImageDialog::instance()->setDownloads(m_movie->images().backdrops()); - ImageDialog::instance()->exec(ImageType::MovieBackdrop); - - if (ImageDialog::instance()->result() == QDialog::Accepted && !ImageDialog::instance()->imageUrls().isEmpty()) { + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::MovieExtraFanart); + imageDialog->clear(); + imageDialog->setMultiSelection(true); + imageDialog->setMovie(m_movie); + imageDialog->setDownloads(m_movie->images().backdrops()); + + imageDialog->exec(ImageType::MovieBackdrop); + const int exitCode = imageDialog->result(); + const QVector imageUrls = imageDialog->imageUrls(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted && !imageUrls.isEmpty()) { ui->fanarts->setLoading(true); emit setActionSaveEnabled(false, MainWidgets::Movies); - m_movie->controller()->loadImages(ImageType::MovieExtraFanart, ImageDialog::instance()->imageUrls()); + m_movie->controller()->loadImages(ImageType::MovieExtraFanart, imageUrls); ui->buttonRevert->setVisible(true); } } @@ -1592,23 +1597,28 @@ void MovieWidget::onChooseImage() return; } - ImageDialog::instance()->setImageType(image->imageType()); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMovie(m_movie); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(image->imageType()); + imageDialog->clear(); + imageDialog->setMovie(m_movie); if (image->imageType() == ImageType::MoviePoster) { - ImageDialog::instance()->setDownloads(m_movie->images().posters()); + imageDialog->setDownloads(m_movie->images().posters()); } else if (image->imageType() == ImageType::MovieBackdrop) { - ImageDialog::instance()->setDownloads(m_movie->images().backdrops()); + imageDialog->setDownloads(m_movie->images().backdrops()); } else if (image->imageType() == ImageType::MovieCdArt && !m_movie->images().discArts().isEmpty()) { - ImageDialog::instance()->setDownloads(m_movie->images().discArts()); + imageDialog->setDownloads(m_movie->images().discArts()); } else { - ImageDialog::instance()->setDownloads(QVector()); + imageDialog->setDownloads(QVector()); } - ImageDialog::instance()->exec(image->imageType()); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + imageDialog->exec(image->imageType()); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted) { emit setActionSaveEnabled(false, MainWidgets::Movies); - m_movie->controller()->loadImage(image->imageType(), ImageDialog::instance()->imageUrl()); + m_movie->controller()->loadImage(image->imageType(), imageUrl); ui->buttonRevert->setVisible(true); } } diff --git a/src/ui/music/MusicWidgetAlbum.cpp b/src/ui/music/MusicWidgetAlbum.cpp index 20199c0d04..7d8ecb5d7f 100644 --- a/src/ui/music/MusicWidgetAlbum.cpp +++ b/src/ui/music/MusicWidgetAlbum.cpp @@ -426,21 +426,25 @@ void MusicWidgetAlbum::onChooseImage() return; } - ImageDialog::instance()->setImageType(image->imageType()); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setAlbum(m_album); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(image->imageType()); + imageDialog->clear(); + imageDialog->setAlbum(m_album); if (!m_album->images(image->imageType()).isEmpty()) { - ImageDialog::instance()->setDownloads(m_album->images(image->imageType())); + imageDialog->setDownloads(m_album->images(image->imageType())); } else { - ImageDialog::instance()->setDownloads(QVector()); + imageDialog->setDownloads(QVector()); } - ImageDialog::instance()->exec(image->imageType()); + imageDialog->exec(image->imageType()); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + if (exitCode == QDialog::Accepted) { emit sigSetActionSaveEnabled(false, MainWidgets::Music); - m_album->controller()->loadImage(image->imageType(), ImageDialog::instance()->imageUrl()); + m_album->controller()->loadImage(image->imageType(), imageUrl); ui->buttonRevert->setVisible(true); } } @@ -562,19 +566,24 @@ void MusicWidgetAlbum::onAddBooklet() return; } - ImageDialog::instance()->setImageType(ImageType::AlbumBooklet); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMultiSelection(true); - ImageDialog::instance()->setAlbum(m_album); - ImageDialog::instance()->setDownloads(QVector()); - ImageDialog::instance()->exec(ImageType::AlbumBooklet); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::AlbumBooklet); + imageDialog->clear(); + imageDialog->setMultiSelection(true); + imageDialog->setAlbum(m_album); + imageDialog->setDownloads(QVector()); - if (ImageDialog::instance()->result() == QDialog::Accepted && !ImageDialog::instance()->imageUrls().isEmpty()) { + imageDialog->exec(ImageType::AlbumBooklet); + const int exitCode = imageDialog->result(); + const QVector imageUrls = imageDialog->imageUrls(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted && !imageUrls.isEmpty()) { if (m_bookletWidget != nullptr) { m_bookletWidget->setLoading(true); } emit sigSetActionSaveEnabled(false, MainWidgets::Music); - m_album->controller()->loadImages(ImageType::AlbumBooklet, ImageDialog::instance()->imageUrls()); + m_album->controller()->loadImages(ImageType::AlbumBooklet, imageUrls); ui->buttonRevert->setVisible(true); } } diff --git a/src/ui/music/MusicWidgetArtist.cpp b/src/ui/music/MusicWidgetArtist.cpp index 362e94ddd5..f8797fbc69 100644 --- a/src/ui/music/MusicWidgetArtist.cpp +++ b/src/ui/music/MusicWidgetArtist.cpp @@ -396,21 +396,25 @@ void MusicWidgetArtist::onChooseImage() return; } - ImageDialog::instance()->setImageType(image->imageType()); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setArtist(m_artist); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(image->imageType()); + imageDialog->clear(); + imageDialog->setArtist(m_artist); if (!m_artist->images(image->imageType()).isEmpty()) { - ImageDialog::instance()->setDownloads(m_artist->images(image->imageType())); + imageDialog->setDownloads(m_artist->images(image->imageType())); } else { - ImageDialog::instance()->setDownloads(QVector()); + imageDialog->setDownloads(QVector()); } - ImageDialog::instance()->exec(image->imageType()); + imageDialog->exec(image->imageType()); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + if (exitCode == QDialog::Accepted) { emit sigSetActionSaveEnabled(false, MainWidgets::Music); - m_artist->controller()->loadImage(image->imageType(), ImageDialog::instance()->imageUrl()); + m_artist->controller()->loadImage(image->imageType(), imageUrl); ui->buttonRevert->setVisible(true); } } @@ -540,17 +544,22 @@ void MusicWidgetArtist::onAddExtraFanart() return; } - ImageDialog::instance()->setImageType(ImageType::ArtistExtraFanart); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMultiSelection(true); - ImageDialog::instance()->setArtist(m_artist); - ImageDialog::instance()->setDownloads(m_artist->images(ImageType::ArtistFanart)); - ImageDialog::instance()->exec(ImageType::ArtistFanart); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::ArtistExtraFanart); + imageDialog->clear(); + imageDialog->setMultiSelection(true); + imageDialog->setArtist(m_artist); + imageDialog->setDownloads(m_artist->images(ImageType::ArtistFanart)); - if (ImageDialog::instance()->result() == QDialog::Accepted && !ImageDialog::instance()->imageUrls().isEmpty()) { + imageDialog->exec(ImageType::ArtistFanart); + const int exitCode = imageDialog->result(); + const QVector imageUrls = imageDialog->imageUrls(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted && !imageUrls.isEmpty()) { ui->fanarts->setLoading(true); emit sigSetActionSaveEnabled(false, MainWidgets::Music); - m_artist->controller()->loadImages(ImageType::ArtistExtraFanart, ImageDialog::instance()->imageUrls()); + m_artist->controller()->loadImages(ImageType::ArtistExtraFanart, imageUrls); ui->buttonRevert->setVisible(true); } } diff --git a/src/ui/tv_show/TvShowWidgetEpisode.cpp b/src/ui/tv_show/TvShowWidgetEpisode.cpp index c58185b52b..819c3f1270 100644 --- a/src/ui/tv_show/TvShowWidgetEpisode.cpp +++ b/src/ui/tv_show/TvShowWidgetEpisode.cpp @@ -684,9 +684,10 @@ void TvShowWidgetEpisode::onChooseThumbnail() return; } - ImageDialog::instance()->setImageType(ImageType::TvShowEpisodeThumb); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setTvShowEpisode(m_episode); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::TvShowEpisodeThumb); + imageDialog->clear(); + imageDialog->setTvShowEpisode(m_episode); QVector posters; if (!m_episode->thumbnail().isEmpty()) { Poster p; @@ -694,14 +695,18 @@ void TvShowWidgetEpisode::onChooseThumbnail() p.thumbUrl = m_episode->thumbnail(); posters << p; } - ImageDialog::instance()->setDownloads(posters); - ImageDialog::instance()->exec(ImageType::TvShowEpisodeThumb); + imageDialog->setDownloads(posters); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + imageDialog->exec(ImageType::TvShowEpisodeThumb); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted) { emit sigSetActionSaveEnabled(false, MainWidgets::TvShows); DownloadManagerElement d; d.imageType = ImageType::TvShowEpisodeThumb; - d.url = ImageDialog::instance()->imageUrl(); + d.url = imageUrl; d.episode = m_episode; d.directDownload = true; m_posterDownloadManager->addDownload(d); diff --git a/src/ui/tv_show/TvShowWidgetSeason.cpp b/src/ui/tv_show/TvShowWidgetSeason.cpp index b0693a4f10..fff5ab4643 100644 --- a/src/ui/tv_show/TvShowWidgetSeason.cpp +++ b/src/ui/tv_show/TvShowWidgetSeason.cpp @@ -221,10 +221,11 @@ void TvShowWidgetSeason::onChooseImage() return; } - ImageDialog::instance()->setImageType(image->imageType()); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setTvShow(m_show); - ImageDialog::instance()->setSeason(m_season); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(image->imageType()); + imageDialog->clear(); + imageDialog->setTvShow(m_show); + imageDialog->setSeason(m_season); if (image->imageType() == ImageType::TvShowSeasonPoster) { // Merge with TV show posters. This is useful if there are @@ -232,28 +233,31 @@ void TvShowWidgetSeason::onChooseImage() QVector posters; posters << m_show->seasonPosters(m_season); posters << m_show->posters(); - ImageDialog::instance()->setDownloads(posters); + imageDialog->setDownloads(posters); } else if (image->imageType() == ImageType::TvShowSeasonBackdrop) { - ImageDialog::instance()->setDownloads(m_show->seasonBackdrops(m_season)); + imageDialog->setDownloads(m_show->seasonBackdrops(m_season)); } else if (image->imageType() == ImageType::TvShowSeasonBanner) { QVector banners; banners << m_show->seasonBanners(m_season, true); banners << m_show->banners(); - ImageDialog::instance()->setDownloads(banners); + imageDialog->setDownloads(banners); } else { - ImageDialog::instance()->setDownloads(QVector()); + imageDialog->setDownloads(QVector()); } - ImageDialog::instance()->exec(image->imageType()); + imageDialog->exec(image->imageType()); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + if (exitCode == QDialog::Accepted) { emit sigSetActionSaveEnabled(false, MainWidgets::TvShows); DownloadManagerElement d; d.imageType = image->imageType(); - d.url = ImageDialog::instance()->imageUrl(); + d.url = imageUrl; d.season = m_season; d.show = m_show; m_downloadManager->addDownload(d); diff --git a/src/ui/tv_show/TvShowWidgetTvShow.cpp b/src/ui/tv_show/TvShowWidgetTvShow.cpp index 6acae8d608..2644b83292 100644 --- a/src/ui/tv_show/TvShowWidgetTvShow.cpp +++ b/src/ui/tv_show/TvShowWidgetTvShow.cpp @@ -1100,17 +1100,22 @@ void TvShowWidgetTvShow::onAddExtraFanart() return; } - ImageDialog::instance()->setImageType(ImageType::TvShowExtraFanart); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setMultiSelection(true); - ImageDialog::instance()->setTvShow(m_show); - ImageDialog::instance()->setDownloads(m_show->backdrops()); - ImageDialog::instance()->exec(ImageType::TvShowExtraFanart); - - if (ImageDialog::instance()->result() == QDialog::Accepted && !ImageDialog::instance()->imageUrls().isEmpty()) { + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(ImageType::TvShowExtraFanart); + imageDialog->clear(); + imageDialog->setMultiSelection(true); + imageDialog->setTvShow(m_show); + imageDialog->setDownloads(m_show->backdrops()); + + imageDialog->exec(ImageType::TvShowExtraFanart); + const int exitCode = imageDialog->result(); + const QVector imageUrls = imageDialog->imageUrls(); + imageDialog->deleteLater(); + + if (exitCode == QDialog::Accepted && !imageUrls.isEmpty()) { ui->fanarts->setLoading(true); emit sigSetActionSaveEnabled(false, MainWidgets::TvShows); - for (const QUrl& url : ImageDialog::instance()->imageUrls()) { + for (const QUrl& url : imageUrls) { DownloadManagerElement d; d.imageType = ImageType::TvShowExtraFanart; d.url = url; @@ -1161,23 +1166,27 @@ void TvShowWidgetTvShow::onChooseImage() return; } - ImageDialog::instance()->setImageType(image->imageType()); - ImageDialog::instance()->clear(); - ImageDialog::instance()->setTvShow(m_show); + auto* imageDialog = new ImageDialog(this); + imageDialog->setImageType(image->imageType()); + imageDialog->clear(); + imageDialog->setTvShow(m_show); switch (image->imageType()) { - case ImageType::TvShowPoster: ImageDialog::instance()->setDownloads(m_show->posters()); break; - case ImageType::TvShowBackdrop: ImageDialog::instance()->setDownloads(m_show->backdrops()); break; - case ImageType::TvShowBanner: ImageDialog::instance()->setDownloads(m_show->banners()); break; - default: ImageDialog::instance()->setDownloads(QVector()); break; + case ImageType::TvShowPoster: imageDialog->setDownloads(m_show->posters()); break; + case ImageType::TvShowBackdrop: imageDialog->setDownloads(m_show->backdrops()); break; + case ImageType::TvShowBanner: imageDialog->setDownloads(m_show->banners()); break; + default: imageDialog->setDownloads(QVector()); break; } - ImageDialog::instance()->exec(image->imageType()); + imageDialog->exec(image->imageType()); + const int exitCode = imageDialog->result(); + const QUrl imageUrl = imageDialog->imageUrl(); + imageDialog->deleteLater(); - if (ImageDialog::instance()->result() == QDialog::Accepted) { + if (exitCode == QDialog::Accepted) { emit sigSetActionSaveEnabled(false, MainWidgets::TvShows); DownloadManagerElement d; d.imageType = image->imageType(); - d.url = ImageDialog::instance()->imageUrl(); + d.url = imageUrl; d.show = m_show; m_posterDownloadManager->addDownload(d); image->setLoading(true);