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:
parent
ecb1d54af3
commit
b415df3395
@ -37,6 +37,10 @@
|
|||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
#include "Shlwapi.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
//#define DOWNMANAGER_DEBUG
|
//#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)
|
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()
|
void DownloadItem::openFolder()
|
||||||
{
|
{
|
||||||
#ifdef Q_OS_WIN
|
#ifdef Q_OS_WIN
|
||||||
if (m_fileName.endsWith(" ")) {
|
QString winFileName = m_path + m_fileName;
|
||||||
// explorer.exe don't support filenames that end with SPACE
|
winFileName.replace(QLatin1Char('/'), "\\");
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
|
QString shExArg = "/e,/select,\"" + winFileName + "\"";
|
||||||
}
|
ShellExecute(NULL, NULL, TEXT("explorer.exe"), shExArg.toStdWString().c_str(), NULL, SW_SHOW);
|
||||||
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);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
|
QDesktopServices::openUrl(QUrl::fromLocalFile(m_path));
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QFileIconProvider>
|
#include <QFileIconProvider>
|
||||||
#include <QTemporaryFile>
|
#include <QTemporaryFile>
|
||||||
|
#include <QHash>
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QUrlQuery>
|
#include <QUrlQuery>
|
||||||
@ -340,6 +341,26 @@ QString QzTools::applyDirectionToPage(QString &pageContents)
|
|||||||
return 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
|
// Qt5 migration help functions
|
||||||
bool QzTools::isCertificateValid(const QSslCertificate &cert)
|
bool QzTools::isCertificateValid(const QSslCertificate &cert)
|
||||||
{
|
{
|
||||||
@ -429,18 +450,3 @@ QString QzTools::buildSystem()
|
|||||||
return "Haiku";
|
return "Haiku";
|
||||||
#endif
|
#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;
|
|
||||||
}
|
|
||||||
|
@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
#include "qz_namespace.h"
|
#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);
|
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 applyDirectionToPage(QString &pageContents);
|
||||||
|
|
||||||
QString QT_QUPZILLA_EXPORT buildSystem();
|
|
||||||
QIcon QT_QUPZILLA_EXPORT iconFromFileName(const QString &fileName);
|
QIcon QT_QUPZILLA_EXPORT iconFromFileName(const QString &fileName);
|
||||||
|
|
||||||
|
QString QT_QUPZILLA_EXPORT buildSystem();
|
||||||
|
|
||||||
// Qt5 migration help functions
|
// Qt5 migration help functions
|
||||||
bool QT_QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert);
|
bool QT_QUPZILLA_EXPORT isCertificateValid(const QSslCertificate &cert);
|
||||||
QString QT_QUPZILLA_EXPORT escape(const QString &string);
|
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);
|
return (index >= 0 && list.count() > index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QHash<QString, QIcon> m_iconCache;
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#endif // GLOBALFUNCTIONS_H
|
#endif // GLOBALFUNCTIONS_H
|
||||||
|
Loading…
Reference in New Issue
Block a user