fix remote import
This commit is contained in:
parent
541a7d18bd
commit
dc101a66da
3 changed files with 91 additions and 68 deletions
|
@ -10,7 +10,7 @@ Windows Portable:
|
||||||
script:
|
script:
|
||||||
- .gitlab/gitlab.sh
|
- .gitlab/gitlab.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "gta5view-{$CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA:0:8}_portable"
|
name: "gta5view-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}_portable"
|
||||||
paths:
|
paths:
|
||||||
- "gta5view-*.exe"
|
- "gta5view-*.exe"
|
||||||
|
|
||||||
|
@ -23,6 +23,6 @@ Windows Installer:
|
||||||
script:
|
script:
|
||||||
- .gitlab/gitlab.sh
|
- .gitlab/gitlab.sh
|
||||||
artifacts:
|
artifacts:
|
||||||
name: "gta5view-{$CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA:0:8}_setup"
|
name: "gta5view-$CI_COMMIT_REF_NAME-${CI_COMMIT_SHA:0:8}_setup"
|
||||||
paths:
|
paths:
|
||||||
- "gta5view-*.exe"
|
- "gta5view-*.exe"
|
||||||
|
|
|
@ -838,6 +838,78 @@ bool ProfileInterface::importUrls(const QMimeData *mimeData)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProfileInterface::importRemote(QUrl remoteUrl)
|
||||||
|
{
|
||||||
|
bool retValue = false;
|
||||||
|
QDialog urlPasteDialog(this);
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
urlPasteDialog.setObjectName(QStringLiteral("UrlPasteDialog"));
|
||||||
|
#else
|
||||||
|
urlPasteDialog.setObjectName(QString::fromUtf8("UrlPasteDialog"));
|
||||||
|
#endif
|
||||||
|
urlPasteDialog.setWindowFlags(urlPasteDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
|
||||||
|
urlPasteDialog.setWindowTitle(tr("Import..."));
|
||||||
|
urlPasteDialog.setModal(true);
|
||||||
|
QVBoxLayout urlPasteLayout(&urlPasteDialog);
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
urlPasteLayout.setObjectName(QStringLiteral("UrlPasteLayout"));
|
||||||
|
#else
|
||||||
|
urlPasteLayout.setObjectName(QString::fromUtf8("UrlPasteLayout"));
|
||||||
|
#endif
|
||||||
|
urlPasteDialog.setLayout(&urlPasteLayout);
|
||||||
|
UiModLabel urlPasteLabel(&urlPasteDialog);
|
||||||
|
#if QT_VERSION >= 0x050000
|
||||||
|
urlPasteLabel.setObjectName(QStringLiteral("UrlPasteLabel"));
|
||||||
|
#else
|
||||||
|
urlPasteLabel.setObjectName(QString::fromUtf8("UrlPasteLabel"));
|
||||||
|
#endif
|
||||||
|
|
||||||
|
urlPasteLabel.setText(tr("Prepare Content for Import..."));
|
||||||
|
urlPasteLayout.addWidget(&urlPasteLabel);
|
||||||
|
urlPasteDialog.setFixedSize(urlPasteDialog.sizeHint());
|
||||||
|
urlPasteDialog.show();
|
||||||
|
|
||||||
|
QNetworkAccessManager *netManager = new QNetworkAccessManager();
|
||||||
|
QNetworkRequest netRequest(remoteUrl);
|
||||||
|
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
|
||||||
|
netRequest.setRawHeader("Accept", "text/html");
|
||||||
|
netRequest.setRawHeader("Accept-Charset", "utf-8");
|
||||||
|
netRequest.setRawHeader("Accept-Language", "en-US,en;q=0.9");
|
||||||
|
netRequest.setRawHeader("Connection", "keep-alive");
|
||||||
|
QNetworkReply *netReply = netManager->get(netRequest);
|
||||||
|
QEventLoop *downloadLoop = new QEventLoop();
|
||||||
|
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
|
||||||
|
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
|
||||||
|
downloadLoop->exec();
|
||||||
|
downloadLoop->disconnect();
|
||||||
|
delete downloadLoop;
|
||||||
|
|
||||||
|
urlPasteDialog.close();
|
||||||
|
|
||||||
|
if (netReply->isFinished())
|
||||||
|
{
|
||||||
|
QImage *snapmaticImage = new QImage();
|
||||||
|
QImageReader snapmaticImageReader;
|
||||||
|
snapmaticImageReader.setDecideFormatFromContent(true);
|
||||||
|
snapmaticImageReader.setDevice(netReply);
|
||||||
|
if (snapmaticImageReader.read(snapmaticImage))
|
||||||
|
{
|
||||||
|
retValue = importImage(snapmaticImage, QDateTime::currentDateTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
delete snapmaticImage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
netReply->abort();
|
||||||
|
}
|
||||||
|
delete netReply;
|
||||||
|
delete netManager;
|
||||||
|
return retValue;
|
||||||
|
}
|
||||||
|
|
||||||
bool ProfileInterface::importImage(QImage *snapmaticImage, QDateTime importDateTime)
|
bool ProfileInterface::importImage(QImage *snapmaticImage, QDateTime importDateTime)
|
||||||
{
|
{
|
||||||
SnapmaticPicture *picture = new SnapmaticPicture(":/template/template.g5e");
|
SnapmaticPicture *picture = new SnapmaticPicture(":/template/template.g5e");
|
||||||
|
@ -1462,72 +1534,22 @@ bool ProfileInterface::eventFilter(QObject *watched, QEvent *event)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
QDialog urlPasteDialog(this);
|
importRemote(clipboardUrl);
|
||||||
#if QT_VERSION >= 0x050000
|
}
|
||||||
urlPasteDialog.setObjectName(QStringLiteral("UrlPasteDialog"));
|
}
|
||||||
#else
|
}
|
||||||
urlPasteDialog.setObjectName(QString::fromUtf8("UrlPasteDialog"));
|
else if (clipboardData->hasText())
|
||||||
#endif
|
|
||||||
urlPasteDialog.setWindowFlags(urlPasteDialog.windowFlags()^Qt::WindowContextHelpButtonHint^Qt::WindowCloseButtonHint);
|
|
||||||
urlPasteDialog.setWindowTitle(tr("Import..."));
|
|
||||||
urlPasteDialog.setModal(true);
|
|
||||||
QVBoxLayout urlPasteLayout(&urlPasteDialog);
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
urlPasteLayout.setObjectName(QStringLiteral("UrlPasteLayout"));
|
|
||||||
#else
|
|
||||||
urlPasteLayout.setObjectName(QString::fromUtf8("UrlPasteLayout"));
|
|
||||||
#endif
|
|
||||||
urlPasteDialog.setLayout(&urlPasteLayout);
|
|
||||||
UiModLabel urlPasteLabel(&urlPasteDialog);
|
|
||||||
#if QT_VERSION >= 0x050000
|
|
||||||
urlPasteLabel.setObjectName(QStringLiteral("UrlPasteLabel"));
|
|
||||||
#else
|
|
||||||
urlPasteLabel.setObjectName(QString::fromUtf8("UrlPasteLabel"));
|
|
||||||
#endif
|
|
||||||
|
|
||||||
urlPasteLabel.setText(tr("Prepare Content for Import..."));
|
|
||||||
urlPasteLayout.addWidget(&urlPasteLabel);
|
|
||||||
urlPasteDialog.setFixedSize(urlPasteDialog.sizeHint());
|
|
||||||
urlPasteDialog.show();
|
|
||||||
|
|
||||||
QNetworkAccessManager *netManager = new QNetworkAccessManager();
|
|
||||||
QNetworkRequest netRequest(clipboardUrl);
|
|
||||||
netRequest.setRawHeader("User-Agent", AppEnv::getUserAgent());
|
|
||||||
netRequest.setRawHeader("Accept", "text/html");
|
|
||||||
netRequest.setRawHeader("Accept-Charset", "utf-8");
|
|
||||||
netRequest.setRawHeader("Accept-Language", "en-US,en;q=0.9");
|
|
||||||
netRequest.setRawHeader("Connection", "keep-alive");
|
|
||||||
QNetworkReply *netReply = netManager->get(netRequest);
|
|
||||||
QEventLoop *downloadLoop = new QEventLoop();
|
|
||||||
QObject::connect(netReply, SIGNAL(finished()), downloadLoop, SLOT(quit()));
|
|
||||||
QTimer::singleShot(30000, downloadLoop, SLOT(quit()));
|
|
||||||
downloadLoop->exec();
|
|
||||||
downloadLoop->disconnect();
|
|
||||||
delete downloadLoop;
|
|
||||||
|
|
||||||
urlPasteDialog.close();
|
|
||||||
|
|
||||||
if (netReply->isFinished())
|
|
||||||
{
|
{
|
||||||
QImage *snapmaticImage = new QImage();
|
QUrl clipboardUrl = QUrl::fromUserInput(clipboardData->text());
|
||||||
QImageReader snapmaticImageReader;
|
if (clipboardUrl.isValid())
|
||||||
snapmaticImageReader.setDecideFormatFromContent(true);
|
|
||||||
snapmaticImageReader.setDevice(netReply);
|
|
||||||
if (snapmaticImageReader.read(snapmaticImage))
|
|
||||||
{
|
{
|
||||||
importImage(snapmaticImage, QDateTime::currentDateTime());
|
if (clipboardUrl.isLocalFile())
|
||||||
|
{
|
||||||
|
importFile(clipboardUrl.toLocalFile(), QDateTime::currentDateTime(), true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delete snapmaticImage;
|
importRemote(clipboardUrl);
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
netReply->abort();
|
|
||||||
}
|
|
||||||
delete netReply;
|
|
||||||
delete netManager;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -117,6 +117,7 @@ private:
|
||||||
bool isSupportedImageFile(QString selectedFileName);
|
bool isSupportedImageFile(QString selectedFileName);
|
||||||
bool importFile(QString selectedFile, QDateTime importDateTime, bool notMultiple);
|
bool importFile(QString selectedFile, QDateTime importDateTime, bool notMultiple);
|
||||||
bool importUrls(const QMimeData *mimeData);
|
bool importUrls(const QMimeData *mimeData);
|
||||||
|
bool importRemote(QUrl remoteUrl);
|
||||||
bool importImage(QImage *snapmaticImage, QDateTime importDateTime);
|
bool importImage(QImage *snapmaticImage, QDateTime importDateTime);
|
||||||
bool importFilesProgress(QStringList selectedFiles);
|
bool importFilesProgress(QStringList selectedFiles);
|
||||||
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);
|
bool importSnapmaticPicture(SnapmaticPicture *picture, bool warn = true);
|
||||||
|
|
Loading…
Reference in a new issue