mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-27 07:46:17 +01:00
Port to webengine, remove some stuff.
This commit is contained in:
parent
3b3e1bcc1b
commit
203806da4f
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -6,5 +6,8 @@
|
||||
<email>rotter.martinos@gmail.com</email>
|
||||
</author>
|
||||
<style/>
|
||||
<markup_wrapper>PGh0bWw+DQogIDxoZWFkPg0KICAgIDxzdHlsZT4NCiAgICAgIGJvZHkgew0KICAgICAgICBtYXJnaW46IDBweDsNCiAgICAgICAgcGFkZGluZzogMHB4Ow0KICAgICAgfQ0KICAgIA0KICAgICAgcHJlIHsNCiAgICAgICAgd2hpdGUtc3BhY2U6IHByZS13cmFwOw0KICAgICAgfQ0KDQogICAgICAuaGVhZGVydGV4dCB7DQogICAgICAgIGZvbnQtc2l6ZTogMjBweDsNCiAgICAgICAgbWFyZ2luLWJvdHRvbTogMTBweDsNCiAgICAgIH0NCg0KICAgICAgLmhlYWRlciB7DQogICAgICAgIGZvbnQtc2l6ZTogMTdweDsNCiAgICAgICAgYmFja2dyb3VuZDogLXdlYmtpdC1ncmFkaWVudChsaW5lYXIsIGxlZnQgdG9wLCBsZWZ0IGJvdHRvbSwgY29sb3Itc3RvcCgwJSxyZ2JhKDk5LDEzNSwyMjksMSkpLCBjb2xvci1zdG9wKDEwMCUscmdiYSg2NCwxMDksMjM2LDEpKSk7DQogICAgICAgIHBhZGRpbmc6IDZweDsNCiAgICAgICAgbWFyZ2luOiAwcHggYXV0bzsNCiAgICAgICAgY29sb3I6IHdoaXRlOw0KICAgICAgICBib3JkZXI6IDAuNXB4IHNvbGlkIGJsYWNrOw0KICAgICAgfQ0KDQogICAgICAuaGVhZGVyIGEgew0KICAgICAgICB0ZXh0LWRlY29yYXRpb246IG5vbmU7DQogICAgICAgIGNvbG9yOiB3aGl0ZTsNCiAgICAgICAgd29yZC13cmFwOiBicmVhay13b3JkOw0KICAgICAgfQ0KICAgICAgDQogICAgICAuaGVhZGVyIC5lbmNsb3N1cmUgew0KICAgICAgICB0ZXh0LWRlY29yYXRpb246IG5vbmU7DQogICAgICAgIGNvbG9yOiBibGFjazsNCiAgICAgICAgd29yZC13cmFwOiBicmVhay13b3JkOw0KICAgICAgfQ0KICAgICAgDQogICAgICAuZW5jbG9zdXJlOmhvdmVyLCAuaGVhZGVyIGE6aG92ZXIgew0KICAgICAgICB0ZXh0LWRlY29yYXRpb246IHVuZGVybGluZTsNCiAgICAgIH0NCg0KICAgICAgLmNvbnRlbnQgew0KICAgICAgICBib3JkZXItdG9wOiAxcHggc29saWQgZ3JheTsNCiAgICAgICAgZm9udC1zaXplOiAxNnB4Ow0KICAgICAgICBtYXJnaW46IDBweCBhdXRvOw0KICAgICAgICBwYWRkaW5nOiA2cHg7DQogICAgICAgIHBhZGRpbmctdG9wOiAxMnB4Ow0KICAgICAgfQ0KICAgICAgDQogICAgICAuY29udGFpbmVyIHsNCiAgICAgICAgYm9yZGVyOiAxcHggc29saWQgZ3JheTsNCiAgICAgICAgLXdlYmtpdC1ib3JkZXItcmFkaXVzOiAycHg7DQogICAgICAgIG1hcmdpbjogMTBweDsNCiAgICAgICAgLXdlYmtpdC1ib3gtc2hhZG93OiAycHggMnB4IDE2cHggMHB4IHJnYmEoNTAsIDUwLCA1MCwgMC42Mik7DQogICAgICB9DQogICAgPC9zdHlsZT4NCiAgICA8dGl0bGU+DQogICAgICAlMQ0KICAgIDwvdGl0bGU+DQogIDwvaGVhZD4NCiAgPGJvZHk+DQogICAgJTINCiAgPC9ib2R5Pg0KPC9odG1sPg==</markup_wrapper>
|
||||
<markup>PGRpdiBjbGFzcz0iY29udGFpbmVyIj4NCiAgICAgIDxkaXYgY2xhc3M9ImhlYWRlciI+DQogICAgICAgIDxkaXYgY2xhc3M9ImhlYWRlcnRleHQiPg0KICAgICAgICAgICUxDQogICAgICAgIDwvZGl2Pg0KIC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ICBpbWFnZTogdXJsKHFzcy9icmFuY2gtb3Blbi5wbmcpOw0KfQ0KDQpRVHJlZVZpZXc6Oml0ZW0gew0KICBwYWRkaW5nOiAxcHggMXB4IDFweCAxcHg7DQp9IA0KDQpRVHJlZVZpZXdbaGlkZVRyZWU9InRydWUiXTo6YnJhbmNoOiFoYXMtY2hsaWRyZW46aGFzU2libGluZ3Mgew0KICBib3JkZXItaW1hZ2U6IG5vbmU7DQogIGltYWdlOiBub25lOw0KfQ0KDQpRU3RhdHVzQmFyOjppdGVtIHsNCiAgYm9yZGVyOiBub25lOw0KfQ==</data>
|
||||
</skin>
|
1152
rssguard.pro
1152
rssguard.pro
File diff suppressed because it is too large
Load Diff
@ -77,6 +77,9 @@
|
||||
#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 FEED_INITIAL_OPML_PATTERN "feeds-%1.opml"
|
||||
|
||||
#define FEED_REGEX_MATCHER "<link[^>]+type=\\\"application/(atom|rss)\\+xml\\\"[^>]*>"
|
||||
|
60
src/gui/messagebrowser.cpp
Normal file
60
src/gui/messagebrowser.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
// 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/messagebrowser.h"
|
||||
|
||||
#include "miscellaneous/skinfactory.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "definitions/definitions.h"
|
||||
|
||||
|
||||
MessageBrowser::MessageBrowser(QWidget *parent) : QWebEngineView(parent) {
|
||||
}
|
||||
|
||||
void MessageBrowser::loadMessage(const Message &message) {
|
||||
Skin skin = qApp->skins()->currentSkin();
|
||||
QString messages_layout;
|
||||
QString single_message_layout = skin.m_layoutMarkup;
|
||||
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("uknown author") :
|
||||
message.m_author),
|
||||
message.m_url,
|
||||
message.m_contents,
|
||||
message.m_created.toString(Qt::DefaultLocaleShortDate),
|
||||
enclosures));
|
||||
|
||||
QString layout_wrapper = skin.m_layoutMarkupWrapper.arg(message.m_title, messages_layout);
|
||||
|
||||
setHtml(layout_wrapper, QUrl(INTERNAL_URL_MESSAGE));
|
||||
}
|
34
src/gui/messagebrowser.h
Normal file
34
src/gui/messagebrowser.h
Normal file
@ -0,0 +1,34 @@
|
||||
// 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 MESSAGEBROWSER_H
|
||||
#define MESSAGEBROWSER_H
|
||||
|
||||
#include <QWebEngineView>
|
||||
|
||||
#include "core/message.h"
|
||||
|
||||
|
||||
class MessageBrowser : public QWebEngineView {
|
||||
public:
|
||||
MessageBrowser(QWidget* parent = 0);
|
||||
|
||||
public slots:
|
||||
void loadMessage(const Message &message);
|
||||
};
|
||||
|
||||
#endif // MESSAGEBROWSER_H
|
@ -30,37 +30,6 @@
|
||||
|
||||
|
||||
void MessagePreviewer::createConnections() {
|
||||
connect(m_ui->m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl &url) {
|
||||
if (!url.isEmpty()) {
|
||||
// User clicked some URL. Open it in external browser or download?
|
||||
MessageBox box(qApp->mainForm());
|
||||
|
||||
box.setText(tr("You clicked some link. You can download the link contents or open it in external web browser."));
|
||||
box.setInformativeText(tr("What action do you want to take?"));
|
||||
box.setDetailedText(url.toString());
|
||||
QAbstractButton *btn_open = box.addButton(tr("Open in external browser"), QMessageBox::ActionRole);
|
||||
QAbstractButton *btn_download = box.addButton(tr("Download"), QMessageBox::ActionRole);
|
||||
QAbstractButton *btn_cancel = box.addButton(QMessageBox::Cancel);
|
||||
|
||||
box.setDefaultButton(QMessageBox::Cancel);
|
||||
box.exec();
|
||||
|
||||
if (box.clickedButton() == btn_open) {
|
||||
WebFactory::instance()->openUrlInExternalBrowser(url.toString());
|
||||
}
|
||||
else if (box.clickedButton() == btn_download) {
|
||||
qApp->downloadManager()->download(url);
|
||||
}
|
||||
|
||||
btn_download->deleteLater();
|
||||
btn_open->deleteLater();
|
||||
btn_cancel->deleteLater();
|
||||
}
|
||||
else {
|
||||
MessageBox::show(qApp->mainForm(), QMessageBox::Warning, tr("Incorrect link"),
|
||||
tr("Selected hyperlink is invalid."));
|
||||
}
|
||||
});
|
||||
connect(m_actionMarkRead = m_toolBar->addAction(qApp->icons()->fromTheme("mail-mark-read"), tr("Mark message as read")),
|
||||
&QAction::triggered,
|
||||
this,
|
||||
@ -73,19 +42,11 @@ void MessagePreviewer::createConnections() {
|
||||
&QAction::triggered,
|
||||
this,
|
||||
&MessagePreviewer::switchMessageImportance);
|
||||
connect(m_ui->m_txtMessage,
|
||||
static_cast<void (QTextBrowser::*)(const QString&)>(&QTextBrowser::highlighted),
|
||||
[=](const QString &text) {
|
||||
Q_UNUSED(text)
|
||||
|
||||
QToolTip::showText(QCursor::pos(), tr("Click this link to download it or open it with external browser."), this);
|
||||
});
|
||||
}
|
||||
|
||||
MessagePreviewer::MessagePreviewer(QWidget *parent) : QWidget(parent),
|
||||
m_ui(new Ui::MessagePreviewer), m_pictures(QStringList()) {
|
||||
m_ui(new Ui::MessagePreviewer) {
|
||||
m_ui->setupUi(this);
|
||||
m_ui->m_txtMessage->viewport()->setAutoFillBackground(true);
|
||||
m_toolBar = new QToolBar(this);
|
||||
m_toolBar->setOrientation(Qt::Vertical);
|
||||
m_ui->m_layout->addWidget(m_toolBar, 0, 0, -1, 1);
|
||||
@ -102,18 +63,11 @@ MessagePreviewer::~MessagePreviewer() {
|
||||
}
|
||||
|
||||
void MessagePreviewer::reloadFontSettings() {
|
||||
const Settings *settings = qApp->settings();
|
||||
QFont fon;
|
||||
|
||||
fon.fromString(settings->value(GROUP(Messages),
|
||||
SETTING(Messages::PreviewerFontStandard)).toString());
|
||||
|
||||
m_ui->m_txtMessage->setFont(fon);
|
||||
// TODO: Reload font settings.
|
||||
}
|
||||
|
||||
void MessagePreviewer::clear() {
|
||||
m_ui->m_txtMessage->clear();
|
||||
m_pictures.clear();
|
||||
m_ui->m_webMessage->setHtml("<html><body</body></html>", QUrl(INTERNAL_URL_BLANK));
|
||||
hide();
|
||||
}
|
||||
|
||||
@ -123,12 +77,9 @@ void MessagePreviewer::loadMessage(const Message &message, RootItem *root) {
|
||||
|
||||
if (!m_root.isNull()) {
|
||||
m_actionSwitchImportance->setChecked(m_message.m_isImportant);
|
||||
m_ui->m_txtMessage->setHtml(prepareHtmlForMessage(m_message));
|
||||
|
||||
m_ui->m_webMessage->loadMessage(message);
|
||||
updateButtons();
|
||||
show();
|
||||
|
||||
m_ui->m_txtMessage->verticalScrollBar()->triggerAction(QScrollBar::SliderToMinimum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -196,30 +147,3 @@ void MessagePreviewer::updateButtons() {
|
||||
m_actionMarkRead->setEnabled(!m_message.m_isRead);
|
||||
m_actionMarkUnread->setEnabled(m_message.m_isRead);
|
||||
}
|
||||
|
||||
QString MessagePreviewer::prepareHtmlForMessage(const Message &message) {
|
||||
QString html = QString("<h2 align=\"center\">%1</h2>").arg(message.m_title);
|
||||
|
||||
html += QString("[url] <a href=\"%1\">%1</a><br/>").arg(message.m_url);
|
||||
|
||||
foreach (const Enclosure &enc, message.m_enclosures) {
|
||||
html += QString("[%2] <a href=\"%1\">%1</a><br/>").arg(enc.m_url, enc.m_mimeType);
|
||||
}
|
||||
|
||||
int offset = 0;
|
||||
QRegExp imgTagRegex("\\<img[^\\>]*src\\s*=\\s*\"([^\"]*)\"[^\\>]*\\>", Qt::CaseInsensitive);
|
||||
|
||||
imgTagRegex.setMinimal(true);
|
||||
|
||||
while( (offset = imgTagRegex.indexIn(message.m_contents, offset)) != -1){
|
||||
m_pictures.append(imgTagRegex.cap(1));
|
||||
|
||||
offset += imgTagRegex.matchedLength();
|
||||
html += QString("[%2] <a href=\"%1\">%1</a><br/>").arg(imgTagRegex.cap(1), tr("image"));
|
||||
}
|
||||
|
||||
html += "<br/>";
|
||||
html += message.m_contents;
|
||||
|
||||
return html;
|
||||
}
|
||||
|
@ -58,12 +58,10 @@ class MessagePreviewer : public QWidget {
|
||||
private:
|
||||
void createConnections();
|
||||
void updateButtons();
|
||||
QString prepareHtmlForMessage(const Message &message);
|
||||
|
||||
QToolBar *m_toolBar;
|
||||
QScopedPointer<Ui::MessagePreviewer> m_ui;
|
||||
Message m_message;
|
||||
QStringList m_pictures;
|
||||
QPointer<RootItem> m_root;
|
||||
|
||||
QAction *m_actionMarkRead;
|
||||
|
@ -23,32 +23,16 @@
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="1">
|
||||
<widget class="MessageTextBrowser" 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="tabChangesFocus">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="openLinks">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
<item row="0" column="0">
|
||||
<widget class="MessageBrowser" name="m_webMessage" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MessageTextBrowser</class>
|
||||
<extends>QTextBrowser</extends>
|
||||
<header>messagetextbrowser.h</header>
|
||||
<class>MessageBrowser</class>
|
||||
<extends>QWebEngineView</extends>
|
||||
<header>messagebrowser.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
|
@ -135,6 +135,19 @@ Skin SkinFactory::skinInfo(const QString &skin_name, bool *ok) const {
|
||||
|
||||
// Obtain version.
|
||||
skin.m_version = skin_node.attributes().namedItem(QSL("version")).toAttr().value();
|
||||
|
||||
// Obtain layout markup wrapper.
|
||||
skin.m_layoutMarkupWrapper = skin_node.namedItem(QSL("markup_wrapper")).toElement().text();
|
||||
skin.m_layoutMarkupWrapper = QByteArray::fromBase64(skin.m_layoutMarkupWrapper.toLocal8Bit());
|
||||
|
||||
// Obtain layout markup.
|
||||
skin.m_layoutMarkup = skin_node.namedItem(QSL("markup")).toElement().text();
|
||||
skin.m_layoutMarkup = QByteArray::fromBase64(skin.m_layoutMarkup.toLocal8Bit());
|
||||
|
||||
// Obtain enclosure hyperlink wrapper.
|
||||
skin.m_enclosureMarkup = skin_node.namedItem(QSL("markup_enclosure")).toElement().text();
|
||||
skin.m_enclosureMarkup = QByteArray::fromBase64(skin.m_enclosureMarkup.toLocal8Bit());
|
||||
|
||||
// Obtain other information.
|
||||
skin.m_baseName = QString(skin_name).replace(QDir::separator(), '/');
|
||||
|
||||
@ -144,7 +157,8 @@ Skin SkinFactory::skinInfo(const QString &skin_name, bool *ok) const {
|
||||
|
||||
if (ok != NULL) {
|
||||
*ok = !skin.m_author.isEmpty() && !skin.m_version.isEmpty() &&
|
||||
!skin.m_baseName.isEmpty() && !skin.m_email.isEmpty();
|
||||
!skin.m_baseName.isEmpty() && !skin.m_email.isEmpty() &&
|
||||
!skin.m_layoutMarkup.isEmpty();
|
||||
}
|
||||
|
||||
return skin;
|
||||
|
@ -32,6 +32,9 @@ struct Skin {
|
||||
QString m_email;
|
||||
QString m_version;
|
||||
QString m_rawData;
|
||||
QString m_layoutMarkupWrapper;
|
||||
QString m_layoutMarkup;
|
||||
QString m_enclosureMarkup;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(Skin)
|
||||
|
Loading…
x
Reference in New Issue
Block a user