- Remove network/image download code (as it is unused)
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
#include "logger.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QRegularExpression>
|
||||
#include <iostream>
|
||||
#include <sys/file.h>
|
||||
@@ -261,11 +260,8 @@ int main(int argc, char *argv[])
|
||||
Log( "Rotation Time: ", appConfig.rotationSeconds );
|
||||
Log( "Overlay input: ", appConfig.overlay );
|
||||
|
||||
QNetworkAccessManager webCtrl;
|
||||
|
||||
MainWindow w;
|
||||
ConfigureWindowFromSettings(w, appConfig);
|
||||
w.setNetworkManager(&webCtrl);
|
||||
w.show();
|
||||
|
||||
std::unique_ptr<ImageSelector> selector = GetSelectorForApp(appConfig);
|
||||
|
||||
@@ -18,8 +18,6 @@
|
||||
#include <QGraphicsPixmapItem>
|
||||
#include <QApplication>
|
||||
#include <QScreen>
|
||||
#include <QNetworkReply>
|
||||
#include <sstream>
|
||||
|
||||
MainWindow::MainWindow(QWidget *parent) :
|
||||
QMainWindow(parent),
|
||||
@@ -162,46 +160,15 @@ void MainWindow::checkWindowSize()
|
||||
void MainWindow::setImage(const ImageDetails &imageDetails)
|
||||
{
|
||||
currentImage = imageDetails;
|
||||
downloadedData.clear();
|
||||
if (pendingReply)
|
||||
{
|
||||
pendingReply->abort();
|
||||
}
|
||||
updateImage();
|
||||
}
|
||||
|
||||
void MainWindow::fileDownloaded(QNetworkReply* netReply)
|
||||
{
|
||||
if (netReply == pendingReply)
|
||||
{
|
||||
pendingReply = nullptr;
|
||||
QNetworkReply::NetworkError err = netReply->error();
|
||||
if (err == QNetworkReply::NoError)
|
||||
{
|
||||
downloadedData = netReply->readAll();
|
||||
netReply->deleteLater();
|
||||
updateImage();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateImage()
|
||||
{
|
||||
checkWindowSize();
|
||||
if (currentImage.filename == "")
|
||||
return;
|
||||
|
||||
if (currentImage.filename.find("https://") != std::string::npos && downloadedData.isNull())
|
||||
{
|
||||
if (pendingReply == nullptr)
|
||||
{
|
||||
QNetworkRequest request(QUrl(currentImage.filename.c_str()));
|
||||
pendingReply = networkManager->get(request);
|
||||
connect( networkManager, SIGNAL (finished(QNetworkReply*)), this, SLOT (fileDownloaded(QNetworkReply*)));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
QLabel *label = this->findChild<QLabel*>("image");
|
||||
const QPixmap* oldImage = label->pixmap();
|
||||
if (oldImage != NULL && transitionSeconds > 0)
|
||||
@@ -212,18 +179,7 @@ void MainWindow::updateImage()
|
||||
}
|
||||
|
||||
QPixmap p;
|
||||
if (!downloadedData.isNull())
|
||||
{
|
||||
p.loadFromData(downloadedData);
|
||||
// BUG BUG have the selector update this?
|
||||
currentImage.width = p.width();
|
||||
currentImage.height = p.height();
|
||||
currentImage.rotation = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
p.load( currentImage.filename.c_str() );
|
||||
}
|
||||
p.load( currentImage.filename.c_str() );
|
||||
|
||||
Log("size:", p.width(), "x", p.height(), "(window:", width(), ",", height(), ")");
|
||||
|
||||
@@ -440,8 +396,3 @@ const ImageDisplayOptions &MainWindow::getBaseOptions()
|
||||
{
|
||||
return baseImageOptions;
|
||||
}
|
||||
|
||||
void MainWindow::setNetworkManager(QNetworkAccessManager *networkManagerIn)
|
||||
{
|
||||
networkManager = networkManagerIn;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
|
||||
#include <QMainWindow>
|
||||
#include <QPixmap>
|
||||
#include <QNetworkAccessManager>
|
||||
#include "imagestructs.h"
|
||||
#include "imageselector.h"
|
||||
|
||||
@@ -34,12 +33,9 @@ public:
|
||||
void setBaseOptions(const ImageDisplayOptions &baseOptionsIn);
|
||||
const ImageDisplayOptions &getBaseOptions();
|
||||
void setImageSwitcher(ImageSwitcher *switcherIn);
|
||||
void setNetworkManager(QNetworkAccessManager *networkManagerIn);
|
||||
void setOverlayHexRGB(QString overlayHexRGB);
|
||||
public slots:
|
||||
void checkWindowSize();
|
||||
private slots:
|
||||
void fileDownloaded(QNetworkReply* pReply);
|
||||
private:
|
||||
Ui::MainWindow *ui;
|
||||
|
||||
@@ -48,9 +44,6 @@ private:
|
||||
ImageDisplayOptions baseImageOptions;
|
||||
bool imageAspectMatchesMonitor = false;
|
||||
ImageDetails currentImage;
|
||||
QByteArray downloadedData;
|
||||
QNetworkAccessManager *networkManager = nullptr;
|
||||
QNetworkReply *pendingReply = nullptr;
|
||||
QSize lastScreenSize = {0,0};
|
||||
QString overlayHexRGB = "#FFFF";
|
||||
unsigned int transitionSeconds = 1;
|
||||
|
||||
@@ -6,8 +6,6 @@
|
||||
#include <QDirIterator>
|
||||
#include <QDir>
|
||||
#include <QFileInfo>
|
||||
#include <QDomDocument>
|
||||
#include <QDomAttr>
|
||||
#include <iostream>
|
||||
#include <stdlib.h> /* srand, rand */
|
||||
|
||||
|
||||
@@ -4,9 +4,6 @@
|
||||
#include <iostream>
|
||||
#include <QDir>
|
||||
#include <QStringList>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkRequest>
|
||||
#include <QNetworkReply>
|
||||
#include "imageselector.h"
|
||||
|
||||
static const QStringList supportedFormats={"jpg","jpeg","png","tif","tiff"};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
#
|
||||
#-------------------------------------------------
|
||||
|
||||
QT += core gui network xml
|
||||
QT += core gui
|
||||
CONFIG += qt
|
||||
CONFIG += debug
|
||||
CONFIG += c++1z
|
||||
|
||||
Reference in New Issue
Block a user