@@ -402,16 +402,16 @@ void QtWebKitWebWidget::handleDownloadRequested(const QNetworkRequest &request)
402
402
403
403
if (device && device->size () > 0 )
404
404
{
405
- const QString path (Utils::getSavePath (request.url ().fileName ()). path );
405
+ const SaveInformation saveInfo (Utils::getSavePath (request.url ().fileName ()));
406
406
407
- if (path. isEmpty ())
407
+ if (!saveInfo. canSave ())
408
408
{
409
409
device->deleteLater ();
410
410
411
411
return ;
412
412
}
413
413
414
- QFile file (path);
414
+ QFile file (saveInfo. path );
415
415
416
416
if (!file.open (QIODevice::WriteOnly))
417
417
{
@@ -435,15 +435,15 @@ void QtWebKitWebWidget::handleDownloadRequested(const QNetworkRequest &request)
435
435
{
436
436
const QString imageUrl (hitResult.imageUrl .url ());
437
437
const QString imageType (imageUrl.mid (11 , (imageUrl.indexOf (QLatin1Char (' ;' )) - 11 )));
438
- const QString path (Utils::getSavePath (tr (" file" ) + QLatin1Char (' .' ) + imageType). path );
438
+ const SaveInformation saveInfo (Utils::getSavePath (tr (" file" ) + QLatin1Char (' .' ) + imageType));
439
439
440
- if (!path. isEmpty ())
440
+ if (saveInfo. canSave ())
441
441
{
442
- QImageWriter writer (path);
442
+ QImageWriter writer (saveInfo. path );
443
443
444
444
if (!writer.write (QImage::fromData (QByteArray::fromBase64 (imageUrl.mid (imageUrl.indexOf (QLatin1String (" ;base64," )) + 7 ).toUtf8 ()), imageType.toStdString ().c_str ())))
445
445
{
446
- Console::addMessage (tr (" Failed to save image: %1" ).arg (writer.errorString ()), Console::OtherCategory, Console::ErrorLevel, path, -1 , getWindowIdentifier ());
446
+ Console::addMessage (tr (" Failed to save image: %1" ).arg (writer.errorString ()), Console::OtherCategory, Console::ErrorLevel, saveInfo. path , -1 , getWindowIdentifier ());
447
447
}
448
448
}
449
449
@@ -875,14 +875,14 @@ void QtWebKitWebWidget::triggerAction(int identifier, const QVariantMap ¶met
875
875
case ActionsManager::SaveAction:
876
876
if (m_page->isViewingMedia ())
877
877
{
878
- const SaveInformation information (Utils::getSavePath (suggestSaveFileName (SingleFileSaveFormat)));
878
+ const SaveInformation saveInfo (Utils::getSavePath (suggestSaveFileName (SingleFileSaveFormat)));
879
879
880
- if (information .canSave )
880
+ if (saveInfo .canSave () )
881
881
{
882
882
QNetworkRequest request (getUrl ());
883
883
request.setAttribute (QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
884
884
885
- TransfersManager::startTransfer (m_networkManager->get (request), information .path , (Transfer::CanAskForPathOption | Transfer::CanAutoDeleteOption | Transfer::CanOverwriteOption | Transfer::IsPrivateOption));
885
+ TransfersManager::startTransfer (m_networkManager->get (request), saveInfo .path , (Transfer::CanAskForPathOption | Transfer::CanAutoDeleteOption | Transfer::CanOverwriteOption | Transfer::IsPrivateOption));
886
886
}
887
887
}
888
888
else
@@ -1598,11 +1598,11 @@ void QtWebKitWebWidget::triggerAction(int identifier, const QVariantMap ¶met
1598
1598
m_page->setViewportSize (viewportSize);
1599
1599
1600
1600
const QStringList filters ({tr (" PNG image (*.png)" ), tr (" JPEG image (*.jpg *.jpeg)" )});
1601
- const SaveInformation result (Utils::getSavePath (suggestSaveFileName (QLatin1String (" .png" )), {}, filters));
1601
+ const SaveInformation saveInfo (Utils::getSavePath (suggestSaveFileName (QLatin1String (" .png" )), {}, filters));
1602
1602
1603
- if (result .canSave )
1603
+ if (saveInfo .canSave () )
1604
1604
{
1605
- pixmap.save (result .path , ((filters.indexOf (result .filter ) == 0 ) ? " PNG" : " JPEG" ));
1605
+ pixmap.save (saveInfo .path , ((filters.indexOf (saveInfo .filter ) == 0 ) ? " PNG" : " JPEG" ));
1606
1606
}
1607
1607
}
1608
1608
0 commit comments