Better newspaper view.
This commit is contained in:
parent
724165b0dd
commit
e9b7961732
@ -9,7 +9,7 @@ Main:
|
||||
Added:
|
||||
|
||||
▪ RSS Guard now automatically switches to SQLite backend if MySQL is not available on program startup.
|
||||
▪ Opened web browser tabs now can be saved. (issue #126)
|
||||
▪ Newspaper view now allows marking individual messages read/unread/starred/unstarred.
|
||||
▪ Added experimental support for tweakable statusbar. (issue #158)
|
||||
▪ Opening of download manager when new file download starts is now optional. (issue #165)
|
||||
|
||||
|
@ -262,9 +262,9 @@ void FeedMessageViewer::createConnections() {
|
||||
|
||||
// Message openers.
|
||||
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
|
||||
form_main->m_ui->m_tabWidget, SLOT(addBrowserWithMessages(RootItem*,QList<Message>)));
|
||||
connect(m_feedsView, SIGNAL(openMessagesInNewspaperView(QList<Message>)),
|
||||
form_main->m_ui->m_tabWidget, SLOT(addBrowserWithMessages(QList<Message>)));
|
||||
m_messagesView, SLOT(createNewspaperView(RootItem*,QList<Message>)));
|
||||
connect(m_feedsView, SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
|
||||
m_messagesView, SLOT(createNewspaperView(RootItem*,QList<Message>)));
|
||||
|
||||
// Toolbar forwardings.
|
||||
connect(form_main->m_ui->m_actionAddFeedIntoSelectedAccount, SIGNAL(triggered()),
|
||||
|
@ -319,10 +319,11 @@ void FeedsView::markAllItemsRead() {
|
||||
}
|
||||
|
||||
void FeedsView::openSelectedItemsInNewspaperMode() {
|
||||
const QList<Message> messages = m_sourceModel->messagesForItem(selectedItem());
|
||||
RootItem *selected_item = selectedItem();
|
||||
const QList<Message> messages = m_sourceModel->messagesForItem(selected_item);
|
||||
|
||||
if (!messages.isEmpty()) {
|
||||
emit openMessagesInNewspaperView(messages);
|
||||
emit openMessagesInNewspaperView(selected_item, messages);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -99,7 +99,7 @@ class FeedsView : public QTreeView {
|
||||
void itemSelected(RootItem *item);
|
||||
|
||||
// Requests opening of given messages in newspaper mode.
|
||||
void openMessagesInNewspaperView(const QList<Message> &messages);
|
||||
void openMessagesInNewspaperView(RootItem *root, const QList<Message> &messages);
|
||||
|
||||
private slots:
|
||||
void markSelectedItemReadStatus(RootItem::ReadStatus read);
|
||||
|
@ -88,13 +88,14 @@ void MessagePreviewer::loadMessage(const Message &message, RootItem *root) {
|
||||
m_message = message;
|
||||
m_root = root;
|
||||
|
||||
m_actionMarkRead->setEnabled(!message.m_isRead);
|
||||
m_actionMarkUnread->setEnabled(message.m_isRead);
|
||||
m_actionSwitchImportance->setChecked(message.m_isImportant);
|
||||
|
||||
if (!m_root.isNull()) {
|
||||
m_ui->m_lblTitle->setText(message.m_title);
|
||||
m_ui->m_txtMessage->setHtml(prepareHtmlForMessage(message));
|
||||
updateButtons();
|
||||
m_actionSwitchImportance->setChecked(m_message.m_isImportant);
|
||||
|
||||
m_ui->m_lblTitle->setText(m_message.m_title);
|
||||
m_ui->m_txtMessage->setHtml(prepareHtmlForMessage(m_message));
|
||||
|
||||
updateTitle();
|
||||
show();
|
||||
|
||||
m_ui->m_txtMessage->verticalScrollBar()->triggerAction(QScrollBar::SliderToMinimum);
|
||||
@ -119,6 +120,9 @@ void MessagePreviewer::markMessageAsRead() {
|
||||
RootItem::Read);
|
||||
|
||||
emit requestMessageListReload(false);
|
||||
m_message.m_isRead = true;
|
||||
updateButtons();
|
||||
updateTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -141,6 +145,9 @@ void MessagePreviewer::markMessageAsUnread() {
|
||||
RootItem::Unread);
|
||||
|
||||
emit requestMessageListReload(false);
|
||||
m_message.m_isRead = false;
|
||||
updateButtons();
|
||||
updateTitle();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -163,14 +170,26 @@ void MessagePreviewer::switchMessageImportance(bool checked) {
|
||||
m_root->getParentServiceRoot()->onBeforeSwitchMessageImportance(m_root.data(),
|
||||
QList<ImportanceChange>() << ImportanceChange(m_message,
|
||||
m_message.m_isImportant ?
|
||||
RootItem::NotImportant :
|
||||
RootItem::Important));
|
||||
RootItem::NotImportant :
|
||||
RootItem::Important));
|
||||
|
||||
emit requestMessageListReload(false);
|
||||
m_message.m_isImportant = checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void MessagePreviewer::updateButtons() {
|
||||
m_actionMarkRead->setEnabled(!m_message.m_isRead);
|
||||
m_actionMarkUnread->setEnabled(m_message.m_isRead);
|
||||
}
|
||||
|
||||
void MessagePreviewer::updateTitle() {
|
||||
QFont fon = m_ui->m_lblTitle->font();
|
||||
fon.setBold(!m_message.m_isRead);
|
||||
m_ui->m_lblTitle->setFont(fon);
|
||||
}
|
||||
|
||||
QString MessagePreviewer::prepareHtmlForMessage(const Message &message) {
|
||||
QString html = QString("<p>[url] <a href=\"%1\">%1</a></p>").arg(message.m_url);
|
||||
|
||||
|
@ -54,6 +54,8 @@ class MessagePreviewer : public QWidget {
|
||||
void requestMessageListReload(bool mark_current_as_read);
|
||||
|
||||
private:
|
||||
void updateButtons();
|
||||
void updateTitle();
|
||||
QString prepareHtmlForMessage(const Message &message);
|
||||
|
||||
QToolBar *m_toolBar;
|
||||
|
@ -46,7 +46,7 @@
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
<property name="margin">
|
||||
<number>0</number>
|
||||
<number>5</number>
|
||||
</property>
|
||||
<property name="textInteractionFlags">
|
||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "network-web/webfactory.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/messagebox.h"
|
||||
#include "gui/newspaperpreviewer.h"
|
||||
#include "gui/styleditemdelegatewithoutfocus.h"
|
||||
|
||||
#include <QKeyEvent>
|
||||
@ -466,6 +467,17 @@ void MessagesView::filterMessages(MessagesModel::MessageHighlighter filter) {
|
||||
m_sourceModel->highlightMessages(filter);
|
||||
}
|
||||
|
||||
void MessagesView::createNewspaperView(RootItem *selected_item, const QList<Message> &messages) {
|
||||
NewspaperPreviewer *prev = new NewspaperPreviewer(selected_item, messages, this);
|
||||
int index = qApp->mainForm()->tabWidget()->addTab(prev,
|
||||
qApp->icons()->fromTheme(QSL("item-newspaper")),
|
||||
tr("Newspaper view"),
|
||||
TabBar::Closable);
|
||||
qApp->mainForm()->tabWidget()->setCurrentIndex(index);
|
||||
|
||||
connect(prev, SIGNAL(requestMessageListReload(bool)), this, SLOT(reloadSelections(bool)));
|
||||
}
|
||||
|
||||
void MessagesView::adjustColumns() {
|
||||
if (header()->count() > 0 && !m_columnsAdjusted) {
|
||||
m_columnsAdjusted = true;
|
||||
|
@ -78,6 +78,8 @@ class MessagesView : public QTreeView {
|
||||
void searchMessages(const QString &pattern);
|
||||
void filterMessages(MessagesModel::MessageHighlighter filter);
|
||||
|
||||
void createNewspaperView(RootItem *selected_item, const QList<Message> &messages);
|
||||
|
||||
private slots:
|
||||
// Marks given indexes as selected.
|
||||
void reselectIndexes(const QModelIndexList &indexes);
|
||||
|
@ -18,11 +18,15 @@
|
||||
#include "gui/newspaperpreviewer.h"
|
||||
|
||||
#include "gui/messagepreviewer.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "miscellaneous/application.h"
|
||||
|
||||
#include <QScrollBar>
|
||||
|
||||
|
||||
NewspaperPreviewer::NewspaperPreviewer(RootItem *root, QList<Message> messages, QWidget *parent)
|
||||
: TabContent(parent), m_ui(new Ui::NewspaperPreviewer), m_root(root), m_messages(messages) {
|
||||
m_ui->setupUi(this);
|
||||
m_ui->setupUi(this);
|
||||
connect(m_ui->m_btnShowMoreMessages, SIGNAL(clicked(bool)), this, SLOT(showMoreMessages()));
|
||||
showMoreMessages();
|
||||
}
|
||||
@ -32,12 +36,13 @@ NewspaperPreviewer::~NewspaperPreviewer() {
|
||||
|
||||
void NewspaperPreviewer::showMoreMessages() {
|
||||
if (!m_root.isNull()) {
|
||||
int current_scroll = m_ui->scrollArea->verticalScrollBar()->value();
|
||||
|
||||
for (int i = 0; i < 10 && !m_messages.isEmpty(); i++) {
|
||||
Message msg = m_messages.takeFirst();
|
||||
MessagePreviewer *prev = new MessagePreviewer(this);
|
||||
|
||||
connect(prev, SIGNAL(requestMessageListReload(bool)), this, SIGNAL(requestMessageListReload(bool)));
|
||||
|
||||
prev->setFixedHeight(300);
|
||||
prev->loadMessage(msg, m_root);
|
||||
m_ui->m_layout->insertWidget(m_ui->m_layout->count() - 2, prev);
|
||||
@ -45,14 +50,12 @@ void NewspaperPreviewer::showMoreMessages() {
|
||||
|
||||
m_ui->m_btnShowMoreMessages->setText(tr("Show more messages (%n remaining)", "", m_messages.size()));
|
||||
m_ui->m_btnShowMoreMessages->setEnabled(!m_messages.isEmpty());
|
||||
|
||||
// TODO: pokračovat, pridat signal void requestMessageListReload(bool mark_current_as_read);
|
||||
// ktery bude forwardovar tentyz signal z toho message previeweru kazdeho
|
||||
// a ten signal navazat na obnoveni seznamu zprav
|
||||
//
|
||||
// taky opravit spojeni v pripade ze se zada o novinovy nahled z feedviewu
|
||||
m_ui->scrollArea->verticalScrollBar()->setValue(current_scroll);
|
||||
}
|
||||
else {
|
||||
// TODO: ukazat chybu
|
||||
qApp->showGuiMessage(tr("Cannot show more messages"),
|
||||
tr("Cannot show more messages because parent feed was removed."),
|
||||
QSystemTrayIcon::Warning,
|
||||
qApp->mainForm(), true);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
#include "gui/newspaperpreviewer.h"
|
||||
|
||||
#include <QMenu>
|
||||
#include <QToolButton>
|
||||
@ -240,11 +239,6 @@ int TabWidget::insertTab(int index, QWidget *widget, const QString &label, const
|
||||
return tab_index;
|
||||
}
|
||||
|
||||
int TabWidget::addBrowserWithMessages(RootItem *root, const QList<Message> &messages) {
|
||||
NewspaperPreviewer *prev = new NewspaperPreviewer(root, messages, this);
|
||||
return addTab(prev, qApp->icons()->fromTheme(QSL("item-newspaper")), tr("Newspaper view"), TabBar::Closable);
|
||||
}
|
||||
|
||||
void TabWidget::changeIcon(int index, const QIcon &new_icon) {
|
||||
setTabIcon(index, new_icon);
|
||||
}
|
||||
|
@ -111,9 +111,6 @@ class TabWidget : public QTabWidget {
|
||||
// Closes all "closable" tabs except the active tab.
|
||||
void closeAllTabsExceptCurrent();
|
||||
|
||||
// Open single or multiple (newspaper mode) messages in new tab.
|
||||
int addBrowserWithMessages(RootItem *root, const QList<Message> &messages);
|
||||
|
||||
private:
|
||||
PlainToolButton *m_btnMainMenu;
|
||||
QMenu *m_menuMain;
|
||||
|
Loading…
x
Reference in New Issue
Block a user