Reaction to downloading etc.

This commit is contained in:
Martin Rotter 2016-06-09 06:24:39 +02:00
parent fe3a570561
commit 2bb3460689
8 changed files with 45 additions and 11 deletions

View File

@ -77,8 +77,8 @@
#define ENCRYPTION_FILE_NAME "key.private"
#define RELOAD_MODEL_BORDER_NUM 10
#define INTERNAL_URL_MESSAGE "rssguard:message"
#define INTERNAL_URL_BLANK "rssguard:blank"
#define INTERNAL_URL_MESSAGE "rssguard.message"
#define INTERNAL_URL_BLANK "rssguard.blank"
#define INTERNAL_URL_HOST "rssguard"
#define INTERNAL_URL_MESSAGE_PORT "message"

View File

@ -56,17 +56,26 @@ void MessageBrowser::loadMessages(const QList<Message> &messages) {
QString::number(message.m_id)));
}
QString layout_wrapper = skin.m_layoutMarkupWrapper.arg(messages.size() == 1 ? messages.at(0).m_title : tr("Newspaper view"),
messages_layout);
m_messageContents = skin.m_layoutMarkupWrapper.arg(messages.size() == 1 ? messages.at(0).m_title : tr("Newspaper view"),
messages_layout);
bool previously_enabled = isEnabled();
setEnabled(false);
setHtml(layout_wrapper, QUrl(INTERNAL_URL_MESSAGE));
setEnabled(previously_enabled);
//setEnabled(false);
setHtml(m_messageContents, QUrl(INTERNAL_URL_MESSAGE));
//load(QUrl(INTERNAL_URL_MESSAGE));
//setEnabled(previously_enabled);
IOFactory::writeTextFile("aa.html", layout_wrapper.toUtf8());
IOFactory::writeTextFile("aa.html", m_messageContents.toUtf8());
}
void MessageBrowser::loadMessage(const Message &message) {
loadMessages(QList<Message>() << message);
}
void MessageBrowser::clear() {
setHtml("<!DOCTYPE html><html><body</body></html>", QUrl(INTERNAL_URL_BLANK));
}
void MessageBrowser::assignMessageContents() {
setHtml(m_messageContents, QUrl(INTERNAL_URL_MESSAGE));
}

View File

@ -33,9 +33,16 @@ class MessageBrowser : public QWebEngineView {
public slots:
void loadMessages(const QList<Message> &messages);
void loadMessage(const Message &message);
void clear();
private:
void assignMessageContents();
signals:
void messageStatusChangeRequested(int message_id, MessageBrowserPage::MessageStatusChange change);
private:
QString m_messageContents;
};
#endif // MESSAGEBROWSER_H

View File

@ -52,14 +52,12 @@ void MessagePreviewer::reloadFontSettings() {
fon.fromString(qApp->settings()->value(GROUP(Messages),
SETTING(Messages::PreviewerFontStandard)).toString());
auto aa = fon.family();
QWebEngineSettings::globalSettings()->setFontFamily(QWebEngineSettings::StandardFont, fon.family());
QWebEngineSettings::globalSettings()->setFontSize(QWebEngineSettings::DefaultFontSize, fon.pointSize());
}
void MessagePreviewer::clear() {
m_ui->m_webMessage->setHtml("<!DOCTYPE html><html><body</body></html>", QUrl(INTERNAL_URL_BLANK));
m_ui->m_webMessage->clear();
hide();
}

View File

@ -36,6 +36,8 @@
#include <QSessionManager>
#include <QThread>
#include <QProcess>
#include <QWebEngineProfile>
#include <QWebEngineDownloadItem>
Application::Application(const QString &id, int &argc, char **argv)
@ -46,6 +48,8 @@ Application::Application(const QString &id, int &argc, char **argv)
connect(this, SIGNAL(aboutToQuit()), this, SLOT(onAboutToQuit()));
connect(this, SIGNAL(commitDataRequest(QSessionManager&)), this, SLOT(onCommitData(QSessionManager&)));
connect(this, SIGNAL(saveStateRequest(QSessionManager&)), this, SLOT(onSaveState(QSessionManager&)));
connect(QWebEngineProfile::defaultProfile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)),
this, SLOT(downloadRequested(QWebEngineDownloadItem*)));
}
Application::~Application() {
@ -291,3 +295,8 @@ void Application::onAboutToQuit() {
qDebug("Close lock timed-out.");
}
}
void Application::downloadRequested(QWebEngineDownloadItem *download_item) {
downloadManager()->download(download_item->url());
download_item->cancel();
}

View File

@ -45,6 +45,7 @@ class FormMain;
class IconFactory;
class QAction;
class Mutex;
class QWebEngineDownloadItem;
class Application : public QtSingleApplication {
Q_OBJECT
@ -167,6 +168,7 @@ class Application : public QtSingleApplication {
void onCommitData(QSessionManager &manager);
void onSaveState(QSessionManager &manager);
void onAboutToQuit();
void downloadRequested(QWebEngineDownloadItem*download_item);
private:
void eliminateFirstRun();

View File

@ -18,6 +18,7 @@
#include "network-web/messagebrowserpage.h"
#include "definitions/definitions.h"
#include "gui/messagebrowser.h"
#include <QStringList>
#include <QString>
@ -26,6 +27,9 @@
MessageBrowserPage::MessageBrowserPage(QObject *parent) : QWebEnginePage(parent) {
}
MessageBrowser *MessageBrowserPage::view() const {
return qobject_cast<MessageBrowser*>(QWebEnginePage::view());
}
void MessageBrowserPage::javaScriptAlert(const QUrl &securityOrigin, const QString &msg) {
if (securityOrigin.isEmpty()) {

View File

@ -21,6 +21,8 @@
#include <QWebEnginePage>
class MessageBrowser;
class MessageBrowserPage : public QWebEnginePage {
Q_OBJECT
@ -34,6 +36,9 @@ class MessageBrowserPage : public QWebEnginePage {
explicit MessageBrowserPage(QObject *parent = 0);
MessageBrowser *view() const;
protected:
void javaScriptAlert(const QUrl &securityOrigin, const QString &msg);
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame);