Fixed #65.
This commit is contained in:
parent
183960452e
commit
e5f0246566
@ -5,7 +5,7 @@ Fixed:
|
|||||||
<ul>
|
<ul>
|
||||||
<li>Fixed issue #53 - removing of duplicate messages. Feature is available globally in "Settings -> Messages".</li>
|
<li>Fixed issue #53 - removing of duplicate messages. Feature is available globally in "Settings -> Messages".</li>
|
||||||
<li>Fixed issue #100 - saving HTML web pages.</li>
|
<li>Fixed issue #100 - saving HTML web pages.</li>
|
||||||
<li>Fixed runtime issue #106.</li>
|
<li>Fixed issues #106, #65.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="fileIcon">
|
<widget class="QLabel" name="m_lblFileIcon">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -25,7 +25,7 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QProgressBar" name="progressBar">
|
<widget class="QProgressBar" name="m_progressDownload">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -46,7 +46,7 @@
|
|||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="verticalLayout">
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="SqueezeLabel" name="m_fileNameLabel" native="true">
|
<widget class="SqueezeLabel" name="m_lblFilename" native="true">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
|
||||||
<horstretch>0</horstretch>
|
<horstretch>0</horstretch>
|
||||||
@ -74,7 +74,7 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="tryAgainButton">
|
<widget class="QToolButton" name="m_btnTryAgain">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
@ -84,21 +84,21 @@
|
|||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="stopButton">
|
<widget class="QToolButton" name="m_btnStopDownload">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Stop</string>
|
<string>&Stop</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="openButton">
|
<widget class="QToolButton" name="m_btnOpenFile">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&Open file</string>
|
<string>&Open file</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QToolButton" name="toolButton">
|
<widget class="QToolButton" name="m_btnOpenFolder">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Open &folder</string>
|
<string>Open &folder</string>
|
||||||
</property>
|
</property>
|
||||||
|
@ -45,11 +45,12 @@ DownloadItem::DownloadItem(QNetworkReply *reply, bool request_file_name, QWidget
|
|||||||
m_bytesReceived(0), m_requestFileName(request_file_name), m_startedSaving(false), m_finishedDownloading(false),
|
m_bytesReceived(0), m_requestFileName(request_file_name), m_startedSaving(false), m_finishedDownloading(false),
|
||||||
m_gettingFileName(false), m_canceledFileSelect(false) {
|
m_gettingFileName(false), m_canceledFileSelect(false) {
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->tryAgainButton->hide();
|
m_ui->m_btnTryAgain->hide();
|
||||||
|
|
||||||
connect(m_ui->stopButton, SIGNAL(clicked()), this, SLOT(stop()));
|
connect(m_ui->m_btnStopDownload, SIGNAL(clicked()), this, SLOT(stop()));
|
||||||
connect(m_ui->openButton, SIGNAL(clicked()), this, SLOT(openFile()));
|
connect(m_ui->m_btnOpenFile, SIGNAL(clicked()), this, SLOT(openFile()));
|
||||||
connect(m_ui->tryAgainButton, SIGNAL(clicked()), this, SLOT(tryAgain()));
|
connect(m_ui->m_btnTryAgain, SIGNAL(clicked()), this, SLOT(tryAgain()));
|
||||||
|
connect(m_ui->m_btnOpenFolder, SIGNAL(clicked()), this, SLOT(openFolder()));
|
||||||
|
|
||||||
if (!request_file_name) {
|
if (!request_file_name) {
|
||||||
m_requestFileName = qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::AlwaysPromptForFilename)).toBool();
|
m_requestFileName = qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::AlwaysPromptForFilename)).toBool();
|
||||||
@ -69,8 +70,8 @@ void DownloadItem::init() {
|
|||||||
|
|
||||||
m_startedSaving = false;
|
m_startedSaving = false;
|
||||||
m_finishedDownloading = false;
|
m_finishedDownloading = false;
|
||||||
m_ui->openButton->setEnabled(false);
|
m_ui->m_btnOpenFile->setEnabled(false);
|
||||||
m_ui->toolButton->setEnabled(false);
|
m_ui->m_btnOpenFolder->setEnabled(false);
|
||||||
m_url = m_reply->url();
|
m_url = m_reply->url();
|
||||||
m_reply->setParent(this);
|
m_reply->setParent(this);
|
||||||
|
|
||||||
@ -82,7 +83,7 @@ void DownloadItem::init() {
|
|||||||
|
|
||||||
// Reset info.
|
// Reset info.
|
||||||
m_ui->m_lblInfoDownload->clear();
|
m_ui->m_lblInfoDownload->clear();
|
||||||
m_ui->progressBar->setValue(0);
|
m_ui->m_progressDownload->setValue(0);
|
||||||
getFileName();
|
getFileName();
|
||||||
|
|
||||||
// Start timer for the download estimation.
|
// Start timer for the download estimation.
|
||||||
@ -111,8 +112,8 @@ void DownloadItem::getFileName() {
|
|||||||
if (chosen_filename.isEmpty()) {
|
if (chosen_filename.isEmpty()) {
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
m_ui->progressBar->setVisible(false);
|
m_ui->m_progressDownload->setVisible(false);
|
||||||
m_ui->m_fileNameLabel->setText(tr("Download for %1 cancelled").arg(QFileInfo(default_filename).fileName()));
|
m_ui->m_lblFilename->setText(tr("Download for %1 cancelled").arg(QFileInfo(default_filename).fileName()));
|
||||||
m_canceledFileSelect = true;
|
m_canceledFileSelect = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -120,7 +121,7 @@ void DownloadItem::getFileName() {
|
|||||||
QFileInfo file_info = QFileInfo(chosen_filename);
|
QFileInfo file_info = QFileInfo(chosen_filename);
|
||||||
|
|
||||||
qApp->downloadManager()->setDownloadDirectory(file_info.absoluteDir().absolutePath());
|
qApp->downloadManager()->setDownloadDirectory(file_info.absoluteDir().absolutePath());
|
||||||
m_ui->m_fileNameLabel->setText(file_info.fileName());
|
m_ui->m_lblFilename->setText(file_info.fileName());
|
||||||
}
|
}
|
||||||
|
|
||||||
m_output.setFileName(chosen_filename);
|
m_output.setFileName(chosen_filename);
|
||||||
@ -131,12 +132,12 @@ void DownloadItem::getFileName() {
|
|||||||
if (!save_dir.exists() && !save_dir.mkpath(save_dir.absolutePath())) {
|
if (!save_dir.exists() && !save_dir.mkpath(save_dir.absolutePath())) {
|
||||||
stop();
|
stop();
|
||||||
|
|
||||||
m_ui->progressBar->setVisible(false);
|
m_ui->m_progressDownload->setVisible(false);
|
||||||
m_ui->m_lblInfoDownload->setText(tr("Download directory %1 couldn't be created").arg(QDir::toNativeSeparators(save_dir.absolutePath())));
|
m_ui->m_lblInfoDownload->setText(tr("Download directory %1 couldn't be created").arg(QDir::toNativeSeparators(save_dir.absolutePath())));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_ui->m_fileNameLabel->setText(QFileInfo(m_output.fileName()).fileName());
|
m_ui->m_lblFilename->setText(QFileInfo(m_output.fileName()).fileName());
|
||||||
|
|
||||||
if (m_requestFileName) {
|
if (m_requestFileName) {
|
||||||
downloadReadyRead();
|
downloadReadyRead();
|
||||||
@ -191,35 +192,35 @@ QString DownloadItem::saveFileName(const QString &directory) const {
|
|||||||
void DownloadItem::stop()
|
void DownloadItem::stop()
|
||||||
{
|
{
|
||||||
setUpdatesEnabled(false);
|
setUpdatesEnabled(false);
|
||||||
m_ui->stopButton->setEnabled(false);
|
m_ui->m_btnStopDownload->setEnabled(false);
|
||||||
m_ui->stopButton->hide();
|
m_ui->m_btnStopDownload->hide();
|
||||||
m_ui->tryAgainButton->setEnabled(true);
|
m_ui->m_btnTryAgain->setEnabled(true);
|
||||||
m_ui->tryAgainButton->show();
|
m_ui->m_btnTryAgain->show();
|
||||||
setUpdatesEnabled(true);
|
setUpdatesEnabled(true);
|
||||||
m_reply->abort();
|
m_reply->abort();
|
||||||
emit downloadFinished();
|
emit downloadFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::openFile() {
|
void DownloadItem::openFile() {
|
||||||
QFileInfo info(m_output);
|
QDesktopServices::openUrl(QUrl::fromLocalFile(m_output.fileName()));
|
||||||
QUrl url = QUrl::fromLocalFile(info.absoluteFilePath());
|
|
||||||
|
|
||||||
QDesktopServices::openUrl(url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::openFolder() {
|
void DownloadItem::openFolder() {
|
||||||
// TODO: pouze na windows, otevrit explorer, jinde schovat tlacitko Open folder.
|
if (m_output.exists()) {
|
||||||
|
QString file = QDir::toNativeSeparators(m_output.fileName());
|
||||||
|
QProcess::startDetached(QString("explorer.exe /select, \"") + file + "\"");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::tryAgain() {
|
void DownloadItem::tryAgain() {
|
||||||
if (!m_ui->tryAgainButton->isEnabled())
|
if (!m_ui->m_btnTryAgain->isEnabled())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ui->tryAgainButton->setEnabled(false);
|
m_ui->m_btnTryAgain->setEnabled(false);
|
||||||
m_ui->tryAgainButton->setVisible(false);
|
m_ui->m_btnTryAgain->setVisible(false);
|
||||||
m_ui->stopButton->setEnabled(true);
|
m_ui->m_btnStopDownload->setEnabled(true);
|
||||||
m_ui->stopButton->setVisible(true);
|
m_ui->m_btnStopDownload->setVisible(true);
|
||||||
m_ui->progressBar->setVisible(true);
|
m_ui->m_progressDownload->setVisible(true);
|
||||||
|
|
||||||
QNetworkReply *r = qApp->downloadManager()->networkManager()->get(QNetworkRequest(m_url));
|
QNetworkReply *r = qApp->downloadManager()->networkManager()->get(QNetworkRequest(m_url));
|
||||||
if (m_reply)
|
if (m_reply)
|
||||||
@ -251,7 +252,7 @@ void DownloadItem::downloadReadyRead()
|
|||||||
if (-1 == m_output.write(m_reply->readAll())) {
|
if (-1 == m_output.write(m_reply->readAll())) {
|
||||||
m_ui->m_lblInfoDownload->setText(tr("Error saving: %1")
|
m_ui->m_lblInfoDownload->setText(tr("Error saving: %1")
|
||||||
.arg(m_output.errorString()));
|
.arg(m_output.errorString()));
|
||||||
m_ui->stopButton->click();
|
m_ui->m_btnStopDownload->click();
|
||||||
} else {
|
} else {
|
||||||
m_startedSaving = true;
|
m_startedSaving = true;
|
||||||
if (m_finishedDownloading)
|
if (m_finishedDownloading)
|
||||||
@ -262,8 +263,8 @@ void DownloadItem::downloadReadyRead()
|
|||||||
void DownloadItem::error(QNetworkReply::NetworkError)
|
void DownloadItem::error(QNetworkReply::NetworkError)
|
||||||
{
|
{
|
||||||
m_ui->m_lblInfoDownload->setText(tr("Error: %1").arg(m_reply->errorString()));
|
m_ui->m_lblInfoDownload->setText(tr("Error: %1").arg(m_reply->errorString()));
|
||||||
m_ui->tryAgainButton->setEnabled(true);
|
m_ui->m_btnTryAgain->setEnabled(true);
|
||||||
m_ui->tryAgainButton->setVisible(true);
|
m_ui->m_btnTryAgain->setVisible(true);
|
||||||
|
|
||||||
emit downloadFinished();
|
emit downloadFinished();
|
||||||
}
|
}
|
||||||
@ -294,8 +295,8 @@ void DownloadItem::downloadProgress(qint64 bytes_received, qint64 bytes_total) {
|
|||||||
currentValue = bytes_received * 100 / bytes_total;
|
currentValue = bytes_received * 100 / bytes_total;
|
||||||
totalValue = 100;
|
totalValue = 100;
|
||||||
}
|
}
|
||||||
m_ui->progressBar->setValue(currentValue);
|
m_ui->m_progressDownload->setValue(currentValue);
|
||||||
m_ui->progressBar->setMaximum(totalValue);
|
m_ui->m_progressDownload->setMaximum(totalValue);
|
||||||
|
|
||||||
emit progress(currentValue, totalValue);
|
emit progress(currentValue, totalValue);
|
||||||
updateInfoLabel();
|
updateInfoLabel();
|
||||||
@ -371,12 +372,12 @@ void DownloadItem::updateInfoLabel()
|
|||||||
|
|
||||||
bool DownloadItem::downloading() const
|
bool DownloadItem::downloading() const
|
||||||
{
|
{
|
||||||
return (m_ui->progressBar->isVisible());
|
return (m_ui->m_progressDownload->isVisible());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DownloadItem::downloadedSuccessfully() const
|
bool DownloadItem::downloadedSuccessfully() const
|
||||||
{
|
{
|
||||||
return (m_ui->stopButton->isHidden() && m_ui->tryAgainButton->isHidden());
|
return (m_ui->m_btnStopDownload->isHidden() && m_ui->m_btnTryAgain->isHidden());
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadItem::finished()
|
void DownloadItem::finished()
|
||||||
@ -385,11 +386,11 @@ void DownloadItem::finished()
|
|||||||
if (!m_startedSaving) {
|
if (!m_startedSaving) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
m_ui->progressBar->hide();
|
m_ui->m_progressDownload->hide();
|
||||||
m_ui->stopButton->setEnabled(false);
|
m_ui->m_btnStopDownload->setEnabled(false);
|
||||||
m_ui->stopButton->hide();
|
m_ui->m_btnStopDownload->hide();
|
||||||
m_ui->openButton->setEnabled(true);
|
m_ui->m_btnOpenFile->setEnabled(true);
|
||||||
m_ui->toolButton->setEnabled(true);
|
m_ui->m_btnOpenFolder->setEnabled(true);
|
||||||
m_output.close();
|
m_output.close();
|
||||||
updateInfoLabel();
|
updateInfoLabel();
|
||||||
emit statusChanged();
|
emit statusChanged();
|
||||||
@ -400,15 +401,15 @@ DownloadManager::DownloadManager(QWidget *parent) : TabContent(parent), m_ui(new
|
|||||||
m_autoSaver(new AutoSaver(this)), m_model(new DownloadModel(this)),
|
m_autoSaver(new AutoSaver(this)), m_model(new DownloadModel(this)),
|
||||||
m_networkManager(WebBrowserNetworkAccessManager::instance()), m_iconProvider(0), m_removePolicy(Never) {
|
m_networkManager(WebBrowserNetworkAccessManager::instance()), m_iconProvider(0), m_removePolicy(Never) {
|
||||||
m_ui->setupUi(this);
|
m_ui->setupUi(this);
|
||||||
m_ui->downloadsView->setShowGrid(false);
|
m_ui->m_viewDownloads->setShowGrid(false);
|
||||||
m_ui->downloadsView->verticalHeader()->hide();
|
m_ui->m_viewDownloads->verticalHeader()->hide();
|
||||||
m_ui->downloadsView->horizontalHeader()->hide();
|
m_ui->m_viewDownloads->horizontalHeader()->hide();
|
||||||
m_ui->downloadsView->setAlternatingRowColors(true);
|
m_ui->m_viewDownloads->setAlternatingRowColors(true);
|
||||||
m_ui->downloadsView->horizontalHeader()->setStretchLastSection(true);
|
m_ui->m_viewDownloads->horizontalHeader()->setStretchLastSection(true);
|
||||||
m_ui->downloadsView->setModel(m_model);
|
m_ui->m_viewDownloads->setModel(m_model);
|
||||||
|
|
||||||
setDownloadDirectory(qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::TargetDirectory)).toString());
|
setDownloadDirectory(qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::TargetDirectory)).toString());
|
||||||
connect(m_ui->cleanupButton, SIGNAL(clicked()), this, SLOT(cleanup()));
|
connect(m_ui->m_btnCleanup, SIGNAL(clicked()), this, SLOT(cleanup()));
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,7 +429,7 @@ int DownloadManager::activeDownloads() const
|
|||||||
{
|
{
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (int i = 0; i < m_downloads.count(); ++i) {
|
for (int i = 0; i < m_downloads.count(); ++i) {
|
||||||
if (m_downloads.at(i)->m_ui->stopButton->isEnabled())
|
if (m_downloads.at(i)->m_ui->m_btnStopDownload->isEnabled())
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
@ -494,10 +495,10 @@ void DownloadManager::addItem(DownloadItem *item) {
|
|||||||
m_model->beginInsertRows(QModelIndex(), row, row);
|
m_model->beginInsertRows(QModelIndex(), row, row);
|
||||||
m_downloads.append(item);
|
m_downloads.append(item);
|
||||||
m_model->endInsertRows();
|
m_model->endInsertRows();
|
||||||
m_ui->downloadsView->setIndexWidget(m_model->index(row, 0), item);
|
m_ui->m_viewDownloads->setIndexWidget(m_model->index(row, 0), item);
|
||||||
QIcon icon = style()->standardIcon(QStyle::SP_FileIcon);
|
QIcon icon = style()->standardIcon(QStyle::SP_FileIcon);
|
||||||
item->m_ui->fileIcon->setPixmap(icon.pixmap(48, 48));
|
item->m_ui->m_lblFileIcon->setPixmap(icon.pixmap(48, 48));
|
||||||
m_ui->downloadsView->setRowHeight(row, item->sizeHint().height());
|
m_ui->m_viewDownloads->setRowHeight(row, item->sizeHint().height());
|
||||||
updateRow(item); //incase download finishes before the constructor returns
|
updateRow(item); //incase download finishes before the constructor returns
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -528,10 +529,10 @@ void DownloadManager::updateRow(DownloadItem *item)
|
|||||||
QIcon icon = m_iconProvider->icon(item->m_output.fileName());
|
QIcon icon = m_iconProvider->icon(item->m_output.fileName());
|
||||||
if (icon.isNull())
|
if (icon.isNull())
|
||||||
icon = style()->standardIcon(QStyle::SP_FileIcon);
|
icon = style()->standardIcon(QStyle::SP_FileIcon);
|
||||||
item->m_ui->fileIcon->setPixmap(icon.pixmap(48, 48));
|
item->m_ui->m_lblFileIcon->setPixmap(icon.pixmap(48, 48));
|
||||||
|
|
||||||
int oldHeight = m_ui->downloadsView->rowHeight(row);
|
int oldHeight = m_ui->m_viewDownloads->rowHeight(row);
|
||||||
m_ui->downloadsView->setRowHeight(row, qMax(oldHeight, item->minimumSizeHint().height()));
|
m_ui->m_viewDownloads->setRowHeight(row, qMax(oldHeight, item->minimumSizeHint().height()));
|
||||||
|
|
||||||
bool remove = false;
|
bool remove = false;
|
||||||
QWebSettings *globalSettings = QWebSettings::globalSettings();
|
QWebSettings *globalSettings = QWebSettings::globalSettings();
|
||||||
@ -546,7 +547,7 @@ void DownloadManager::updateRow(DownloadItem *item)
|
|||||||
if (remove)
|
if (remove)
|
||||||
m_model->removeRow(row);
|
m_model->removeRow(row);
|
||||||
|
|
||||||
m_ui->cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0);
|
m_ui->m_btnCleanup->setEnabled(m_downloads.count() - activeDownloads() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadManager::RemovePolicy DownloadManager::removePolicy() const
|
DownloadManager::RemovePolicy DownloadManager::removePolicy() const
|
||||||
@ -610,18 +611,18 @@ void DownloadManager::load()
|
|||||||
if (!url.isEmpty() && !fileName.isEmpty()) {
|
if (!url.isEmpty() && !fileName.isEmpty()) {
|
||||||
DownloadItem *item = new DownloadItem(0, false, this);
|
DownloadItem *item = new DownloadItem(0, false, this);
|
||||||
item->m_output.setFileName(fileName);
|
item->m_output.setFileName(fileName);
|
||||||
item->m_ui->m_fileNameLabel->setText(QFileInfo(item->m_output.fileName()).fileName());
|
item->m_ui->m_lblFilename->setText(QFileInfo(item->m_output.fileName()).fileName());
|
||||||
item->m_url = url;
|
item->m_url = url;
|
||||||
item->m_ui->stopButton->setVisible(false);
|
item->m_ui->m_btnStopDownload->setVisible(false);
|
||||||
item->m_ui->stopButton->setEnabled(false);
|
item->m_ui->m_btnStopDownload->setEnabled(false);
|
||||||
item->m_ui->tryAgainButton->setVisible(!done);
|
item->m_ui->m_btnTryAgain->setVisible(!done);
|
||||||
item->m_ui->tryAgainButton->setEnabled(!done);
|
item->m_ui->m_btnTryAgain->setEnabled(!done);
|
||||||
item->m_ui->progressBar->setVisible(false);
|
item->m_ui->m_progressDownload->setVisible(false);
|
||||||
addItem(item);
|
addItem(item);
|
||||||
}
|
}
|
||||||
key = QString(QLatin1String("download_%1_")).arg(++i);
|
key = QString(QLatin1String("download_%1_")).arg(++i);
|
||||||
}
|
}
|
||||||
m_ui->cleanupButton->setEnabled(m_downloads.count() - activeDownloads() > 0);
|
m_ui->m_btnCleanup->setEnabled(m_downloads.count() - activeDownloads() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::cleanup()
|
void DownloadManager::cleanup()
|
||||||
@ -693,13 +694,17 @@ DownloadModel::DownloadModel(DownloadManager *download_manager, QObject *parent)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QVariant DownloadModel::data(const QModelIndex &index, int role) const
|
QVariant DownloadModel::data(const QModelIndex &index, int role) const {
|
||||||
{
|
if (index.row() < 0 || index.row() >= rowCount(index.parent())) {
|
||||||
if (index.row() < 0 || index.row() >= rowCount(index.parent()))
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
if (role == Qt::ToolTipRole)
|
}
|
||||||
if (!m_downloadManager->m_downloads.at(index.row())->downloadedSuccessfully())
|
|
||||||
|
if (role == Qt::ToolTipRole) {
|
||||||
|
if (!m_downloadManager->m_downloads.at(index.row())->downloadedSuccessfully()) {
|
||||||
return m_downloadManager->m_downloads.at(index.row())->m_ui->m_lblInfoDownload->text();
|
return m_downloadManager->m_downloads.at(index.row())->m_ui->m_lblInfoDownload->text();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -716,7 +721,7 @@ bool DownloadModel::removeRows(int row, int count, const QModelIndex &parent)
|
|||||||
int lastRow = row + count - 1;
|
int lastRow = row + count - 1;
|
||||||
for (int i = lastRow; i >= row; --i) {
|
for (int i = lastRow; i >= row; --i) {
|
||||||
if (m_downloadManager->m_downloads.at(i)->downloadedSuccessfully()
|
if (m_downloadManager->m_downloads.at(i)->downloadedSuccessfully()
|
||||||
|| m_downloadManager->m_downloads.at(i)->m_ui->tryAgainButton->isEnabled()) {
|
|| m_downloadManager->m_downloads.at(i)->m_ui->m_btnTryAgain->isEnabled()) {
|
||||||
beginRemoveRows(parent, i, i);
|
beginRemoveRows(parent, i, i);
|
||||||
m_downloadManager->m_downloads.takeAt(i)->deleteLater();
|
m_downloadManager->m_downloads.takeAt(i)->deleteLater();
|
||||||
endRemoveRows();
|
endRemoveRows();
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="EditTableView" name="downloadsView">
|
<widget class="EditTableView" name="m_viewDownloads">
|
||||||
<property name="frameShape">
|
<property name="frameShape">
|
||||||
<enum>QFrame::Box</enum>
|
<enum>QFrame::Box</enum>
|
||||||
</property>
|
</property>
|
||||||
@ -33,7 +33,7 @@
|
|||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="cleanupButton">
|
<widget class="QPushButton" name="m_btnCleanup">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
|
@ -128,6 +128,7 @@ void WebView::setupIcons() {
|
|||||||
m_actionCopyLink->setIcon(qApp->icons()->fromTheme("edit-copy"));
|
m_actionCopyLink->setIcon(qApp->icons()->fromTheme("edit-copy"));
|
||||||
m_actionCopyImage->setIcon(qApp->icons()->fromTheme("edit-copy-image"));
|
m_actionCopyImage->setIcon(qApp->icons()->fromTheme("edit-copy-image"));
|
||||||
m_actionSaveHyperlinkAs->setIcon(qApp->icons()->fromTheme("document-download"));
|
m_actionSaveHyperlinkAs->setIcon(qApp->icons()->fromTheme("document-download"));
|
||||||
|
m_actionSaveImageAs->setIcon(qApp->icons()->fromTheme("document-download"));
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040800
|
#if QT_VERSION >= 0x040800
|
||||||
m_actionCopyImageUrl->setIcon(qApp->icons()->fromTheme("edit-copy"));
|
m_actionCopyImageUrl->setIcon(qApp->icons()->fromTheme("edit-copy"));
|
||||||
@ -174,6 +175,11 @@ void WebView::initializeActions() {
|
|||||||
m_actionCopyImage->setText(tr("Copy image"));
|
m_actionCopyImage->setText(tr("Copy image"));
|
||||||
m_actionCopyImage->setToolTip(tr("Copy image to clipboard."));
|
m_actionCopyImage->setToolTip(tr("Copy image to clipboard."));
|
||||||
|
|
||||||
|
m_actionSaveImageAs = pageAction(QWebPage::DownloadImageToDisk);
|
||||||
|
m_actionSaveImageAs->setParent(this);
|
||||||
|
m_actionSaveImageAs->setText("Save image as...");
|
||||||
|
m_actionSaveImageAs->setToolTip(tr("Save image to disk."));
|
||||||
|
|
||||||
m_actionSavePageAs = new QAction(qApp->icons()->fromTheme("document-download"), tr("Save page as..."), this);
|
m_actionSavePageAs = new QAction(qApp->icons()->fromTheme("document-download"), tr("Save page as..."), this);
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040800
|
#if QT_VERSION >= 0x040800
|
||||||
@ -271,6 +277,7 @@ void WebView::popupContextMenu(const QPoint &pos) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
image_submenu.addAction(m_actionCopyImage);
|
image_submenu.addAction(m_actionCopyImage);
|
||||||
|
image_submenu.addAction(m_actionSaveImageAs);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Display the menu.
|
// Display the menu.
|
||||||
|
@ -101,6 +101,7 @@ class WebView : public QWebView {
|
|||||||
QAction *m_actionCopyImage;
|
QAction *m_actionCopyImage;
|
||||||
QAction *m_actionSavePageAs;
|
QAction *m_actionSavePageAs;
|
||||||
QAction *m_actionSaveHyperlinkAs;
|
QAction *m_actionSaveHyperlinkAs;
|
||||||
|
QAction *m_actionSaveImageAs;
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040800
|
#if QT_VERSION >= 0x040800
|
||||||
QAction *m_actionCopyImageUrl;
|
QAction *m_actionCopyImageUrl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user