diff --git a/src/songinfo/artistinfoview.cpp b/src/songinfo/artistinfoview.cpp index c4987eb67..6c13bea14 100644 --- a/src/songinfo/artistinfoview.cpp +++ b/src/songinfo/artistinfoview.cpp @@ -55,7 +55,7 @@ void ArtistInfoView::ResultReady(int id, const SongInfoFetcher::Result& result) if (!result.images_.isEmpty()) { // Image view goes at the top - PrettyImageView* image_view = new PrettyImageView(this); + PrettyImageView* image_view = new PrettyImageView(network_, this); AddWidget(image_view); foreach (const QUrl& url, result.images_) { diff --git a/src/songinfo/songinfobase.cpp b/src/songinfo/songinfobase.cpp index f938e1fed..88352a959 100644 --- a/src/songinfo/songinfobase.cpp +++ b/src/songinfo/songinfobase.cpp @@ -16,6 +16,7 @@ */ #include "songinfobase.h" +#include "core/network.h" #include #include @@ -28,6 +29,7 @@ const char* SongInfoBase::kSettingsGroup = "SongInfo"; SongInfoBase::SongInfoBase(QWidget* parent) : QWidget(parent), + network_(new NetworkAccessManager(this)), fetcher_(new SongInfoFetcher(this)), current_request_id_(-1), scroll_area_(new QScrollArea), diff --git a/src/songinfo/songinfobase.h b/src/songinfo/songinfobase.h index 8de902ef2..2063058f6 100644 --- a/src/songinfo/songinfobase.h +++ b/src/songinfo/songinfobase.h @@ -30,6 +30,7 @@ class CollapsibleInfoPane; class WidgetFadeHelper; +class QNetworkAccessManager; class QScrollArea; class QVBoxLayout; @@ -66,6 +67,7 @@ protected slots: virtual void ResultReady(int id, const SongInfoFetcher::Result& result); protected: + QNetworkAccessManager* network_; SongInfoFetcher* fetcher_; int current_request_id_; diff --git a/src/widgets/prettyimage.cpp b/src/widgets/prettyimage.cpp index b74fdf695..56c938076 100644 --- a/src/widgets/prettyimage.cpp +++ b/src/widgets/prettyimage.cpp @@ -16,7 +16,6 @@ */ #include "prettyimage.h" -#include "core/network.h" #include "ui/iconloader.h" #include @@ -28,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -43,9 +43,10 @@ const int PrettyImage::kMaxImageWidth = 300; const char* PrettyImage::kSettingsGroup = "PrettyImageView"; -PrettyImage::PrettyImage(const QUrl& url, QWidget* parent) +PrettyImage::PrettyImage(const QUrl& url, QNetworkAccessManager* network, + QWidget* parent) : QWidget(parent), - network_(new NetworkAccessManager(this)), + network_(network), state_(State_WaitingForLazyLoad), url_(url), menu_(NULL) diff --git a/src/widgets/prettyimage.h b/src/widgets/prettyimage.h index da6e60b91..77118f301 100644 --- a/src/widgets/prettyimage.h +++ b/src/widgets/prettyimage.h @@ -21,16 +21,16 @@ #include #include -class NetworkAccessManager; - class QMenu; +class QNetworkAccessManager; class QNetworkReply; class PrettyImage : public QWidget { Q_OBJECT public: - PrettyImage(const QUrl& url, QWidget* parent = 0); + PrettyImage(const QUrl& url, QNetworkAccessManager* network, + QWidget* parent = 0); static const int kTotalHeight; static const int kReflectionHeight; @@ -70,7 +70,7 @@ private: void DrawThumbnail(QPainter* p, const QRect& rect); private: - NetworkAccessManager* network_; + QNetworkAccessManager* network_; State state_; QUrl url_; diff --git a/src/widgets/prettyimageview.cpp b/src/widgets/prettyimageview.cpp index b9f2b6d01..d6b05ef37 100644 --- a/src/widgets/prettyimageview.cpp +++ b/src/widgets/prettyimageview.cpp @@ -25,8 +25,9 @@ #include #include -PrettyImageView::PrettyImageView(QWidget* parent) +PrettyImageView::PrettyImageView(QNetworkAccessManager* network, QWidget* parent) : QScrollArea(parent), + network_(network), container_(new QWidget(this)), layout_(new QHBoxLayout(container_)), current_index_(-1), @@ -66,7 +67,7 @@ bool PrettyImageView::eventFilter(QObject* obj, QEvent* event) { } void PrettyImageView::AddImage(const QUrl& url) { - PrettyImage* image = new PrettyImage(url, container_); + PrettyImage* image = new PrettyImage(url, network_, container_); connect(image, SIGNAL(destroyed()), SLOT(ScrollToCurrent())); connect(image, SIGNAL(Loaded()), SLOT(ScrollToCurrent())); diff --git a/src/widgets/prettyimageview.h b/src/widgets/prettyimageview.h index eb00f36e4..df2c16fb3 100644 --- a/src/widgets/prettyimageview.h +++ b/src/widgets/prettyimageview.h @@ -24,6 +24,7 @@ class QHBoxLayout; class QMenu; +class QNetworkAccessManager; class QNetworkReply; class QPropertyAnimation; class QTimeLine; @@ -32,7 +33,7 @@ class PrettyImageView : public QScrollArea { Q_OBJECT public: - PrettyImageView(QWidget* parent = 0); + PrettyImageView(QNetworkAccessManager* network, QWidget* parent = 0); static const char* kSettingsGroup; @@ -52,6 +53,8 @@ private slots: private: bool eventFilter(QObject*, QEvent*); + QNetworkAccessManager* network_; + QWidget* container_; QHBoxLayout* layout_;