1
mirror of https://invent.kde.org/network/falkon.git synced 2024-12-20 10:46:35 +01:00

Fixed building on both Linux & Windows.

This commit is contained in:
nowrep 2013-01-29 19:55:09 +01:00
parent ecb1d54af3
commit b415df3395
3 changed files with 31 additions and 29 deletions

View File

@ -37,6 +37,10 @@
#include <QDesktopServices>
#include <QProcess>
#ifdef Q_OS_WIN
#include "Shlwapi.h"
#endif
//#define DOWNMANAGER_DEBUG
DownloadItem::DownloadItem(QListWidgetItem* item, QNetworkReply* reply, const QString &path, const QString &fileName, const QPixmap &fileIcon, QTime* timer, bool openAfterFinishedDownload, const QUrl &downloadPage, DownloadManager* manager)
@ -423,16 +427,10 @@ void DownloadItem::openFile()
void DownloadItem::openFolder()
{
#ifdef Q_OS_WIN
if (m_fileName.endsWith(" ")) {
// explorer.exe don't support filenames that end with SPACE
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
}
else {
QString winFileName = m_path + m_fileName;
winFileName.replace(QLatin1Char('/'), "\\");
QString shExArg = "/e,/select,\"" + winFileName + "\"";
ShellExecute(NULL, NULL, TEXT("explorer.exe"), shExArg.toStdWString().c_str(), NULL, SW_SHOW);
}
QString winFileName = m_path + m_fileName;
winFileName.replace(QLatin1Char('/'), "\\");
QString shExArg = "/e,/select,\"" + winFileName + "\"";
ShellExecute(NULL, NULL, TEXT("explorer.exe"), shExArg.toStdWString().c_str(), NULL, SW_SHOW);
#else
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
#endif

View File

@ -34,6 +34,7 @@
#include <QIcon>
#include <QFileIconProvider>
#include <QTemporaryFile>
#include <QHash>
#if QT_VERSION >= 0x050000
#include <QUrlQuery>
@ -340,6 +341,26 @@ QString QzTools::applyDirectionToPage(QString &pageContents)
return pageContents;
}
QIcon QzTools::iconFromFileName(const QString &fileName)
{
static QHash<QString, QIcon> iconCache;
QFileInfo tempInfo(fileName);
if (iconCache.contains(tempInfo.suffix())) {
return iconCache.value(tempInfo.suffix());
}
QFileIconProvider iconProvider;
QTemporaryFile tempFile(mApp->tempPath() + "/XXXXXX." + tempInfo.suffix());
tempFile.open();
tempInfo.setFile(tempFile.fileName());
QIcon icon(iconProvider.icon(tempInfo));
iconCache.insert(tempInfo.suffix(), icon);
return icon;
}
// Qt5 migration help functions
bool QzTools::isCertificateValid(const QSslCertificate &cert)
{
@ -429,18 +450,3 @@ QString QzTools::buildSystem()
return "Haiku";
#endif
}
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());
QIcon icon(QFileIconProvider().icon(tempInfo));
m_iconCache.insert(tempInfo.suffix(), icon);
return icon;
}

View File

@ -20,7 +20,6 @@
#include <QList>
#include <QString>
#include <QHash>
#include "qz_namespace.h"
@ -57,9 +56,10 @@ QString QT_QUPZILLA_EXPORT fileSizeToString(qint64 size);
QPixmap QT_QUPZILLA_EXPORT createPixmapForSite(const QIcon &icon, const QString &title, const QString &url);
QString QT_QUPZILLA_EXPORT applyDirectionToPage(QString &pageContents);
QString QT_QUPZILLA_EXPORT buildSystem();
QIcon QT_QUPZILLA_EXPORT iconFromFileName(const QString &fileName);
QString QT_QUPZILLA_EXPORT buildSystem();
// Qt5 migration help functions
bool QT_QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert);
QString QT_QUPZILLA_EXPORT escape(const QString &string);
@ -74,8 +74,6 @@ bool listContainsIndex(const QList<T> &list, int index)
return (index >= 0 && list.count() > index);
}
static QHash<QString, QIcon> m_iconCache;
} // namespace
#endif // GLOBALFUNCTIONS_H