Cleanups, added previewer.
This commit is contained in:
parent
322aef972d
commit
328f29cc5d
10 changed files with 230 additions and 71 deletions
|
@ -36,6 +36,7 @@
|
||||||
#include "gui/messagebox.h"
|
#include "gui/messagebox.h"
|
||||||
#include "gui/messagestoolbar.h"
|
#include "gui/messagestoolbar.h"
|
||||||
#include "gui/feedstoolbar.h"
|
#include "gui/feedstoolbar.h"
|
||||||
|
#include "gui/messagepreviewer.h"
|
||||||
#include "gui/dialogs/formdatabasecleanup.h"
|
#include "gui/dialogs/formdatabasecleanup.h"
|
||||||
#include "gui/dialogs/formmain.h"
|
#include "gui/dialogs/formmain.h"
|
||||||
#include "exceptions/applicationexception.h"
|
#include "exceptions/applicationexception.h"
|
||||||
|
@ -63,7 +64,7 @@ FeedMessageViewer::FeedMessageViewer(QWidget *parent)
|
||||||
m_toolBarMessages(new MessagesToolBar(tr("Toolbar for messages"), this)),
|
m_toolBarMessages(new MessagesToolBar(tr("Toolbar for messages"), this)),
|
||||||
m_messagesView(new MessagesView(this)),
|
m_messagesView(new MessagesView(this)),
|
||||||
m_feedsView(new FeedsView(this)),
|
m_feedsView(new FeedsView(this)),
|
||||||
m_messagesBrowser(new QTextBrowser(this)) {
|
m_messagesBrowser(new MessagePreviewer(this)) {
|
||||||
initialize();
|
initialize();
|
||||||
initializeViews();
|
initializeViews();
|
||||||
loadMessageViewerFonts();
|
loadMessageViewerFonts();
|
||||||
|
@ -238,10 +239,10 @@ void FeedMessageViewer::createConnections() {
|
||||||
connect(m_toolBarMessages, SIGNAL(messageFilterChanged(MessagesModel::MessageHighlighter)), m_messagesView, SLOT(filterMessages(MessagesModel::MessageHighlighter)));
|
connect(m_toolBarMessages, SIGNAL(messageFilterChanged(MessagesModel::MessageHighlighter)), m_messagesView, SLOT(filterMessages(MessagesModel::MessageHighlighter)));
|
||||||
|
|
||||||
// Message changers.
|
// Message changers.
|
||||||
connect(m_messagesView, SIGNAL(currentMessagesRemoved()), m_messagesBrowser, SLOT(clear()));
|
connect(m_messagesView, SIGNAL(currentMessageRemoved()), m_messagesBrowser, SLOT(clear()));
|
||||||
connect(m_messagesView, SIGNAL(currentMessagesChanged(QList<Message>)), this, SLOT(navigateToMessages(QList<Message>)));
|
connect(m_messagesView, SIGNAL(currentMessageChanged(Message)), m_messagesBrowser, SLOT(loadMessage(Message)));
|
||||||
connect(m_messagesView, SIGNAL(currentMessagesRemoved()), this, SLOT(updateMessageButtonsAvailability()));
|
connect(m_messagesView, SIGNAL(currentMessageRemoved()), this, SLOT(updateMessageButtonsAvailability()));
|
||||||
connect(m_messagesView, SIGNAL(currentMessagesChanged(QList<Message>)), this, SLOT(updateMessageButtonsAvailability()));
|
connect(m_messagesView, SIGNAL(currentMessageChanged(Message)), this, SLOT(updateMessageButtonsAvailability()));
|
||||||
|
|
||||||
connect(m_feedsView, SIGNAL(itemSelected(RootItem*)), this, SLOT(updateFeedButtonsAvailability()));
|
connect(m_feedsView, SIGNAL(itemSelected(RootItem*)), this, SLOT(updateFeedButtonsAvailability()));
|
||||||
connect(qApp->feedUpdateLock(), SIGNAL(locked()), this, SLOT(updateFeedButtonsAvailability()));
|
connect(qApp->feedUpdateLock(), SIGNAL(locked()), this, SLOT(updateFeedButtonsAvailability()));
|
||||||
|
@ -438,43 +439,6 @@ void FeedMessageViewer::refreshVisualProperties() {
|
||||||
m_toolBarMessages->setToolButtonStyle(button_style);
|
m_toolBarMessages->setToolButtonStyle(button_style);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FeedMessageViewer::navigateToMessages(const QList<Message> &messages) {
|
|
||||||
Skin skin = qApp->skins()->currentSkin();
|
|
||||||
QString messages_layout;
|
|
||||||
QString single_message_layout = skin.m_layoutMarkup;
|
|
||||||
|
|
||||||
foreach (const Message &message, messages) {
|
|
||||||
QString enclosures;
|
|
||||||
|
|
||||||
foreach (const Enclosure &enclosure, message.m_enclosures) {
|
|
||||||
enclosures += skin.m_enclosureMarkup.arg(enclosure.m_url);
|
|
||||||
|
|
||||||
if (!enclosure.m_mimeType.isEmpty()) {
|
|
||||||
enclosures += QL1S(" [") + enclosure.m_mimeType + QL1S("]");
|
|
||||||
}
|
|
||||||
|
|
||||||
enclosures += QL1S("<br>");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!enclosures.isEmpty()) {
|
|
||||||
enclosures = enclosures.prepend(QSL("<br>"));
|
|
||||||
}
|
|
||||||
|
|
||||||
messages_layout.append(single_message_layout.arg(message.m_title,
|
|
||||||
tr("Written by ") + (message.m_author.isEmpty() ?
|
|
||||||
tr("unknown author") :
|
|
||||||
message.m_author),
|
|
||||||
message.m_url,
|
|
||||||
message.m_contents,
|
|
||||||
message.m_created.toString(Qt::DefaultLocaleShortDate),
|
|
||||||
enclosures));
|
|
||||||
}
|
|
||||||
|
|
||||||
QString layout_wrapper = skin.m_layoutMarkupWrapper.arg(messages.size() == 1 ? messages.at(0).m_title : tr("Newspaper view"), messages_layout);
|
|
||||||
|
|
||||||
m_messagesBrowser->setHtml(layout_wrapper);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FeedMessageViewer::onFeedsUpdateFinished() {
|
void FeedMessageViewer::onFeedsUpdateFinished() {
|
||||||
m_messagesView->reloadSelections(true);
|
m_messagesView->reloadSelections(true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,7 @@ class WebBrowser;
|
||||||
class MessagesView;
|
class MessagesView;
|
||||||
class MessagesToolBar;
|
class MessagesToolBar;
|
||||||
class FeedsToolBar;
|
class FeedsToolBar;
|
||||||
|
class MessagePreviewer;
|
||||||
class FeedsView;
|
class FeedsView;
|
||||||
class StandardFeed;
|
class StandardFeed;
|
||||||
class QToolBar;
|
class QToolBar;
|
||||||
|
@ -95,8 +96,6 @@ class FeedMessageViewer : public TabContent {
|
||||||
// Reloads some changeable visual settings.
|
// Reloads some changeable visual settings.
|
||||||
void refreshVisualProperties();
|
void refreshVisualProperties();
|
||||||
|
|
||||||
void navigateToMessages(const QList<Message> &messages);
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
// Called when feed update finishes.
|
// Called when feed update finishes.
|
||||||
void onFeedsUpdateFinished();
|
void onFeedsUpdateFinished();
|
||||||
|
@ -135,7 +134,7 @@ class FeedMessageViewer : public TabContent {
|
||||||
FeedsView *m_feedsView;
|
FeedsView *m_feedsView;
|
||||||
QWidget *m_feedsWidget;
|
QWidget *m_feedsWidget;
|
||||||
QWidget *m_messagesWidget;
|
QWidget *m_messagesWidget;
|
||||||
QTextBrowser *m_messagesBrowser;
|
MessagePreviewer *m_messagesBrowser;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // FEEDMESSAGEVIEWER_H
|
#endif // FEEDMESSAGEVIEWER_H
|
||||||
|
|
89
src/gui/messagepreviewer.cpp
Normal file
89
src/gui/messagepreviewer.cpp
Normal file
|
@ -0,0 +1,89 @@
|
||||||
|
// This file is part of RSS Guard.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011-2016 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
|
//
|
||||||
|
// RSS Guard 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.
|
||||||
|
//
|
||||||
|
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#include "gui/messagepreviewer.h"
|
||||||
|
|
||||||
|
#include "miscellaneous/application.h"
|
||||||
|
#include "network-web/webfactory.h"
|
||||||
|
#include "gui/messagebox.h"
|
||||||
|
#include "gui/dialogs/formmain.h"
|
||||||
|
|
||||||
|
#include <QScrollBar>
|
||||||
|
|
||||||
|
|
||||||
|
MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
||||||
|
m_ui(new Ui::MessagePreviewer) {
|
||||||
|
m_ui->setupUi(this);
|
||||||
|
m_ui->m_txtMessage->viewport()->setAutoFillBackground(true);
|
||||||
|
|
||||||
|
connect(m_ui->m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl &url) {
|
||||||
|
// User clicked some URL. Open it in external browser or download?
|
||||||
|
MessageBox box(qApp->mainForm());
|
||||||
|
|
||||||
|
box.setText(tr("You clicked link \"%1\". You can download the link contents or open it in external web browser.").arg(url.toString()));
|
||||||
|
box.setInformativeText(tr("What action do you want to take?"));
|
||||||
|
QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::AcceptRole);
|
||||||
|
QAbstractButton *btn_download = box.addButton(tr("Download"), QMessageBox::RejectRole);
|
||||||
|
|
||||||
|
box.exec();
|
||||||
|
|
||||||
|
if (box.clickedButton() == btn_open) {
|
||||||
|
WebFactory::instance()->openUrlInExternalBrowser(url.toString());
|
||||||
|
}
|
||||||
|
else if (box.clickedButton() == btn_download) {
|
||||||
|
qApp->downloadManager()->download(url);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
MessagePreviewer::~MessagePreviewer() {
|
||||||
|
delete m_ui;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagePreviewer::clear() {
|
||||||
|
m_ui->m_lblTitle->clear();
|
||||||
|
m_ui->m_txtMessage->clear();
|
||||||
|
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MessagePreviewer::loadMessage(const Message &message) {
|
||||||
|
m_ui->m_lblTitle->setText(message.m_title);
|
||||||
|
m_ui->m_txtMessage->setHtml(prepareHtmlForMessage(message));
|
||||||
|
show();
|
||||||
|
|
||||||
|
m_ui->m_txtMessage->verticalScrollBar()->triggerAction(QScrollBar::SliderToMinimum);
|
||||||
|
}
|
||||||
|
|
||||||
|
QString MessagePreviewer::prepareHtmlForMessage(const Message &message) {
|
||||||
|
QString html = QString("<p><a href=\"%1\">%1</a><p/>").arg(message.m_url);
|
||||||
|
|
||||||
|
foreach (const Enclosure &enc, message.m_enclosures) {
|
||||||
|
html += QString("<p>[%2] <a href=\"%1\">%1</a><p/>").arg(enc.m_url, enc.m_mimeType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!message.m_enclosures.isEmpty()) {
|
||||||
|
html += "<hr/>";
|
||||||
|
}
|
||||||
|
|
||||||
|
html += message.m_contents;
|
||||||
|
|
||||||
|
return html;
|
||||||
|
}
|
49
src/gui/messagepreviewer.h
Normal file
49
src/gui/messagepreviewer.h
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
// This file is part of RSS Guard.
|
||||||
|
//
|
||||||
|
// Copyright (C) 2011-2016 by Martin Rotter <rotter.martinos@gmail.com>
|
||||||
|
//
|
||||||
|
// RSS Guard 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.
|
||||||
|
//
|
||||||
|
// RSS Guard 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 RSS Guard. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
#ifndef MESSAGEPREVIEWER_H
|
||||||
|
#define MESSAGEPREVIEWER_H
|
||||||
|
|
||||||
|
#include <QWidget>
|
||||||
|
|
||||||
|
#include "ui_messagepreviewer.h"
|
||||||
|
|
||||||
|
#include "core/message.h"
|
||||||
|
|
||||||
|
|
||||||
|
namespace Ui {
|
||||||
|
class MessagePreviewer;
|
||||||
|
}
|
||||||
|
|
||||||
|
class MessagePreviewer : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
explicit MessagePreviewer(QWidget *parent = 0);
|
||||||
|
virtual ~MessagePreviewer();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void clear();
|
||||||
|
void loadMessage(const Message &message);
|
||||||
|
|
||||||
|
private:
|
||||||
|
QString prepareHtmlForMessage(const Message &message);
|
||||||
|
|
||||||
|
Ui::MessagePreviewer *m_ui;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // MESSAGEPREVIEWER_H
|
61
src/gui/messagepreviewer.ui
Normal file
61
src/gui/messagepreviewer.ui
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>MessagePreviewer</class>
|
||||||
|
<widget class="QWidget" name="MessagePreviewer">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>502</width>
|
||||||
|
<height>396</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<layout class="QVBoxLayout" name="verticalLayout">
|
||||||
|
<item>
|
||||||
|
<widget class="QLabel" name="m_lblTitle">
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>18</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>avas</string>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="wordWrap">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QTextBrowser" name="m_txtMessage">
|
||||||
|
<property name="autoFillBackground">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="frameShape">
|
||||||
|
<enum>QFrame::StyledPanel</enum>
|
||||||
|
</property>
|
||||||
|
<property name="frameShadow">
|
||||||
|
<enum>QFrame::Plain</enum>
|
||||||
|
</property>
|
||||||
|
<property name="openLinks">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
|
@ -96,7 +96,7 @@ void MessagesView::reloadSelections(bool mark_current_index_read) {
|
||||||
else {
|
else {
|
||||||
// Messages were probably removed from the model, nothing can
|
// Messages were probably removed from the model, nothing can
|
||||||
// be selected and no message can be displayed.
|
// be selected and no message can be displayed.
|
||||||
emit currentMessagesRemoved();
|
emit currentMessageRemoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,10 +203,10 @@ void MessagesView::selectionChanged(const QItemSelection &selected, const QItemS
|
||||||
m_sourceModel->setMessageRead(mapped_current_index.row(), RootItem::Read);
|
m_sourceModel->setMessageRead(mapped_current_index.row(), RootItem::Read);
|
||||||
}
|
}
|
||||||
|
|
||||||
emit currentMessagesChanged(QList<Message>() << message);
|
emit currentMessageChanged(message);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit currentMessagesRemoved();
|
emit currentMessageRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()) {
|
if (qApp->settings()->value(GROUP(Messages), SETTING(Messages::KeepCursorInCenter)).toBool()) {
|
||||||
|
@ -228,7 +228,7 @@ void MessagesView::loadItem(RootItem *item) {
|
||||||
// active message is not shown in browser.
|
// active message is not shown in browser.
|
||||||
// BUG: Qt 5 is probably bugged here. Selections
|
// BUG: Qt 5 is probably bugged here. Selections
|
||||||
// should be cleared automatically when SQL model is reset.
|
// should be cleared automatically when SQL model is reset.
|
||||||
emit currentMessagesRemoved();
|
emit currentMessageRemoved();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MessagesView::openSelectedSourceMessagesExternally() {
|
void MessagesView::openSelectedSourceMessagesExternally() {
|
||||||
|
@ -337,7 +337,7 @@ void MessagesView::deleteSelectedMessages() {
|
||||||
reselectIndexes(QModelIndexList() << last_item);
|
reselectIndexes(QModelIndexList() << last_item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit currentMessagesRemoved();
|
emit currentMessageRemoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +365,7 @@ void MessagesView::restoreSelectedMessages() {
|
||||||
reselectIndexes(QModelIndexList() << last_item);
|
reselectIndexes(QModelIndexList() << last_item);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
emit currentMessagesRemoved();
|
emit currentMessageRemoved();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -453,7 +453,7 @@ void MessagesView::searchMessages(const QString &pattern) {
|
||||||
m_proxyModel->setFilterRegExp(pattern);
|
m_proxyModel->setFilterRegExp(pattern);
|
||||||
|
|
||||||
if (selectionModel()->selectedRows().size() == 0) {
|
if (selectionModel()->selectedRows().size() == 0) {
|
||||||
emit currentMessagesRemoved();
|
emit currentMessageRemoved();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Scroll to selected message, it could become scrolled out due to filter change.
|
// Scroll to selected message, it could become scrolled out due to filter change.
|
||||||
|
@ -506,5 +506,5 @@ void MessagesView::onSortIndicatorChanged(int column, Qt::SortOrder order) {
|
||||||
|
|
||||||
// Repopulate the shit.
|
// Repopulate the shit.
|
||||||
m_sourceModel->sort(column, order);
|
m_sourceModel->sort(column, order);
|
||||||
emit currentMessagesRemoved();
|
emit currentMessageRemoved();
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,8 +95,8 @@ class MessagesView : public QTreeView {
|
||||||
void openMessagesInNewspaperView(const QList<Message> &messages);
|
void openMessagesInNewspaperView(const QList<Message> &messages);
|
||||||
|
|
||||||
// Notify others about message selections.
|
// Notify others about message selections.
|
||||||
void currentMessagesChanged(const QList<Message> &messages);
|
void currentMessageChanged(const Message &message);
|
||||||
void currentMessagesRemoved();
|
void currentMessageRemoved();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// Creates needed connections.
|
// Creates needed connections.
|
||||||
|
|
|
@ -241,7 +241,6 @@ int TabWidget::insertTab(int index, QWidget *widget, const QString &label, const
|
||||||
|
|
||||||
int TabWidget::addBrowserWithMessages(const QList<Message> &messages) {
|
int TabWidget::addBrowserWithMessages(const QList<Message> &messages) {
|
||||||
// TODO: TODO - volano kdyz se maji zobrazit zpravy v novinovem nahledu
|
// TODO: TODO - volano kdyz se maji zobrazit zpravy v novinovem nahledu
|
||||||
|
|
||||||
return 0; /* new index */
|
return 0; /* new index */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,16 +40,14 @@
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
|
|
||||||
|
|
||||||
DownloadItem::DownloadItem(bool is_direct_download, QNetworkReply *reply, QWidget *parent) : QWidget(parent),
|
DownloadItem::DownloadItem(QNetworkReply *reply, QWidget *parent) : QWidget(parent),
|
||||||
m_ui(new Ui::DownloadItem), m_reply(reply),
|
m_ui(new Ui::DownloadItem), m_reply(reply),
|
||||||
m_bytesReceived(0), m_requestFileName(false), m_startedSaving(false), m_finishedDownloading(false),
|
m_bytesReceived(0), m_requestFileName(false), 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->m_btnTryAgain->hide();
|
m_ui->m_btnTryAgain->hide();
|
||||||
|
|
||||||
m_requestFileName = is_direct_download ?
|
m_requestFileName = qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::AlwaysPromptForFilename)).toBool();
|
||||||
qApp->settings()->value(GROUP(Downloads), SETTING(Downloads::AlwaysPromptForFilename)).toBool() :
|
|
||||||
true;
|
|
||||||
|
|
||||||
connect(m_ui->m_btnStopDownload, SIGNAL(clicked()), this, SLOT(stop()));
|
connect(m_ui->m_btnStopDownload, SIGNAL(clicked()), this, SLOT(stop()));
|
||||||
connect(m_ui->m_btnOpenFile, SIGNAL(clicked()), this, SLOT(openFile()));
|
connect(m_ui->m_btnOpenFile, SIGNAL(clicked()), this, SLOT(openFile()));
|
||||||
|
@ -501,17 +499,17 @@ int DownloadManager::downloadProgress() const {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::download(const QNetworkRequest &request, bool direct_download) {
|
void DownloadManager::download(const QNetworkRequest &request) {
|
||||||
if (!request.url().isEmpty()) {
|
if (!request.url().isEmpty()) {
|
||||||
handleUnsupportedContent(m_networkManager->get(request), direct_download);
|
handleUnsupportedContent(m_networkManager->get(request));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::download(const QUrl &url, bool direct_download) {
|
void DownloadManager::download(const QUrl &url) {
|
||||||
download(QNetworkRequest(url), direct_download);
|
download(QNetworkRequest(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool direct_download) {
|
void DownloadManager::handleUnsupportedContent(QNetworkReply *reply) {
|
||||||
if (reply == NULL || reply->url().isEmpty()) {
|
if (reply == NULL || reply->url().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -524,7 +522,7 @@ void DownloadManager::handleUnsupportedContent(QNetworkReply *reply, bool direct
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadItem *item = new DownloadItem(direct_download, reply, this);
|
DownloadItem *item = new DownloadItem(reply, this);
|
||||||
addItem(item);
|
addItem(item);
|
||||||
|
|
||||||
if (!item->m_canceledFileSelect && qApp->settings()->value(GROUP(Downloads),
|
if (!item->m_canceledFileSelect && qApp->settings()->value(GROUP(Downloads),
|
||||||
|
@ -670,7 +668,7 @@ void DownloadManager::load() {
|
||||||
bool done = settings->value(GROUP(Downloads), QString(Downloads::ItemDone).arg(i), true).toBool();
|
bool done = settings->value(GROUP(Downloads), QString(Downloads::ItemDone).arg(i), true).toBool();
|
||||||
|
|
||||||
if (!url.isEmpty() && !file_name.isEmpty()) {
|
if (!url.isEmpty() && !file_name.isEmpty()) {
|
||||||
DownloadItem *item = new DownloadItem(false, 0, this);
|
DownloadItem *item = new DownloadItem(0, this);
|
||||||
item->m_output.setFileName(file_name);
|
item->m_output.setFileName(file_name);
|
||||||
item->m_url = url;
|
item->m_url = url;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ class DownloadItem : public QWidget {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// Constructors.
|
// Constructors.
|
||||||
explicit DownloadItem(bool is_direct_download, QNetworkReply *reply = 0, QWidget *parent = 0);
|
explicit DownloadItem(QNetworkReply *reply = 0, QWidget *parent = 0);
|
||||||
virtual ~DownloadItem();
|
virtual ~DownloadItem();
|
||||||
|
|
||||||
bool downloading() const;
|
bool downloading() const;
|
||||||
|
@ -124,9 +124,9 @@ class DownloadManager : public TabContent {
|
||||||
static QString dataString(qint64 size);
|
static QString dataString(qint64 size);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void download(const QNetworkRequest &request, bool direct_download = false);
|
void download(const QNetworkRequest &request);
|
||||||
void download(const QUrl &url, bool direct_download = false);
|
void download(const QUrl &url);
|
||||||
void handleUnsupportedContent(QNetworkReply *reply, bool direct_download = false);
|
void handleUnsupportedContent(QNetworkReply *reply);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
|
|
Loading…
Add table
Reference in a new issue