From a28d2587f544f3b99f07810b185aa95cc6e1a54e Mon Sep 17 00:00:00 2001 From: Herwig Birke Date: Mon, 13 Nov 2017 14:01:49 +0100 Subject: [PATCH] . --- cedit.cpp | 13 ++ cedit.ui | 477 ++++++++++++++++++++++++----------------------- cfanartimage.cpp | 66 +++++++ cfanartimage.h | 17 ++ cserie.cpp | 11 ++ cserie.h | 2 + qtMovies.pro | 6 +- 7 files changed, 354 insertions(+), 238 deletions(-) create mode 100644 cfanartimage.cpp create mode 100644 cfanartimage.h diff --git a/cedit.cpp b/cedit.cpp index 1e50f66..7b1bac8 100644 --- a/cedit.cpp +++ b/cedit.cpp @@ -2,6 +2,8 @@ #include "ui_cedit.h" #include "cmovieimage.h" +#include "cfanartimage.h" + #include "cseasondetails.h" #include "cmessageanimatedialog.h" @@ -96,6 +98,17 @@ void cEdit::setSerie(cSerie* lpSerie) ui->m_lpCliffhanger->setChecked(lpSerie->cliffhanger()); ui->m_lpDownloadLink->setText(lpSerie->download()); + QString szBanner = lpSerie->fanartBanner(); + { + if(!szBanner.isEmpty()) + { + cFanartImage banner; + QPixmap pixmap = banner.getImage(szBanner); + if(!pixmap.isNull()) + ui->m_lpBanner->setPixmap(pixmap); + } + } + int x; QList seasonList = lpSerie->seasonList(); for(x = 0;x < seasonList.count();x++) diff --git a/cedit.ui b/cedit.ui index f9f73df..0fe7c37 100644 --- a/cedit.ui +++ b/cedit.ui @@ -13,258 +13,263 @@ Edit - - - - - - - 1 - - - - Progress - - - - - - - - - - - - true - - - - - - - Year: - - - - - - - - - - Cliffhanger - - - - - - - - - - - Download Link: - - - - - - - - - - - - - - all Init - - - - - - - all Progress - - - - - - - all Done - - - - - - - - - true - - - - - 0 - 0 - 1123 - 546 - - - + + + + + + 0 + + + + Progress + + + + + + + + + + + + + + + + + + true - - - - - - - - - - - - Details - - - - - - - - - - Actors - - - - - - - 2 - - - false - - + + + - 1 + Year: - - + + + + + + + - 2 + Cliffhanger - - - - - - - - - - 16777215 - 16777215 - - - - true - - - - - - - - - Genre - - - - - - - false - - + + + + + + + + - 1 + Download Link: - + + + + + + + + + + + + + all Init + + + + + + + all Progress + + + + + + + all Done + + + + + + + + + true + + + + + 0 + 0 + 581 + 334 + + + + true + + - - - - - - - - - - 0 - 0 - - - - QFrame::Box - + + + + + + + + + + + Details + + + + + + + + + + Actors + + + + + + + 2 + + + false + + - + 1 - - Qt::AlignCenter + + + + 2 - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - 0 - - - - Tab 1 - + + + + + + + + + + 16777215 + 16777215 + + + + true + + + + + + + + Genre + + + + + + + false + + + + 1 + + + + + + + + + + + + + 0 + 0 + + + + QFrame::Box + + + + + + Qt::AlignCenter + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + 0 + + + + Tab 1 + - - - + + + - - - - - Qt::Horizontal - - - QDialogButtonBox::Cancel|QDialogButtonBox::Ok - - - - - - + + + + + + Qt::Horizontal + + + QDialogButtonBox::Cancel|QDialogButtonBox::Ok + + + + + diff --git a/cfanartimage.cpp b/cfanartimage.cpp new file mode 100644 index 0000000..04ad36e --- /dev/null +++ b/cfanartimage.cpp @@ -0,0 +1,66 @@ +#include "common.h" + +#include "cfanartimage.h" + +#include +#include +#include +#include +#include +#include +#include + + +cFanartImage::cFanartImage() +{ +} + +QPixmap cFanartImage::getImage(const QString& szFileName) +{ + QPixmap pixmap; + + QString szPath = rootPath() + QDir::separator() + szFileName.mid(25); + szPath.replace("/", QDir::separator()); + + if(szFileName.isEmpty()) + pixmap.load(rootPath() + QDir::separator() + QDir::separator() + "empty.jpg"); + else + pixmap.load(szPath); + + if(!pixmap.width()) + return(downloadFile(szFileName)); + + return(pixmap); +} + +QPixmap cFanartImage::downloadFile(const QString& szFileName) +{ + QPixmap pixmap; + + QString szPath = rootPath() + QDir::separator() + szFileName.mid(25); + szPath.replace("/", QDir::separator()); + QString szURL = szFileName; + + QNetworkAccessManager networkManager; + QUrl url(szURL); + QNetworkRequest request(url); + request.setHeader(QNetworkRequest::ContentTypeHeader, "application/xml"); + + QNetworkReply* reply = networkManager.get(request); + QEventLoop loop; + + QObject::connect(reply, SIGNAL(finished()), &loop, SLOT(quit())); + loop.exec(); + + QByteArray szData = reply->readAll(); + delete reply; + + pixmap.loadFromData(szData); + + QDir dir(szPath); + QFileInfo fileInfo(szPath); + dir.mkpath(dir.filePath(fileInfo.absolutePath())); + pixmap.save(szPath); + + return(pixmap); +} diff --git a/cfanartimage.h b/cfanartimage.h new file mode 100644 index 0000000..3f31aa7 --- /dev/null +++ b/cfanartimage.h @@ -0,0 +1,17 @@ +#ifndef CFANARTIMAGE_H +#define CFANARTIMAGE_H + + +#include + + +class cFanartImage +{ +public: + cFanartImage(); + QPixmap getImage(const QString& szFileName); +private: + QPixmap downloadFile(const QString& szFileName); +}; + +#endif // CFANARTIMAGE_H diff --git a/cserie.cpp b/cserie.cpp index a095512..83aedc7 100644 --- a/cserie.cpp +++ b/cserie.cpp @@ -713,6 +713,17 @@ void cSerie::setFanartList(const cFanartList& fanartList) m_fanartList = fanartList; } +QString cSerie::fanartBanner() +{ + for(int x = 0;x < m_fanartList.count();x++) + { + cFanart* lpFanartTV = m_fanartList.at(x); + if(lpFanartTV->type() == cFanart::TypeTVBanner) + return(lpFanartTV->url()); + } + return(""); +} + cSerie* cSerieList::add(const qint32& iID) { cSerie* lpNew = find(iID); diff --git a/cserie.h b/cserie.h index ea5fb05..5c38d52 100644 --- a/cserie.h +++ b/cserie.h @@ -150,6 +150,8 @@ public: void loadFanart(); void setFanartList(const cFanartList& fanartList); cFanartList fanartList(); + + QString fanartBanner(); private: QString m_szSeriesName; QString m_szOriginalName; diff --git a/qtMovies.pro b/qtMovies.pro index 5743f41..5382f4c 100644 --- a/qtMovies.pro +++ b/qtMovies.pro @@ -37,7 +37,8 @@ SOURCES += main.cpp\ cscrollarea.cpp \ cpixmapwidget.cpp \ cfanart.cpp \ - cfanarttv.cpp + cfanarttv.cpp \ + cfanartimage.cpp HEADERS += cmainwindow.h \ cserie.h \ @@ -63,7 +64,8 @@ HEADERS += cmainwindow.h \ cscrollarea.h \ cpixmapwidget.h \ cfanart.h \ - cfanarttv.h + cfanarttv.h \ + cfanartimage.h FORMS += cmainwindow.ui \ csearch.ui \