diff --git a/src/lib/app/mainapplication.cpp b/src/lib/app/mainapplication.cpp index de83f285b..32764a791 100644 --- a/src/lib/app/mainapplication.cpp +++ b/src/lib/app/mainapplication.cpp @@ -863,6 +863,7 @@ RegisterQAppAssociation* MainApplication::associationManager() 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("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; } diff --git a/src/lib/downloads/downloaditem.cpp b/src/lib/downloads/downloaditem.cpp index f367471f8..fdcc3f818 100644 --- a/src/lib/downloads/downloaditem.cpp +++ b/src/lib/downloads/downloaditem.cpp @@ -320,13 +320,19 @@ void DownloadItem::stop(bool askForDeleteFile) return; } 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_timer.stop(); if (m_reply) { m_reply->abort(); } - else { + else if (m_ftpDownloader) { m_ftpDownloader->abort(); m_ftpDownloader->close(); } @@ -454,8 +460,8 @@ void DownloadItem::error() ui->downloadInfo->setText(tr("Error: ") + m_reply->errorString()); } else if (m_ftpDownloader && m_ftpDownloader->error() != QFtp::NoError) { - ui->downloadInfo->setText(tr("Error: ") + m_ftpDownloader->errorString()); stop(false); + ui->downloadInfo->setText(tr("Error: ") + m_ftpDownloader->errorString()); } } @@ -464,9 +470,10 @@ void DownloadItem::updateDownload() #ifdef DOWNMANAGER_DEBUG qDebug() << __FUNCTION__ ; #endif - bool downoaderIsFinished = (m_reply && m_reply->isFinished()) - || (m_ftpDownloader && m_ftpDownloader->isFinished()); - if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() && downoaderIsFinished) { + // after caling stop() (from readyRead()) m_reply will be a dangling pointer, + // thus it should be checked after m_outputFile.isOpen() + if (ui->progressBar->maximum() == 0 && m_outputFile.isOpen() && + ((m_reply && m_reply->isFinished()) || (m_ftpDownloader && m_ftpDownloader->isFinished()))) { downloadProgress(0, 0); finished(); } diff --git a/src/lib/tools/qztools.cpp b/src/lib/tools/qztools.cpp index 04d69c96e..c8ba509ba 100644 --- a/src/lib/tools/qztools.cpp +++ b/src/lib/tools/qztools.cpp @@ -433,8 +433,14 @@ QString QzTools::buildSystem() QIcon QzTools::iconFromFileName(const QString &fileName) { QFileInfo tempInfo(fileName); + if (m_iconCache.contains(tempInfo.suffix())) { + return m_iconCache.value(tempInfo.suffix()); + } + QTemporaryFile tempFile(mApp->tempPath() + "/XXXXXX." + tempInfo.suffix()); tempFile.open(); tempInfo.setFile(tempFile.fileName()); - return QFileIconProvider().icon(tempInfo); + QIcon icon(QFileIconProvider().icon(tempInfo)); + m_iconCache.insert(tempInfo.suffix(), icon); + return icon; } diff --git a/src/lib/tools/qztools.h b/src/lib/tools/qztools.h index 3cdf38edb..41b516572 100644 --- a/src/lib/tools/qztools.h +++ b/src/lib/tools/qztools.h @@ -20,6 +20,7 @@ #include #include +#include #include "qz_namespace.h" @@ -73,6 +74,8 @@ bool listContainsIndex(const QList &list, int index) return (index >= 0 && list.count() > index); } +static QHash m_iconCache; + } // namespace #endif // GLOBALFUNCTIONS_H diff --git a/windows/installer.nsi b/windows/installer.nsi index 070c45845..5b5ad55aa 100644 --- a/windows/installer.nsi +++ b/windows/installer.nsi @@ -319,6 +319,7 @@ SectionGroup $(TITLE_SecSetASDefault) SecSetASDefault Section $(TITLE_SecProtocols) SecProtocols ${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} "ftp" "$INSTDIR\qupzilla.exe" "QupZilla.FTP" "URL:File Transfer Protocol" "$INSTDIR\qupzilla.exe,0" "protocol" ${UpdateSystemIcons} SectionEnd SectionGroupEnd @@ -399,6 +400,7 @@ notRunning: ${UnRegisterAssociation} ".html" "QupZilla.HTML" "$INSTDIR\qupzilla.exe" "file" ${UnRegisterAssociation} "http" "QupZilla.HTTP" "$INSTDIR\qupzilla.exe" "protocol" ${UnRegisterAssociation} "https" "QupZilla.HTTPS" "$INSTDIR\qupzilla.exe" "protocol" + ${UnRegisterAssociation} "ftp" "QupZilla.FTP" "$INSTDIR\qupzilla.exe" "protocol" ${UpdateSystemIcons} SectionEnd @@ -476,6 +478,7 @@ Function RegisterCapabilities ${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.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! 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}\URLAssociations" "http" "QupZilla.HTTP" 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 "SOFTWARE\RegisteredApplications" "${PRODUCT_NAME}" "${PRODUCT_CAPABILITIES_KEY}" ${EndIf}