1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 18:56:34 +01:00

Merge pull request #726 from srazi/master

Fixed downloader issue and some ftp related changes.
This commit is contained in:
David Rosca 2013-01-29 10:29:32 -08:00
commit ecb1d54af3
5 changed files with 28 additions and 7 deletions

View File

@ -863,6 +863,7 @@ RegisterQAppAssociation* MainApplication::associationManager()
m_registerQAppAssociation->addCapability(".htm", "QupZilla.HTM", "HTM File", fileIconPath, RegisterQAppAssociation::FileAssociation); m_registerQAppAssociation->addCapability(".htm", "QupZilla.HTM", "HTM File", fileIconPath, RegisterQAppAssociation::FileAssociation);
m_registerQAppAssociation->addCapability("http", "QupZilla.HTTP", "URL:HyperText Transfer Protocol", appIconPath, RegisterQAppAssociation::UrlAssociation); m_registerQAppAssociation->addCapability("http", "QupZilla.HTTP", "URL:HyperText Transfer Protocol", appIconPath, RegisterQAppAssociation::UrlAssociation);
m_registerQAppAssociation->addCapability("https", "QupZilla.HTTPS", "URL:HyperText Transfer Protocol with Privacy", appIconPath, RegisterQAppAssociation::UrlAssociation); m_registerQAppAssociation->addCapability("https", "QupZilla.HTTPS", "URL:HyperText Transfer Protocol with Privacy", appIconPath, RegisterQAppAssociation::UrlAssociation);
m_registerQAppAssociation->addCapability("ftp", "QupZilla.FTP", "URL:File Transfer Protocol", appIconPath, RegisterQAppAssociation::UrlAssociation);
} }
return m_registerQAppAssociation; return m_registerQAppAssociation;
} }

View File

@ -320,13 +320,19 @@ void DownloadItem::stop(bool askForDeleteFile)
return; return;
} }
m_downloadStopped = true; m_downloadStopped = true;
QString host = m_reply ? m_reply->url().host() : m_ftpDownloader->url().host(); QString host;
if (m_reply) {
host = m_reply->url().host();
}
else if (m_ftpDownloader) {
host = m_ftpDownloader->url().host();
}
m_openAfterFinish = false; m_openAfterFinish = false;
m_timer.stop(); m_timer.stop();
if (m_reply) { if (m_reply) {
m_reply->abort(); m_reply->abort();
} }
else { else if (m_ftpDownloader) {
m_ftpDownloader->abort(); m_ftpDownloader->abort();
m_ftpDownloader->close(); m_ftpDownloader->close();
} }
@ -454,8 +460,8 @@ void DownloadItem::error()
ui->downloadInfo->setText(tr("Error: ") + m_reply->errorString()); ui->downloadInfo->setText(tr("Error: ") + m_reply->errorString());
} }
else if (m_ftpDownloader && m_ftpDownloader->error() != QFtp::NoError) { else if (m_ftpDownloader && m_ftpDownloader->error() != QFtp::NoError) {
ui->downloadInfo->setText(tr("Error: ") + m_ftpDownloader->errorString());
stop(false); stop(false);
ui->downloadInfo->setText(tr("Error: ") + m_ftpDownloader->errorString());
} }
} }
@ -464,9 +470,10 @@ void DownloadItem::updateDownload()
#ifdef DOWNMANAGER_DEBUG #ifdef DOWNMANAGER_DEBUG
qDebug() << __FUNCTION__ ; qDebug() << __FUNCTION__ ;
#endif #endif
bool downoaderIsFinished = (m_reply && m_reply->isFinished()) // after caling stop() (from readyRead()) m_reply will be a dangling pointer,
|| (m_ftpDownloader && m_ftpDownloader->isFinished()); // thus it should be checked after m_outputFile.isOpen()
if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() && downoaderIsFinished) { if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() &&
((m_reply && m_reply->isFinished()) || (m_ftpDownloader && m_ftpDownloader->isFinished()))) {
downloadProgress(0, 0); downloadProgress(0, 0);
finished(); finished();
} }

View File

@ -433,8 +433,14 @@ QString QzTools::buildSystem()
QIcon QzTools::iconFromFileName(const QString &fileName) QIcon QzTools::iconFromFileName(const QString &fileName)
{ {
QFileInfo tempInfo(fileName); QFileInfo tempInfo(fileName);
if (m_iconCache.contains(tempInfo.suffix())) {
return m_iconCache.value(tempInfo.suffix());
}
QTemporaryFile tempFile(mApp->tempPath() + "/XXXXXX." + tempInfo.suffix()); QTemporaryFile tempFile(mApp->tempPath() + "/XXXXXX." + tempInfo.suffix());
tempFile.open(); tempFile.open();
tempInfo.setFile(tempFile.fileName()); tempInfo.setFile(tempFile.fileName());
return QFileIconProvider().icon(tempInfo); QIcon icon(QFileIconProvider().icon(tempInfo));
m_iconCache.insert(tempInfo.suffix(), icon);
return icon;
} }

View File

@ -20,6 +20,7 @@
#include <QList> #include <QList>
#include <QString> #include <QString>
#include <QHash>
#include "qz_namespace.h" #include "qz_namespace.h"
@ -73,6 +74,8 @@ bool listContainsIndex(const QList<T> &list, int index)
return (index >= 0 && list.count() > index); return (index >= 0 && list.count() > index);
} }
static QHash<QString, QIcon> m_iconCache;
} // namespace } // namespace
#endif // GLOBALFUNCTIONS_H #endif // GLOBALFUNCTIONS_H

View File

@ -319,6 +319,7 @@ SectionGroup $(TITLE_SecSetASDefault) SecSetASDefault
Section $(TITLE_SecProtocols) SecProtocols Section $(TITLE_SecProtocols) SecProtocols
${RegisterAssociation} "http" "$INSTDIR\qupzilla.exe" "QupZilla.HTTP" "URL:HyperText Transfer Protocol" "$INSTDIR\qupzilla.exe,0" "protocol" ${RegisterAssociation} "http" "$INSTDIR\qupzilla.exe" "QupZilla.HTTP" "URL:HyperText Transfer Protocol" "$INSTDIR\qupzilla.exe,0" "protocol"
${RegisterAssociation} "https" "$INSTDIR\qupzilla.exe" "QupZilla.HTTPS" "URL:HyperText Transfer Protocol with Privacy" "$INSTDIR\qupzilla.exe,0" "protocol" ${RegisterAssociation} "https" "$INSTDIR\qupzilla.exe" "QupZilla.HTTPS" "URL:HyperText Transfer Protocol with Privacy" "$INSTDIR\qupzilla.exe,0" "protocol"
${RegisterAssociation} "ftp" "$INSTDIR\qupzilla.exe" "QupZilla.FTP" "URL:File Transfer Protocol" "$INSTDIR\qupzilla.exe,0" "protocol"
${UpdateSystemIcons} ${UpdateSystemIcons}
SectionEnd SectionEnd
SectionGroupEnd SectionGroupEnd
@ -399,6 +400,7 @@ notRunning:
${UnRegisterAssociation} ".html" "QupZilla.HTML" "$INSTDIR\qupzilla.exe" "file" ${UnRegisterAssociation} ".html" "QupZilla.HTML" "$INSTDIR\qupzilla.exe" "file"
${UnRegisterAssociation} "http" "QupZilla.HTTP" "$INSTDIR\qupzilla.exe" "protocol" ${UnRegisterAssociation} "http" "QupZilla.HTTP" "$INSTDIR\qupzilla.exe" "protocol"
${UnRegisterAssociation} "https" "QupZilla.HTTPS" "$INSTDIR\qupzilla.exe" "protocol" ${UnRegisterAssociation} "https" "QupZilla.HTTPS" "$INSTDIR\qupzilla.exe" "protocol"
${UnRegisterAssociation} "ftp" "QupZilla.FTP" "$INSTDIR\qupzilla.exe" "protocol"
${UpdateSystemIcons} ${UpdateSystemIcons}
SectionEnd SectionEnd
@ -476,6 +478,7 @@ Function RegisterCapabilities
${CreateProgId} "QupZilla.HTML" "$INSTDIR\qupzilla.exe" $(FILE_Html) "$INSTDIR\qupzilla.exe,1" ${CreateProgId} "QupZilla.HTML" "$INSTDIR\qupzilla.exe" $(FILE_Html) "$INSTDIR\qupzilla.exe,1"
${CreateProgId} "QupZilla.HTTP" "$INSTDIR\qupzilla.exe" "URL:HyperText Transfer Protocol" "$INSTDIR\qupzilla.exe,0" ${CreateProgId} "QupZilla.HTTP" "$INSTDIR\qupzilla.exe" "URL:HyperText Transfer Protocol" "$INSTDIR\qupzilla.exe,0"
${CreateProgId} "QupZilla.HTTPS" "$INSTDIR\qupzilla.exe" "URL:HyperText Transfer Protocol with Privacy" "$INSTDIR\qupzilla.exe,0" ${CreateProgId} "QupZilla.HTTPS" "$INSTDIR\qupzilla.exe" "URL:HyperText Transfer Protocol with Privacy" "$INSTDIR\qupzilla.exe,0"
${CreateProgId} "QupZilla.FTP" "$INSTDIR\qupzilla.exe" "URL:File Transfer Protocol" "$INSTDIR\qupzilla.exe,0"
; note: these lines just introduce capabilities of QupZilla to OS and don't change defaults! ; note: these lines just introduce capabilities of QupZilla to OS and don't change defaults!
WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}" "ApplicationDescription" "$(PRODUCT_DESC)" WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}" "ApplicationDescription" "$(PRODUCT_DESC)"
@ -485,6 +488,7 @@ Function RegisterCapabilities
WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\FileAssociations" ".html" "QupZilla.HTML" WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\FileAssociations" ".html" "QupZilla.HTML"
WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\URLAssociations" "http" "QupZilla.HTTP" WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\URLAssociations" "http" "QupZilla.HTTP"
WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\URLAssociations" "https" "QupZilla.HTTPS" WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\URLAssociations" "https" "QupZilla.HTTPS"
WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\URLAssociations" "ftp" "QupZilla.FTP"
WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\Startmenu" "StartMenuInternet" "$INSTDIR\qupzilla.exe" WriteRegStr HKLM "${PRODUCT_CAPABILITIES_KEY}\Startmenu" "StartMenuInternet" "$INSTDIR\qupzilla.exe"
WriteRegStr HKLM "SOFTWARE\RegisteredApplications" "${PRODUCT_NAME}" "${PRODUCT_CAPABILITIES_KEY}" WriteRegStr HKLM "SOFTWARE\RegisteredApplications" "${PRODUCT_NAME}" "${PRODUCT_CAPABILITIES_KEY}"
${EndIf} ${EndIf}