@@ -402,16 +402,16 @@ void QtWebKitWebWidget::handleDownloadRequested(const QNetworkRequest &request)
402402
403403 if (device && device->size () > 0 )
404404 {
405- const QString path (Utils::getSavePath (request.url ().fileName ()). path );
405+ const SaveInformation saveInfo (Utils::getSavePath (request.url ().fileName ()));
406406
407- if (path. isEmpty ())
407+ if (!saveInfo. canSave ())
408408 {
409409 device->deleteLater ();
410410
411411 return ;
412412 }
413413
414- QFile file (path);
414+ QFile file (saveInfo. path );
415415
416416 if (!file.open (QIODevice::WriteOnly))
417417 {
@@ -435,15 +435,15 @@ void QtWebKitWebWidget::handleDownloadRequested(const QNetworkRequest &request)
435435 {
436436 const QString imageUrl (hitResult.imageUrl .url ());
437437 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));
439439
440- if (!path. isEmpty ())
440+ if (saveInfo. canSave ())
441441 {
442- QImageWriter writer (path);
442+ QImageWriter writer (saveInfo. path );
443443
444444 if (!writer.write (QImage::fromData (QByteArray::fromBase64 (imageUrl.mid (imageUrl.indexOf (QLatin1String (" ;base64," )) + 7 ).toUtf8 ()), imageType.toStdString ().c_str ())))
445445 {
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 ());
447447 }
448448 }
449449
@@ -875,14 +875,14 @@ void QtWebKitWebWidget::triggerAction(int identifier, const QVariantMap ¶met
875875 case ActionsManager::SaveAction:
876876 if (m_page->isViewingMedia ())
877877 {
878- const SaveInformation information (Utils::getSavePath (suggestSaveFileName (SingleFileSaveFormat)));
878+ const SaveInformation saveInfo (Utils::getSavePath (suggestSaveFileName (SingleFileSaveFormat)));
879879
880- if (information .canSave )
880+ if (saveInfo .canSave () )
881881 {
882882 QNetworkRequest request (getUrl ());
883883 request.setAttribute (QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
884884
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));
886886 }
887887 }
888888 else
@@ -1598,11 +1598,11 @@ void QtWebKitWebWidget::triggerAction(int identifier, const QVariantMap ¶met
15981598 m_page->setViewportSize (viewportSize);
15991599
16001600 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));
16021602
1603- if (result .canSave )
1603+ if (saveInfo .canSave () )
16041604 {
1605- pixmap.save (result .path , ((filters.indexOf (result .filter ) == 0 ) ? " PNG" : " JPEG" ));
1605+ pixmap.save (saveInfo .path , ((filters.indexOf (saveInfo .filter ) == 0 ) ? " PNG" : " JPEG" ));
16061606 }
16071607 }
16081608
0 commit comments