mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
Downloads: Bring back option to choose path / open downloads
This commit is contained in:
parent
35f002efb4
commit
510f521074
@ -1,330 +0,0 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#include "downloadfilehelper.h"
|
||||
#include "webpage.h"
|
||||
#include "tabbedwebview.h"
|
||||
#include "downloadoptionsdialog.h"
|
||||
#include "mainapplication.h"
|
||||
#include "browserwindow.h"
|
||||
#include "downloaditem.h"
|
||||
#include "downloadmanager.h"
|
||||
#include "qztools.h"
|
||||
#include "datapaths.h"
|
||||
#include "settings.h"
|
||||
#include "qzregexp.h"
|
||||
|
||||
#include <QFileIconProvider>
|
||||
#include <QListWidgetItem>
|
||||
#include <QTemporaryFile>
|
||||
#include <QWebEngineHistory>
|
||||
#include <QFileDialog>
|
||||
|
||||
#include <QStandardPaths>
|
||||
|
||||
#if QTWEBENGINE_DISABLED
|
||||
|
||||
DownloadFileHelper::DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog)
|
||||
: QObject()
|
||||
, m_lastDownloadOption(DownloadManager::SaveFile)
|
||||
, m_lastDownloadPath(lastDownloadPath)
|
||||
, m_downloadPath(downloadPath)
|
||||
, m_useNativeDialog(useNativeDialog)
|
||||
, m_timer(0)
|
||||
, m_reply(0)
|
||||
, m_fileSize(0)
|
||||
, m_openFileChoosed(false)
|
||||
, m_listWidget(0)
|
||||
, m_iconProvider(new QFileIconProvider)
|
||||
, m_manager(0)
|
||||
{
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//// Getting where to download requested file
|
||||
//// in 3 functions, as we are using non blocking
|
||||
//// dialogs ( this is important to make secure downloading
|
||||
//// on Windows working properly )
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
void DownloadFileHelper::handleUnsupportedContent(QNetworkReply* reply, const DownloadManager::DownloadInfo &info)
|
||||
{
|
||||
m_timer = new QTime();
|
||||
m_timer->start();
|
||||
m_h_fileName = info.suggestedFileName.isEmpty() ? getFileName(reply) : info.suggestedFileName;
|
||||
m_reply = reply;
|
||||
|
||||
QFileInfo fileInfo(m_h_fileName);
|
||||
QTemporaryFile tempFile(DataPaths::path(DataPaths::Temp) + "/XXXXXX." + fileInfo.suffix());
|
||||
tempFile.open();
|
||||
tempFile.write(m_reply->peek(1024 * 1024));
|
||||
QFileInfo tempInfo(tempFile.fileName());
|
||||
m_fileIcon = m_iconProvider->icon(tempInfo).pixmap(30, 30);
|
||||
QString mimeType = m_iconProvider->type(tempInfo);
|
||||
|
||||
m_fileSize = m_reply->header(QNetworkRequest::ContentLengthHeader).toLongLong();
|
||||
if (m_fileSize > 0) {
|
||||
mimeType.append(QString(" (%1)").arg(QzTools::fileSizeToString(m_fileSize)));
|
||||
}
|
||||
|
||||
// Close Empty Tab
|
||||
if (info.page) {
|
||||
WebView* view = qobject_cast<WebView*>(info.page->view());
|
||||
if (!info.page->url().isEmpty()) {
|
||||
m_downloadPage = info.page->url();
|
||||
}
|
||||
else if (info.page->history()->canGoBack()) {
|
||||
m_downloadPage = info.page->history()->backItem().url();
|
||||
}
|
||||
else if (view && info.page->history()->count() == 0) {
|
||||
view->closeView();
|
||||
}
|
||||
}
|
||||
|
||||
if (info.askWhatToDo && m_downloadPath.isEmpty()) {
|
||||
DownloadOptionsDialog* dialog = new DownloadOptionsDialog(m_h_fileName, m_fileIcon, mimeType, reply->url(), mApp->activeWindow());
|
||||
dialog->showExternalManagerOption(m_manager->useExternalManager());
|
||||
dialog->setLastDownloadOption(m_lastDownloadOption);
|
||||
dialog->show();
|
||||
|
||||
connect(dialog, SIGNAL(dialogFinished(int)), this, SLOT(optionsDialogAccepted(int)));
|
||||
}
|
||||
else if (info.forceChoosingPath) {
|
||||
optionsDialogAccepted(4);
|
||||
}
|
||||
else if (m_manager->useExternalManager()) {
|
||||
optionsDialogAccepted(3);
|
||||
}
|
||||
else {
|
||||
optionsDialogAccepted(2);
|
||||
}
|
||||
}
|
||||
|
||||
QString DownloadFileHelper::parseContentDisposition(const QByteArray &header)
|
||||
{
|
||||
QString path;
|
||||
|
||||
if (header.isEmpty()) {
|
||||
return path;
|
||||
}
|
||||
|
||||
QString value;
|
||||
|
||||
if (QzTools::isUtf8(header.constData())) {
|
||||
value = QString::fromUtf8(header);
|
||||
}
|
||||
else {
|
||||
value = QString::fromLatin1(header);
|
||||
}
|
||||
|
||||
// We try to use UTF-8 encoded filename first if present
|
||||
if (value.contains(QzRegExp("[ ;]{1,}filename*\\*\\s*=\\s*UTF-8''", Qt::CaseInsensitive))) {
|
||||
QzRegExp reg("filename\\s*\\*\\s*=\\s*UTF-8''([^;]*)", Qt::CaseInsensitive);
|
||||
reg.indexIn(value);
|
||||
path = QUrl::fromPercentEncoding(reg.cap(1).toUtf8()).trimmed();
|
||||
}
|
||||
else if (value.contains(QzRegExp("[ ;]{1,}filename\\s*=", Qt::CaseInsensitive))) {
|
||||
QzRegExp reg("[ ;]{1,}filename\\s*=(.*)", Qt::CaseInsensitive);
|
||||
reg.indexIn(value);
|
||||
path = reg.cap(1).trimmed();
|
||||
|
||||
// Parse filename in quotes (to support semicolon inside filename)
|
||||
if (path.startsWith(QLatin1Char('"')) && path.count(QLatin1Char('"')) > 1) {
|
||||
int pos = path.indexOf(QLatin1Char('"'), 1);
|
||||
while (pos != -1) {
|
||||
if (path[pos - 1] != QLatin1Char('\\')) {
|
||||
// We also need to strip starting quote
|
||||
path = path.left(pos).mid(1);
|
||||
break;
|
||||
}
|
||||
pos = path.indexOf(QLatin1Char('"'), pos + 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
QzRegExp reg("([^;]*)", Qt::CaseInsensitive);
|
||||
reg.indexIn(path);
|
||||
path = reg.cap(1).trimmed();
|
||||
}
|
||||
|
||||
if (path.startsWith(QLatin1Char('"')) && path.endsWith(QLatin1Char('"'))) {
|
||||
path = path.mid(1, path.length() - 2);
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
void DownloadFileHelper::optionsDialogAccepted(int finish)
|
||||
{
|
||||
bool forceChoosingPath = false;
|
||||
m_openFileChoosed = false;
|
||||
|
||||
switch (finish) {
|
||||
case 0: // Cancelled
|
||||
delete m_timer;
|
||||
|
||||
m_reply->abort();
|
||||
m_reply->deleteLater();
|
||||
|
||||
return;
|
||||
|
||||
case 1: // Open
|
||||
m_openFileChoosed = true;
|
||||
m_lastDownloadOption = DownloadManager::OpenFile;
|
||||
break;
|
||||
|
||||
case 2: // Save
|
||||
m_lastDownloadOption = DownloadManager::SaveFile;
|
||||
break;
|
||||
|
||||
case 3: // External manager
|
||||
m_manager->startExternalManager(m_reply->url());
|
||||
m_reply->abort();
|
||||
m_reply->deleteLater();
|
||||
return;
|
||||
|
||||
case 4: // Force opening save file dialog
|
||||
m_lastDownloadOption = DownloadManager::SaveFile;
|
||||
forceChoosingPath = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
qWarning() << "DownloadFileHelper::optionsDialogAccepted invalid return value!";
|
||||
delete m_timer;
|
||||
|
||||
m_reply->abort();
|
||||
m_reply->deleteLater();
|
||||
return;
|
||||
}
|
||||
|
||||
m_manager->setLastDownloadOption(m_lastDownloadOption);
|
||||
|
||||
if (!m_openFileChoosed) {
|
||||
if (m_downloadPath.isEmpty() || forceChoosingPath) {
|
||||
if (m_useNativeDialog) {
|
||||
fileNameChoosed(QFileDialog::getSaveFileName(mApp->getWindow(), tr("Save file as..."), m_lastDownloadPath + m_h_fileName));
|
||||
}
|
||||
else {
|
||||
QFileDialog* dialog = new QFileDialog(mApp->getWindow());
|
||||
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
dialog->setWindowTitle(tr("Save file as..."));
|
||||
dialog->setAcceptMode(QFileDialog::AcceptSave);
|
||||
dialog->setDirectory(m_lastDownloadPath);
|
||||
dialog->selectFile(m_h_fileName);
|
||||
|
||||
QList<QUrl> urls;
|
||||
urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::HomeLocation))
|
||||
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation))
|
||||
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation))
|
||||
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation))
|
||||
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation))
|
||||
<< QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation));
|
||||
dialog->setSidebarUrls(urls);
|
||||
|
||||
dialog->open();
|
||||
connect(dialog, SIGNAL(fileSelected(QString)), this, SLOT(fileNameChoosed(QString)));
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileNameChoosed(m_downloadPath + QLatin1Char('/') + m_h_fileName, true);
|
||||
}
|
||||
}
|
||||
else {
|
||||
fileNameChoosed(DataPaths::path(DataPaths::Temp) + QLatin1Char('/') + m_h_fileName, true);
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadFileHelper::fileNameChoosed(const QString &name, bool fileNameAutoGenerated)
|
||||
{
|
||||
m_userFileName = name.trimmed();
|
||||
|
||||
if (m_userFileName.isEmpty()) {
|
||||
m_reply->abort();
|
||||
m_reply->deleteLater();
|
||||
|
||||
delete m_timer;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
int pos = m_userFileName.lastIndexOf(QLatin1Char('/'));
|
||||
if (pos != -1) {
|
||||
int size = m_userFileName.size();
|
||||
m_path = m_userFileName.left(pos + 1);
|
||||
m_fileName = m_userFileName.right(size - pos - 1);
|
||||
}
|
||||
|
||||
if (fileNameAutoGenerated) {
|
||||
m_fileName = QzTools::ensureUniqueFilename(m_fileName);
|
||||
}
|
||||
|
||||
if (!m_path.contains(DataPaths::path(DataPaths::Temp))) {
|
||||
m_lastDownloadPath = m_path;
|
||||
}
|
||||
|
||||
Settings settings;
|
||||
settings.beginGroup("DownloadManager");
|
||||
settings.setValue("lastDownloadPath", m_lastDownloadPath);
|
||||
settings.endGroup();
|
||||
m_manager->setLastDownloadPath(m_lastDownloadPath);
|
||||
|
||||
QListWidgetItem* item = new QListWidgetItem(m_listWidget);
|
||||
DownloadItem* downItem = new DownloadItem(item, m_reply, m_path, m_fileName, m_fileIcon, m_timer, m_openFileChoosed, m_downloadPage, m_manager);
|
||||
downItem->setTotalSize(m_fileSize);
|
||||
|
||||
emit itemCreated(item, downItem);
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////
|
||||
//// End here
|
||||
//////////////////////////////////////////////////////
|
||||
|
||||
QString DownloadFileHelper::getFileName(QNetworkReply* reply)
|
||||
{
|
||||
QString path = parseContentDisposition(reply->rawHeader("Content-Disposition"));
|
||||
|
||||
if (path.isEmpty()) {
|
||||
path = reply->url().path();
|
||||
}
|
||||
|
||||
QFileInfo info(path);
|
||||
QString baseName = info.completeBaseName();
|
||||
QString endName = info.suffix();
|
||||
|
||||
if (baseName.isEmpty()) {
|
||||
baseName = tr("NoNameDownload");
|
||||
}
|
||||
|
||||
if (!endName.isEmpty()) {
|
||||
endName.prepend(QLatin1Char('.'));
|
||||
}
|
||||
|
||||
QString name = baseName + endName;
|
||||
|
||||
if (name.contains(QLatin1Char('"'))) {
|
||||
name.remove(QLatin1String("\";"));
|
||||
}
|
||||
|
||||
return QzTools::filterCharsFromFilename(name);
|
||||
}
|
||||
|
||||
DownloadFileHelper::~DownloadFileHelper()
|
||||
{
|
||||
delete m_iconProvider;
|
||||
}
|
||||
|
||||
#endif
|
@ -1,85 +0,0 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* ============================================================ */
|
||||
#ifndef DOWNLOADFILEHELPER_H
|
||||
#define DOWNLOADFILEHELPER_H
|
||||
|
||||
#if QTWEBENGINE_DISABLED
|
||||
|
||||
#include <QObject>
|
||||
#include <QPixmap>
|
||||
#include <QUrl>
|
||||
|
||||
#include "qzcommon.h"
|
||||
#include "downloadmanager.h"
|
||||
|
||||
class QFileIconProvider;
|
||||
class QListWidget;
|
||||
|
||||
class DownloadItem;
|
||||
class DownloadManager;
|
||||
class WebPage;
|
||||
|
||||
class QUPZILLA_EXPORT DownloadFileHelper : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit DownloadFileHelper(const QString &lastDownloadPath, const QString &downloadPath, bool useNativeDialog);
|
||||
~DownloadFileHelper();
|
||||
|
||||
void setListWidget(QListWidget* tw) { m_listWidget = tw; }
|
||||
void setDownloadManager(DownloadManager* m) { m_manager = m; }
|
||||
void setLastDownloadOption(const DownloadManager::DownloadOption &option) { m_lastDownloadOption = option; }
|
||||
|
||||
void handleUnsupportedContent(QNetworkReply* reply, const DownloadManager::DownloadInfo &info);
|
||||
|
||||
static QString parseContentDisposition(const QByteArray &header);
|
||||
|
||||
signals:
|
||||
void itemCreated(QListWidgetItem* item, DownloadItem* downItem);
|
||||
|
||||
private slots:
|
||||
void optionsDialogAccepted(int finish = -1);
|
||||
void fileNameChoosed(const QString &name, bool fileNameAutoGenerated = false);
|
||||
|
||||
private:
|
||||
QString getFileName(QNetworkReply* reply);
|
||||
|
||||
DownloadManager::DownloadOption m_lastDownloadOption;
|
||||
QString m_lastDownloadPath;
|
||||
QString m_downloadPath;
|
||||
bool m_useNativeDialog;
|
||||
|
||||
QTime* m_timer;
|
||||
QString m_path;
|
||||
QString m_fileName;
|
||||
QString m_userFileName;
|
||||
QString m_h_fileName;
|
||||
QNetworkReply* m_reply;
|
||||
QPixmap m_fileIcon;
|
||||
QUrl m_downloadPage;
|
||||
qint64 m_fileSize;
|
||||
bool m_openFileChoosed;
|
||||
|
||||
QListWidget* m_listWidget;
|
||||
QFileIconProvider* m_iconProvider;
|
||||
DownloadManager* m_manager;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // DOWNLOADFILEHELPER_H
|
@ -43,7 +43,7 @@
|
||||
|
||||
//#define DOWNMANAGER_DEBUG
|
||||
|
||||
DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadItem* downloadItem, const QString &path, const QString &fileName, DownloadManager* manager)
|
||||
DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadItem* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager)
|
||||
: QWidget()
|
||||
, ui(new Ui::DownloadItem)
|
||||
, m_item(item)
|
||||
@ -51,6 +51,7 @@ DownloadItem::DownloadItem(QListWidgetItem *item, QWebEngineDownloadItem* downlo
|
||||
, m_path(path)
|
||||
, m_fileName(fileName)
|
||||
, m_downUrl(downloadItem->url())
|
||||
, m_openFile(openFile)
|
||||
, m_validIcon(false)
|
||||
, m_downloading(false)
|
||||
, m_downloadStopped(false)
|
||||
@ -122,10 +123,12 @@ void DownloadItem::finished()
|
||||
qDebug() << __FUNCTION__ << m_reply;
|
||||
#endif
|
||||
|
||||
bool success = false;
|
||||
QString host = m_download->url().host();
|
||||
|
||||
switch (m_download->state()) {
|
||||
case QWebEngineDownloadItem::DownloadCompleted:
|
||||
success = true;
|
||||
ui->downloadInfo->setText(tr("Done - %1 (%2)").arg(host, QDateTime::currentDateTime().toString(Qt::DefaultLocaleShortDate)));
|
||||
break;
|
||||
|
||||
@ -148,6 +151,9 @@ void DownloadItem::finished()
|
||||
m_item->setSizeHint(sizeHint());
|
||||
m_downloading = false;
|
||||
|
||||
if (success && m_openFile)
|
||||
openFile();
|
||||
|
||||
emit downloadFinished(true);
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@ class QUPZILLA_EXPORT DownloadItem : public QWidget
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DownloadItem(QListWidgetItem* item, QWebEngineDownloadItem* downloadItem, const QString &path, const QString &fileName, DownloadManager* manager);
|
||||
explicit DownloadItem(QListWidgetItem* item, QWebEngineDownloadItem* downloadItem, const QString &path, const QString &fileName, bool openFile, DownloadManager* manager);
|
||||
bool isDownloading() { return m_downloading; }
|
||||
bool isCancelled();
|
||||
QTime remainingTime() { return m_remTime; }
|
||||
@ -86,6 +86,7 @@ private:
|
||||
QTime m_remTime;
|
||||
QBasicTimer m_timer;
|
||||
QUrl m_downUrl;
|
||||
bool m_openFile;
|
||||
bool m_validIcon;
|
||||
|
||||
bool m_downloading;
|
||||
|
@ -28,8 +28,8 @@
|
||||
#include "qztools.h"
|
||||
#include "webpage.h"
|
||||
#include "webview.h"
|
||||
#include "downloadfilehelper.h"
|
||||
#include "settings.h"
|
||||
#include "datapaths.h"
|
||||
|
||||
#include <QMessageBox>
|
||||
#include <QCloseEvent>
|
||||
@ -90,10 +90,6 @@ void DownloadManager::loadSettings()
|
||||
if (!m_externalArguments.contains(QLatin1String("%d"))) {
|
||||
m_externalArguments.append(QLatin1String(" %d"));
|
||||
}
|
||||
|
||||
if (m_downloadPath.isEmpty()) {
|
||||
m_downloadPath = QStandardPaths::writableLocation(QStandardPaths::DownloadLocation);
|
||||
}
|
||||
}
|
||||
|
||||
void DownloadManager::show()
|
||||
@ -216,21 +212,53 @@ void DownloadManager::clearList()
|
||||
|
||||
void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
|
||||
{
|
||||
if (m_useExternalManager) {
|
||||
startExternalManager(downloadItem->url());
|
||||
QString downloadPath;
|
||||
bool openFile = false;
|
||||
|
||||
QString fileName = QFileInfo(downloadItem->path()).fileName();
|
||||
|
||||
if (m_downloadPath.isEmpty()) {
|
||||
// Ask what to do
|
||||
DownloadOptionsDialog optionsDialog(fileName, downloadItem->url(), mApp->activeWindow());
|
||||
optionsDialog.showExternalManagerOption(m_useExternalManager);
|
||||
optionsDialog.setLastDownloadOption(m_lastDownloadOption);
|
||||
|
||||
switch (optionsDialog.exec()) {
|
||||
case 1: // Open
|
||||
openFile = true;
|
||||
downloadPath = QzTools::ensureUniqueFilename(DataPaths::path(DataPaths::Temp) + QLatin1Char('/') + fileName);
|
||||
m_lastDownloadOption = OpenFile;
|
||||
break;
|
||||
|
||||
case 2: // Save
|
||||
downloadPath = QFileDialog::getSaveFileName(mApp->activeWindow(), tr("Save file as..."), m_lastDownloadPath + fileName);
|
||||
m_lastDownloadOption = SaveFile;
|
||||
break;
|
||||
|
||||
case 3: // External manager
|
||||
startExternalManager(downloadItem->url());
|
||||
// fallthrough
|
||||
|
||||
default:
|
||||
downloadItem->cancel();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
downloadPath = QzTools::ensureUniqueFilename(m_downloadPath + QL1C('/') + fileName);
|
||||
}
|
||||
|
||||
if (downloadPath.isEmpty()) {
|
||||
downloadItem->cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
QString fileName = QFileInfo(downloadItem->path()).fileName();
|
||||
|
||||
// Set download path and accept
|
||||
downloadItem->setPath(QzTools::ensureUniqueFilename(QSL("%1/%2").arg(m_downloadPath, fileName)));
|
||||
downloadItem->setPath(downloadPath);
|
||||
downloadItem->accept();
|
||||
|
||||
// Create download item
|
||||
QListWidgetItem* listItem = new QListWidgetItem(ui->list);
|
||||
DownloadItem* downItem = new DownloadItem(listItem, downloadItem, m_downloadPath, fileName, this);
|
||||
DownloadItem* downItem = new DownloadItem(listItem, downloadItem, QFileInfo(downloadPath).absolutePath(), fileName, openFile, this);
|
||||
connect(downItem, SIGNAL(deleteItem(DownloadItem*)), this, SLOT(deleteItem(DownloadItem*)));
|
||||
connect(downItem, SIGNAL(downloadFinished(bool)), this, SLOT(downloadFinished(bool)));
|
||||
ui->list->setItemWidget(listItem, downItem);
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
#include <QClipboard>
|
||||
|
||||
DownloadOptionsDialog::DownloadOptionsDialog(const QString &fileName, const QPixmap &fileIcon, const QString &mimeType, const QUrl &url, QWidget* parent)
|
||||
DownloadOptionsDialog::DownloadOptionsDialog(const QString &fileName, const QUrl &url, QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, ui(new Ui::DownloadOptionsDialog)
|
||||
, m_url(url)
|
||||
@ -29,8 +29,6 @@ DownloadOptionsDialog::DownloadOptionsDialog(const QString &fileName, const QPix
|
||||
ui->setupUi(this);
|
||||
|
||||
ui->fileName->setText("<b>" + fileName + "</b>");
|
||||
ui->fileIcon->setPixmap(fileIcon);
|
||||
ui->fileType->setText(mimeType);
|
||||
ui->fromServer->setText(url.host());
|
||||
setWindowTitle(tr("Opening %1").arg(fileName));
|
||||
|
||||
|
@ -34,7 +34,7 @@ class QUPZILLA_EXPORT DownloadOptionsDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DownloadOptionsDialog(const QString &fileName, const QPixmap &fileIcon, const QString &mimeType, const QUrl &url, QWidget* parent = 0);
|
||||
explicit DownloadOptionsDialog(const QString &fileName, const QUrl &url, QWidget* parent = 0);
|
||||
~DownloadOptionsDialog();
|
||||
|
||||
void showExternalManagerOption(bool show);
|
||||
|
@ -26,34 +26,14 @@
|
||||
<string>Opening</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="2" column="1" colspan="2">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>which is a:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLabel" name="fileType">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>You have chosen to open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="0" colspan="3">
|
||||
<item row="4" column="0" colspan="3">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>What should QupZilla do with this file?</string>
|
||||
@ -102,10 +82,39 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1" colspan="2">
|
||||
<item row="5" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" colspan="3">
|
||||
<widget class="SqueezeLabelV2" name="fileName">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="0" colspan="3">
|
||||
<widget class="QFrame" name="fromFrame">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<property name="margin">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item>
|
||||
@ -153,46 +162,6 @@
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="0" colspan="3">
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="standardButtons">
|
||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="0" column="0" colspan="3">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>You have chosen to open</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0" rowspan="3">
|
||||
<widget class="QLabel" name="fileIcon">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="1" colspan="2">
|
||||
<widget class="SqueezeLabelV2" name="fileName">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::LinksAccessibleByMouse|Qt::TextSelectableByMouse</set>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
|
@ -105,7 +105,6 @@ SOURCES += \
|
||||
bookmarks/bookmarkswidget.cpp \
|
||||
cookies/cookiejar.cpp \
|
||||
cookies/cookiemanager.cpp \
|
||||
#downloads/downloadfilehelper.cpp \
|
||||
downloads/downloaditem.cpp \
|
||||
downloads/downloadmanager.cpp \
|
||||
downloads/downloadoptionsdialog.cpp \
|
||||
@ -135,7 +134,7 @@ SOURCES += \
|
||||
network/pac/pacmanager.cpp \
|
||||
network/pac/proxyautoconfig.cpp \
|
||||
network/schemehandlers/adblockschemehandler.cpp \
|
||||
network/schemehandlers/fileschemehandler.cpp \
|
||||
#network/schemehandlers/fileschemehandler.cpp \
|
||||
#network/schemehandlers/ftpschemehandler.cpp \
|
||||
network/schemehandlers/qupzillaschemehandler.cpp \
|
||||
network/sslerrordialog.cpp \
|
||||
@ -300,7 +299,6 @@ HEADERS += \
|
||||
bookmarks/bookmarkswidget.h \
|
||||
cookies/cookiejar.h \
|
||||
cookies/cookiemanager.h \
|
||||
#downloads/downloadfilehelper.h \
|
||||
downloads/downloaditem.h \
|
||||
downloads/downloadmanager.h \
|
||||
downloads/downloadoptionsdialog.h \
|
||||
@ -331,7 +329,7 @@ HEADERS += \
|
||||
network/pac/pacmanager.h \
|
||||
network/pac/proxyautoconfig.h \
|
||||
network/schemehandlers/adblockschemehandler.h \
|
||||
network/schemehandlers/fileschemehandler.h \
|
||||
#network/schemehandlers/fileschemehandler.h \
|
||||
#network/schemehandlers/ftpschemehandler.h \
|
||||
network/schemehandlers/qupzillaschemehandler.h \
|
||||
network/schemehandlers/schemehandler.h \
|
||||
|
@ -36,7 +36,6 @@
|
||||
#include "delayedfilewatcher.h"
|
||||
#include "searchenginesmanager.h"
|
||||
#include "html5permissions/html5permissionsmanager.h"
|
||||
#include "schemehandlers/fileschemehandler.h"
|
||||
#include "javascript/externaljsobject.h"
|
||||
#include "tabwidget.h"
|
||||
#include "scripts.h"
|
||||
|
Loading…
Reference in New Issue
Block a user