remove newspaper view and unify "newspaper view" for single articles, they now use full previewer

This commit is contained in:
Martin Rotter 2023-11-20 12:58:39 +01:00
parent fa990b2610
commit dbb1b53974
11 changed files with 250 additions and 309 deletions

File diff suppressed because it is too large Load diff

View file

@ -224,7 +224,6 @@ QList<QAction*> FormMain::allActions() const {
actions << m_ui->m_actionFeedMoveTop;
actions << m_ui->m_actionFeedMoveBottom;
actions << m_ui->m_actionAddCategoryIntoSelectedItem;
actions << m_ui->m_actionViewSelectedItemsNewspaperMode;
actions << m_ui->m_actionSelectNextItem;
actions << m_ui->m_actionSelectPreviousItem;
actions << m_ui->m_actionSelectNextMessage;
@ -466,7 +465,7 @@ void FormMain::updateMessageButtonsAvailability() {
m_ui->m_actionMarkSelectedMessagesAsRead->setEnabled(atleast_one_message_selected);
m_ui->m_actionMarkSelectedMessagesAsUnread->setEnabled(atleast_one_message_selected);
m_ui->m_actionOpenSelectedMessagesInternallyNoTab->setEnabled(one_message_selected);
m_ui->m_actionOpenSelectedMessagesInternally->setEnabled(atleast_one_message_selected);
m_ui->m_actionOpenSelectedMessagesInternally->setEnabled(one_message_selected);
m_ui->m_actionOpenSelectedSourceArticlesExternally->setEnabled(atleast_one_message_selected);
m_ui->m_actionCopyUrlSelectedArticles->setEnabled(atleast_one_message_selected);
m_ui->m_actionSendMessageViaEmail->setEnabled(one_message_selected);
@ -501,7 +500,6 @@ void FormMain::updateFeedButtonsAvailability() {
m_ui->m_actionUpdateSelectedItemsWithCustomTimers->setEnabled(!critical_action_running);
m_ui->m_actionUpdateSelectedItems->setEnabled(!critical_action_running &&
(feed_selected || category_selected || service_selected));
m_ui->m_actionViewSelectedItemsNewspaperMode->setEnabled(anything_selected);
m_ui->m_actionExpandCollapseItem->setEnabled(category_selected || service_selected);
m_ui->m_actionExpandCollapseItemRecursively->setEnabled(category_selected || service_selected);
m_ui->m_actionServiceDelete->setEnabled(service_selected);
@ -612,7 +610,6 @@ void FormMain::setupIcons() {
m_ui->m_actionOpenSelectedMessagesInternally->setIcon(icon_theme_factory->fromTheme(QSL("document-open")));
m_ui->m_actionOpenSelectedMessagesInternallyNoTab->setIcon(icon_theme_factory->fromTheme(QSL("document-open")));
m_ui->m_actionSendMessageViaEmail->setIcon(icon_theme_factory->fromTheme(QSL("mail-send")));
m_ui->m_actionViewSelectedItemsNewspaperMode->setIcon(icon_theme_factory->fromTheme(QSL("format-justify-fill")));
m_ui->m_actionSelectNextItem->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down")));
m_ui->m_actionSelectPreviousItem->setIcon(icon_theme_factory->fromTheme(QSL("arrow-up")));
m_ui->m_actionSelectNextMessage->setIcon(icon_theme_factory->fromTheme(QSL("arrow-down")));
@ -947,10 +944,6 @@ void FormMain::createConnections() {
&QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(),
&FeedsView::editRecursiveFeeds);
connect(m_ui->m_actionViewSelectedItemsNewspaperMode,
&QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(),
&FeedsView::openSelectedItemsInNewspaperMode);
connect(m_ui->m_actionDeleteSelectedItem,
&QAction::triggered,
tabWidget()->feedMessageViewer()->feedsView(),

View file

@ -148,7 +148,6 @@
<addaction name="m_actionClearAllItems"/>
<addaction name="separator"/>
<addaction name="m_actionCopyUrlSelectedFeed"/>
<addaction name="m_actionViewSelectedItemsNewspaperMode"/>
<addaction name="m_actionMarkSelectedItemsAsRead"/>
<addaction name="m_actionMarkSelectedItemsAsUnread"/>
<addaction name="m_actionClearSelectedItems"/>
@ -431,17 +430,6 @@
<string notr="true"/>
</property>
</action>
<action name="m_actionViewSelectedItemsNewspaperMode">
<property name="text">
<string>View selected item in &amp;newspaper mode</string>
</property>
<property name="toolTip">
<string>Displays all messages from selected item in a new &quot;newspaper mode&quot; tab. Note that messages are not set as read automatically.</string>
</property>
<property name="shortcut">
<string notr="true"/>
</property>
</action>
<action name="m_actionSwitchMainWindow">
<property name="checked">
<bool>false</bool>

View file

@ -550,15 +550,6 @@ void FeedsView::markAllItemsRead() {
markAllItemsReadStatus(RootItem::ReadStatus::Read);
}
void FeedsView::openSelectedItemsInNewspaperMode() {
RootItem* selected_item = selectedItem();
const QList<Message> messages = m_sourceModel->messagesForItem(selected_item);
if (!messages.isEmpty()) {
emit openMessagesInNewspaperView(selected_item, messages);
}
}
void FeedsView::selectNextItem() {
QModelIndex index_next = moveCursor(QAbstractItemView::CursorAction::MoveDown, Qt::KeyboardModifier::NoModifier);
@ -656,9 +647,8 @@ QMenu* FeedsView::initializeContextMenuBin(RootItem* clicked_item) {
QList<QAction*> specific_actions = clicked_item->contextMenuFeedsList();
m_contextMenuBin->addActions(QList<QAction*>() << qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode
<< qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsRead
<< qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsUnread);
m_contextMenuBin->addActions({qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsRead,
qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsUnread});
if (!specific_actions.isEmpty()) {
m_contextMenuBin->addSeparator();
@ -683,7 +673,6 @@ QMenu* FeedsView::initializeContextMenuService(RootItem* clicked_item) {
qApp->mainForm()->m_ui->m_actionEditChildFeeds,
qApp->mainForm()->m_ui->m_actionEditChildFeedsRecursive,
qApp->mainForm()->m_ui->m_actionCopyUrlSelectedFeed,
qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode,
qApp->mainForm()->m_ui->m_actionExpandCollapseItem,
qApp->mainForm()->m_ui->m_actionExpandCollapseItemRecursively,
qApp->mainForm()->m_ui->m_actionRearrangeCategories,
@ -909,7 +898,6 @@ QMenu* FeedsView::initializeContextMenuCategories(RootItem* clicked_item) {
qApp->mainForm()->m_ui->m_actionEditChildFeeds,
qApp->mainForm()->m_ui->m_actionEditChildFeedsRecursive,
qApp->mainForm()->m_ui->m_actionCopyUrlSelectedFeed,
qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode,
qApp->mainForm()->m_ui->m_actionExpandCollapseItem,
qApp->mainForm()->m_ui->m_actionExpandCollapseItemRecursively,
qApp->mainForm()->m_ui->m_actionRearrangeCategories,
@ -962,7 +950,6 @@ QMenu* FeedsView::initializeContextMenuFeeds(RootItem* clicked_item) {
m_contextMenuFeeds->addActions(QList<QAction*>() << qApp->mainForm()->m_ui->m_actionUpdateSelectedItems
<< qApp->mainForm()->m_ui->m_actionEditSelectedItem
<< qApp->mainForm()->m_ui->m_actionCopyUrlSelectedFeed
<< qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode
<< qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsRead
<< qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsUnread
<< qApp->mainForm()->m_ui->m_actionDeleteSelectedItem);
@ -1008,9 +995,8 @@ QMenu* FeedsView::initializeContextMenuImportant(RootItem* clicked_item) {
QList<QAction*> specific_actions = clicked_item->contextMenuFeedsList();
m_contextMenuImportant->addActions(QList<QAction*>() << qApp->mainForm()->m_ui->m_actionViewSelectedItemsNewspaperMode
<< qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsRead
<< qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsUnread);
m_contextMenuImportant->addActions({qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsRead,
qApp->mainForm()->m_ui->m_actionMarkSelectedItemsAsUnread});
if (!specific_actions.isEmpty()) {
m_contextMenuImportant->addSeparator();
@ -1194,20 +1180,6 @@ void FeedsView::contextMenuEvent(QContextMenuEvent* event) {
}
void FeedsView::mouseDoubleClickEvent(QMouseEvent* event) {
QModelIndex idx = indexAt(event->pos());
if (idx.isValid()) {
RootItem* item = m_sourceModel->itemForIndex(m_proxyModel->mapToSource(idx));
if (item->kind() == RootItem::Kind::Feed || item->kind() == RootItem::Kind::Bin) {
const QList<Message> messages = m_sourceModel->messagesForItem(item);
if (!messages.isEmpty()) {
emit openMessagesInNewspaperView(item, messages);
}
}
}
QTreeView::mouseDoubleClickEvent(event);
}

View file

@ -58,9 +58,6 @@ class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
void markSelectedItemUnread();
void markAllItemsRead();
// Newspaper accessors.
void openSelectedItemsInNewspaperMode();
// Feed clearers.
void clearSelectedItems();
void clearAllItems();
@ -98,7 +95,6 @@ class RSSGUARD_DLLSPEC FeedsView : public BaseTreeView {
signals:
void itemSelected(RootItem* item);
void requestViewNextUnreadMessage();
void openMessagesInNewspaperView(RootItem* root, const QList<Message>& messages);
protected:
void drawBranches(QPainter* painter, const QRect& rect, const QModelIndex& index) const;

View file

@ -42,7 +42,7 @@ void MessagePreviewer::createConnections() {
}
MessagePreviewer::MessagePreviewer(QWidget* parent)
: QWidget(parent), m_mainLayout(new QGridLayout(this)), m_viewerLayout(new QStackedLayout()),
: TabContent(parent), m_mainLayout(new QGridLayout(this)), m_viewerLayout(new QStackedLayout()),
m_toolBar(new QToolBar(this)), m_msgBrowser(new WebBrowser(nullptr, this)), m_separator(nullptr),
m_btnLabels(QList<LabelToolbarAction*>()), m_itemDetails(new ItemDetails(this)), m_toolbarVisible(true) {
m_toolBar->setOrientation(Qt::Orientation::Vertical);

View file

@ -3,7 +3,7 @@
#ifndef MESSAGEPREVIEWER_H
#define MESSAGEPREVIEWER_H
#include <QToolButton>
#include "gui/tabcontent.h"
#include "core/message.h"
#include "services/abstract/label.h"
@ -11,6 +11,7 @@
#include <QAction>
#include <QPointer>
#include <QToolButton>
#include <QUrl>
class QGridLayout;
@ -32,7 +33,7 @@ class LabelToolbarAction : public QAction {
QPointer<Label> m_label;
};
class MessagePreviewer : public QWidget {
class MessagePreviewer : public TabContent {
Q_OBJECT
public:
@ -41,7 +42,7 @@ class MessagePreviewer : public QWidget {
void reloadFontSettings();
WebBrowser* webBrowser() const;
virtual WebBrowser* webBrowser() const;
public slots:
void setToolbarsVisible(bool visible);

View file

@ -634,15 +634,12 @@ void MessagesView::openSelectedSourceMessagesExternally() {
}
void MessagesView::openSelectedMessagesInternally() {
QList<Message> messages;
auto rws = selectionModel()->selectedRows();
for (const QModelIndex& index : std::as_const(rws)) {
messages << m_sourceModel->messageAt(m_proxyModel->mapToSource(index).row());
}
if (!rws.isEmpty()) {
auto msg = m_sourceModel->messageAt(m_proxyModel->mapToSource(rws.first()).row());
if (!messages.isEmpty()) {
emit openMessagesInNewspaperView(m_sourceModel->loadedItem(), messages);
emit openSingleMessageInNewTab(m_sourceModel->loadedItem(), msg);
}
}

View file

@ -85,7 +85,7 @@ class MessagesView : public BaseTreeView {
signals:
void openLinkNewTab(const QString& link);
void openLinkMiniBrowser(const QString& link);
void openMessagesInNewspaperView(RootItem* root, const QList<Message>& messages);
void openSingleMessageInNewTab(RootItem* root, const Message& message);
// Notify others about message selections.
void currentMessageChanged(const Message& message, RootItem* root);

View file

@ -6,6 +6,7 @@
#include "gui/dialogs/formmain.h"
#include "gui/feedmessageviewer.h"
#include "gui/feedsview.h"
#include "gui/messagepreviewer.h"
#include "gui/messagesview.h"
#include "gui/reusable/plaintoolbutton.h"
#include "gui/tabbar.h"
@ -123,13 +124,9 @@ void TabWidget::createConnections() {
connect(tabBar(), &TabBar::tabMoved, this, &TabWidget::fixContentsAfterMove);
connect(feedMessageViewer()->messagesView(),
&MessagesView::openMessagesInNewspaperView,
&MessagesView::openSingleMessageInNewTab,
this,
&TabWidget::addNewspaperView);
connect(feedMessageViewer()->feedsView(),
&FeedsView::openMessagesInNewspaperView,
this,
&TabWidget::addNewspaperView);
&TabWidget::addSingleMessageView);
}
void TabWidget::initializeTabs() {
@ -206,16 +203,18 @@ void TabWidget::closeCurrentTab() {
closeTab(currentIndex());
}
int TabWidget::addNewspaperView(RootItem* root, const QList<Message>& messages) {
WebBrowser* browser = new WebBrowser(nullptr, this);
int TabWidget::addSingleMessageView(RootItem* root, const Message& message) {
auto* browser = new MessagePreviewer(this);
auto* msg_mdl = qApp->mainForm()->tabWidget()->feedMessageViewer()->messagesView()->sourceModel();
int index = addTab(browser,
qApp->icons()->fromTheme(QSL("format-justify-fill")),
tr("Newspaper view"),
TabBar::TabType::Closable);
connect(browser, &MessagePreviewer::markMessageRead, msg_mdl, &MessagesModel::setMessageReadById);
connect(browser, &MessagePreviewer::markMessageImportant, msg_mdl, &MessagesModel::setMessageImportantById);
connect(browser, &MessagePreviewer::setMessageLabelIds, msg_mdl, &MessagesModel::setMessageLabelsById);
QTimer::singleShot(300, browser, [browser, root, messages]() {
browser->loadMessages(messages, root);
int index = addTab(browser, root->fullIcon(), message.m_title, TabBar::TabType::Closable);
QTimer::singleShot(500, browser, [browser, root, message]() {
browser->loadMessage(message, root);
});
return index;

View file

@ -73,7 +73,7 @@ class TabWidget : public QTabWidget {
// Displays download manager.
void showDownloadManager();
int addNewspaperView(RootItem* root, const QList<Message>& messages);
int addSingleMessageView(RootItem* root, const Message& message);
// Adds new WebBrowser tab to global TabWidget.
int addEmptyBrowser();