mirror of
https://github.com/martinrotter/rssguard.git
synced 2025-01-30 09:04:52 +01:00
Some unifications in msg viewer.
This commit is contained in:
parent
3a0cbba696
commit
cb2922f0bc
@ -4,12 +4,17 @@
|
||||
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/searchtextwidget.h"
|
||||
#include "miscellaneous/application.h"
|
||||
#include "miscellaneous/databasequeries.h"
|
||||
#include "network-web/webfactory.h"
|
||||
#include "services/abstract/serviceroot.h"
|
||||
|
||||
#include "gui/messagetextbrowser.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QKeyEvent>
|
||||
#include <QPainter>
|
||||
#include <QScrollBar>
|
||||
#include <QToolBar>
|
||||
#include <QToolTip>
|
||||
@ -17,20 +22,20 @@
|
||||
void MessagePreviewer::createConnections() {
|
||||
installEventFilter(this);
|
||||
|
||||
connect(m_ui.m_searchWidget, &SearchTextWidget::cancelSearch, this, [this]() {
|
||||
m_ui.m_txtMessage->textCursor().clearSelection();
|
||||
m_ui.m_txtMessage->moveCursor(QTextCursor::MoveOperation::Left);
|
||||
connect(m_searchWidget, &SearchTextWidget::cancelSearch, this, [this]() {
|
||||
m_txtMessage->textCursor().clearSelection();
|
||||
m_txtMessage->moveCursor(QTextCursor::MoveOperation::Left);
|
||||
});
|
||||
connect(m_ui.m_searchWidget, &SearchTextWidget::searchForText, this, [this](const QString& text, bool backwards) {
|
||||
connect(m_searchWidget, &SearchTextWidget::searchForText, this, [this](const QString& text, bool backwards) {
|
||||
if (backwards) {
|
||||
m_ui.m_txtMessage->find(text, QTextDocument::FindFlag::FindBackward);
|
||||
m_txtMessage->find(text, QTextDocument::FindFlag::FindBackward);
|
||||
}
|
||||
else {
|
||||
m_ui.m_txtMessage->find(text);
|
||||
m_txtMessage->find(text);
|
||||
}
|
||||
});
|
||||
|
||||
connect(m_ui.m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl& url) {
|
||||
connect(m_txtMessage, &QTextBrowser::anchorClicked, [=](const QUrl& url) {
|
||||
if (url.toString().startsWith(INTERNAL_URL_PASSATTACHMENT) &&
|
||||
m_root != nullptr &&
|
||||
m_root->getParentServiceRoot()->downloadAttachmentOnMyOwn(url)) {
|
||||
@ -94,7 +99,7 @@ void MessagePreviewer::createConnections() {
|
||||
&QAction::triggered,
|
||||
this,
|
||||
&MessagePreviewer::switchMessageImportance);
|
||||
connect(m_ui.m_txtMessage,
|
||||
connect(m_txtMessage,
|
||||
QOverload<const QUrl&>::of(&QTextBrowser::highlighted),
|
||||
[=](const QUrl& url) {
|
||||
Q_UNUSED(url)
|
||||
@ -102,16 +107,28 @@ void MessagePreviewer::createConnections() {
|
||||
});
|
||||
}
|
||||
|
||||
MessagePreviewer::MessagePreviewer(QWidget* parent) : QWidget(parent) {
|
||||
m_ui.setupUi(this);
|
||||
m_ui.m_txtMessage->viewport()->setAutoFillBackground(true);
|
||||
m_toolBar = new QToolBar(this);
|
||||
MessagePreviewer::MessagePreviewer(QWidget* parent)
|
||||
: QWidget(parent), m_layout(new QGridLayout(this)), m_toolBar(new QToolBar(this)),
|
||||
m_txtMessage(new MessageTextBrowser(this)), m_searchWidget(new SearchTextWidget(this)) {
|
||||
|
||||
m_txtMessage->setAutoFillBackground(true);
|
||||
m_txtMessage->setFrameShape(QFrame::StyledPanel);
|
||||
m_txtMessage->setFrameShadow(QFrame::Plain);
|
||||
m_txtMessage->setTabChangesFocus(true);
|
||||
m_txtMessage->setOpenLinks(false);
|
||||
m_txtMessage->viewport()->setAutoFillBackground(true);
|
||||
|
||||
m_toolBar->setOrientation(Qt::Vertical);
|
||||
m_ui.m_layout->addWidget(m_toolBar, 0, 0, -1, 1);
|
||||
|
||||
m_layout->setContentsMargins(3, 3, 3, 3);
|
||||
m_layout->addWidget(m_txtMessage, 0, 1, 1, 1);
|
||||
m_layout->addWidget(m_searchWidget, 1, 1, 1, 1);
|
||||
m_layout->addWidget(m_toolBar, 0, 0, -1, 1);
|
||||
|
||||
createConnections();
|
||||
|
||||
m_actionSwitchImportance->setCheckable(true);
|
||||
m_ui.m_searchWidget->hide();
|
||||
m_searchWidget->hide();
|
||||
|
||||
reloadFontSettings();
|
||||
clear();
|
||||
@ -122,11 +139,11 @@ void MessagePreviewer::reloadFontSettings() {
|
||||
QFont fon;
|
||||
|
||||
fon.fromString(settings->value(GROUP(Messages), SETTING(Messages::PreviewerFontStandard)).toString());
|
||||
m_ui.m_txtMessage->setFont(fon);
|
||||
m_txtMessage->setFont(fon);
|
||||
}
|
||||
|
||||
void MessagePreviewer::clear() {
|
||||
m_ui.m_txtMessage->clear();
|
||||
m_txtMessage->clear();
|
||||
m_pictures.clear();
|
||||
hide();
|
||||
}
|
||||
@ -140,12 +157,12 @@ void MessagePreviewer::loadMessage(const Message& message, RootItem* root) {
|
||||
m_root = root;
|
||||
|
||||
if (!m_root.isNull()) {
|
||||
m_ui.m_searchWidget->hide();
|
||||
m_searchWidget->hide();
|
||||
m_actionSwitchImportance->setChecked(m_message.m_isImportant);
|
||||
m_ui.m_txtMessage->setHtml(prepareHtmlForMessage(m_message));
|
||||
m_txtMessage->setHtml(prepareHtmlForMessage(m_message));
|
||||
updateButtons();
|
||||
show();
|
||||
m_ui.m_txtMessage->verticalScrollBar()->triggerAction(QScrollBar::SliderToMinimum);
|
||||
m_txtMessage->verticalScrollBar()->triggerAction(QScrollBar::SliderToMinimum);
|
||||
}
|
||||
}
|
||||
|
||||
@ -209,9 +226,9 @@ bool MessagePreviewer::eventFilter(QObject* watched, QEvent* event) {
|
||||
auto* key_event = static_cast<QKeyEvent*>(event);
|
||||
|
||||
if (key_event->matches(QKeySequence::StandardKey::Find)) {
|
||||
m_ui.m_searchWidget->clear();
|
||||
m_ui.m_searchWidget->show();
|
||||
m_ui.m_searchWidget->setFocus();
|
||||
m_searchWidget->clear();
|
||||
m_searchWidget->show();
|
||||
m_searchWidget->setFocus();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -5,19 +5,17 @@
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include "ui_messagepreviewer.h"
|
||||
|
||||
#include "core/message.h"
|
||||
#include "services/abstract/rootitem.h"
|
||||
|
||||
#include <QPointer>
|
||||
|
||||
namespace Ui {
|
||||
class MessagePreviewer;
|
||||
}
|
||||
|
||||
class QGridLayout;
|
||||
class QToolBar;
|
||||
|
||||
class MessageTextBrowser;
|
||||
class SearchTextWidget;
|
||||
|
||||
class MessagePreviewer : public QWidget {
|
||||
Q_OBJECT
|
||||
|
||||
@ -49,9 +47,10 @@ class MessagePreviewer : public QWidget {
|
||||
void updateButtons();
|
||||
QString prepareHtmlForMessage(const Message& message);
|
||||
|
||||
QGridLayout* m_layout;
|
||||
QToolBar* m_toolBar;
|
||||
|
||||
Ui::MessagePreviewer m_ui;
|
||||
MessageTextBrowser* m_txtMessage;
|
||||
SearchTextWidget* m_searchWidget;
|
||||
Message m_message;
|
||||
QStringList m_pictures;
|
||||
QPointer<RootItem> m_root;
|
||||
|
@ -1,65 +0,0 @@
|
||||
<?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="QGridLayout" name="m_layout">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<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>
|
||||
<item row="1" column="1">
|
||||
<widget class="SearchTextWidget" name="m_searchWidget" native="true"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>MessageTextBrowser</class>
|
||||
<extends>QTextBrowser</extends>
|
||||
<header>messagetextbrowser.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>SearchTextWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>searchtextwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
@ -27,7 +27,6 @@ void NewspaperPreviewer::showMoreMessages() {
|
||||
connect(prev, &MessagePreviewer::markMessageRead, this, &NewspaperPreviewer::markMessageRead);
|
||||
connect(prev, &MessagePreviewer::markMessageImportant, this, &NewspaperPreviewer::markMessageImportant);
|
||||
|
||||
margins.setRight(0);
|
||||
prev->layout()->setContentsMargins(margins);
|
||||
prev->setFixedHeight(300);
|
||||
prev->loadMessage(msg, m_root);
|
||||
|
@ -407,7 +407,7 @@ else {
|
||||
gui/messagetextbrowser.cpp \
|
||||
gui/newspaperpreviewer.cpp
|
||||
|
||||
FORMS += gui/messagepreviewer.ui \
|
||||
FORMS += \
|
||||
gui/newspaperpreviewer.ui
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,8 @@
|
||||
#include <QColor>
|
||||
|
||||
class Label : public RootItem {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit Label(RootItem* parent_item = nullptr);
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
#include "services/abstract/rootitem.h"
|
||||
|
||||
class LabelsNode : public RootItem {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit LabelsNode(RootItem* parent_item = nullptr);
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user