mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 18:56:34 +01:00
DownloadOptionsDialog: Show download mime type and icon
This commit is contained in:
parent
c785e09bdf
commit
fcc356e4df
@ -224,7 +224,7 @@ void DownloadManager::download(QWebEngineDownloadItem *downloadItem)
|
|||||||
result = SavePage;
|
result = SavePage;
|
||||||
} else {
|
} else {
|
||||||
// Ask what to do
|
// Ask what to do
|
||||||
DownloadOptionsDialog optionsDialog(fileName, downloadItem->url(), mApp->activeWindow());
|
DownloadOptionsDialog optionsDialog(fileName, downloadItem, mApp->activeWindow());
|
||||||
optionsDialog.showExternalManagerOption(m_useExternalManager);
|
optionsDialog.showExternalManagerOption(m_useExternalManager);
|
||||||
optionsDialog.setLastDownloadOption(m_lastDownloadOption);
|
optionsDialog.setLastDownloadOption(m_lastDownloadOption);
|
||||||
result = Result(optionsDialog.exec());
|
result = Result(optionsDialog.exec());
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - Qt web browser
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -17,22 +17,36 @@
|
|||||||
* ============================================================ */
|
* ============================================================ */
|
||||||
#include "downloadoptionsdialog.h"
|
#include "downloadoptionsdialog.h"
|
||||||
#include "ui_downloadoptionsdialog.h"
|
#include "ui_downloadoptionsdialog.h"
|
||||||
|
#include "iconprovider.h"
|
||||||
|
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QMimeDatabase>
|
||||||
|
#include <QWebEngineDownloadItem>
|
||||||
|
|
||||||
DownloadOptionsDialog::DownloadOptionsDialog(const QString &fileName, const QUrl &url, QWidget *parent)
|
DownloadOptionsDialog::DownloadOptionsDialog(const QString &fileName, QWebEngineDownloadItem *downloadItem, QWidget *parent)
|
||||||
: QDialog(parent)
|
: QDialog(parent)
|
||||||
, ui(new Ui::DownloadOptionsDialog)
|
, ui(new Ui::DownloadOptionsDialog)
|
||||||
, m_url(url)
|
, m_downloadItem(downloadItem)
|
||||||
, m_signalEmited(false)
|
, m_signalEmited(false)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
|
|
||||||
ui->fileName->setText("<b>" + fileName + "</b>");
|
ui->fileName->setText("<b>" + fileName + "</b>");
|
||||||
ui->fromServer->setText(url.host());
|
ui->fromServer->setText(m_downloadItem->url().host());
|
||||||
setWindowTitle(tr("Opening %1").arg(fileName));
|
|
||||||
|
|
||||||
setFixedHeight(sizeHint().height());
|
const QIcon fileIcon = IconProvider::instance()->standardIcon(QStyle::SP_FileIcon);
|
||||||
|
|
||||||
|
QMimeDatabase db;
|
||||||
|
const QMimeType mime = db.mimeTypeForName(downloadItem->mimeType());
|
||||||
|
if (mime.isValid() && !mime.isDefault()) {
|
||||||
|
ui->mimeName->setText(mime.comment());
|
||||||
|
ui->iconLabel->setPixmap(QIcon::fromTheme(mime.iconName(), fileIcon).pixmap(22));
|
||||||
|
} else {
|
||||||
|
ui->mimeFrame->hide();
|
||||||
|
ui->iconLabel->setPixmap(fileIcon.pixmap(22));
|
||||||
|
}
|
||||||
|
|
||||||
|
setWindowTitle(tr("Opening %1").arg(fileName));
|
||||||
|
|
||||||
ui->buttonBox->setFocus();
|
ui->buttonBox->setFocus();
|
||||||
|
|
||||||
@ -93,7 +107,7 @@ int DownloadOptionsDialog::exec()
|
|||||||
|
|
||||||
void DownloadOptionsDialog::copyDownloadLink()
|
void DownloadOptionsDialog::copyDownloadLink()
|
||||||
{
|
{
|
||||||
QApplication::clipboard()->setText(m_url.toString());
|
QApplication::clipboard()->setText(m_downloadItem->url().toString());
|
||||||
ui->copyDownloadLink->setText(tr("Download link copied."));
|
ui->copyDownloadLink->setText(tr("Download link copied."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/* ============================================================
|
/* ============================================================
|
||||||
* QupZilla - WebKit based browser
|
* QupZilla - Qt web browser
|
||||||
* Copyright (C) 2010-2014 David Rosca <nowrep@gmail.com>
|
* Copyright (C) 2010-2017 David Rosca <nowrep@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -29,12 +29,14 @@ namespace Ui
|
|||||||
class DownloadOptionsDialog;
|
class DownloadOptionsDialog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class QWebEngineDownloadItem;
|
||||||
|
|
||||||
class QUPZILLA_EXPORT DownloadOptionsDialog : public QDialog
|
class QUPZILLA_EXPORT DownloadOptionsDialog : public QDialog
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit DownloadOptionsDialog(const QString &fileName, const QUrl &url, QWidget* parent = 0);
|
explicit DownloadOptionsDialog(const QString &fileName, QWebEngineDownloadItem *downloadItem, QWidget* parent = 0);
|
||||||
~DownloadOptionsDialog();
|
~DownloadOptionsDialog();
|
||||||
|
|
||||||
void showExternalManagerOption(bool show);
|
void showExternalManagerOption(bool show);
|
||||||
@ -54,7 +56,7 @@ signals:
|
|||||||
private:
|
private:
|
||||||
Ui::DownloadOptionsDialog* ui;
|
Ui::DownloadOptionsDialog* ui;
|
||||||
|
|
||||||
QUrl m_url;
|
QWebEngineDownloadItem *m_downloadItem;
|
||||||
bool m_signalEmited;
|
bool m_signalEmited;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -2,38 +2,24 @@
|
|||||||
<ui version="4.0">
|
<ui version="4.0">
|
||||||
<class>DownloadOptionsDialog</class>
|
<class>DownloadOptionsDialog</class>
|
||||||
<widget class="QDialog" name="DownloadOptionsDialog">
|
<widget class="QDialog" name="DownloadOptionsDialog">
|
||||||
<property name="geometry">
|
|
||||||
<rect>
|
|
||||||
<x>0</x>
|
|
||||||
<y>0</y>
|
|
||||||
<width>410</width>
|
|
||||||
<height>267</height>
|
|
||||||
</rect>
|
|
||||||
</property>
|
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
<width>410</width>
|
<width>400</width>
|
||||||
<height>0</height>
|
<height>0</height>
|
||||||
</size>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="maximumSize">
|
|
||||||
<size>
|
|
||||||
<width>410</width>
|
|
||||||
<height>16777215</height>
|
|
||||||
</size>
|
|
||||||
</property>
|
|
||||||
<property name="windowTitle">
|
|
||||||
<string>Opening</string>
|
|
||||||
</property>
|
|
||||||
<layout class="QGridLayout" name="gridLayout_2">
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
<item row="0" column="0" colspan="3">
|
<item row="9" column="0" colspan="3">
|
||||||
<widget class="QLabel" name="label">
|
<widget class="QDialogButtonBox" name="buttonBox">
|
||||||
<property name="text">
|
<property name="orientation">
|
||||||
<string>You have chosen to open</string>
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="standardButtons">
|
||||||
|
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="3">
|
<item row="7" column="0" colspan="3">
|
||||||
<widget class="QGroupBox" name="groupBox">
|
<widget class="QGroupBox" name="groupBox">
|
||||||
<property name="title">
|
<property name="title">
|
||||||
<string>What should QupZilla do with this file?</string>
|
<string>What should QupZilla do with this file?</string>
|
||||||
@ -82,17 +68,49 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="3">
|
<item row="3" column="0" colspan="3">
|
||||||
<widget class="QDialogButtonBox" name="buttonBox">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout_3">
|
||||||
|
<property name="spacing">
|
||||||
|
<number>7</number>
|
||||||
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_4">
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="standardButtons">
|
<property name="sizeType">
|
||||||
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>8</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="iconLabel">
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
<property name="maximumSize">
|
||||||
|
<size>
|
||||||
|
<width>24</width>
|
||||||
|
<height>24</height>
|
||||||
|
</size>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="0" colspan="3">
|
<item>
|
||||||
<widget class="SqueezeLabelV2" name="fileName">
|
<widget class="SqueezeLabelV2" name="fileName">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
@ -102,7 +120,59 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="2" column="0" colspan="3">
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QFrame" name="mimeFrame">
|
||||||
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
|
<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>
|
||||||
|
<spacer name="horizontalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="label_5">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>which is:</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="mimeName"/>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
<widget class="QFrame" name="fromFrame">
|
<widget class="QFrame" name="fromFrame">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||||
<property name="leftMargin">
|
<property name="leftMargin">
|
||||||
@ -117,10 +187,26 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
|
<item>
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Fixed</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="label_3">
|
<widget class="QLabel" name="label_3">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Preferred">
|
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
@ -163,6 +249,29 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
</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="8" column="0">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="4" column="1">
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
<customwidgets>
|
<customwidgets>
|
||||||
<customwidget>
|
<customwidget>
|
||||||
|
Loading…
Reference in New Issue
Block a user