Save work.
This commit is contained in:
parent
27d77bc5d7
commit
d580c75ae4
@ -258,10 +258,10 @@ void FeedMessageViewer::createConnections() {
|
||||
|
||||
// Message openers.
|
||||
connect(m_messagesView, SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
|
||||
m_messagesView, SLOT(createNewspaperView(RootItem*,QList<Message>)));
|
||||
qApp->mainForm()->tabWidget(), SLOT(addNewspaperView(RootItem*,QList<Message>));
|
||||
connect(m_feedsView, SIGNAL(openMessagesInNewspaperView(RootItem*,QList<Message>)),
|
||||
m_messagesView, SLOT(createNewspaperView(RootItem*,QList<Message>)));
|
||||
|
||||
qApp->mainForm()->tabWidget(), SLOT(addNewspaperView(RootItem*,QList<Message>)));
|
||||
|
||||
// Toolbar forwardings.
|
||||
connect(form_main->m_ui->m_actionAddFeedIntoSelectedAccount, SIGNAL(triggered()),
|
||||
m_feedsView, SLOT(addFeedIntoSelectedAccount()));
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "gui/tabbar.h"
|
||||
#include "gui/feedmessageviewer.h"
|
||||
#include "gui/webbrowser.h"
|
||||
#include "gui/plaintoolbutton.h"
|
||||
#include "gui/dialogs/formmain.h"
|
||||
|
||||
@ -202,6 +203,67 @@ void TabWidget::closeAllTabsExceptCurrent() {
|
||||
}
|
||||
}
|
||||
|
||||
int TabWidget::addNewspaperView(RootItem *root, const QList<Message> &messages) {
|
||||
WebBrowser *prev = new WebBrowser(this);
|
||||
int index = addTab(prev, qApp->icons()->fromTheme(QSL("text-x-script")), tr("Newspaper view"), TabBar::Closable);
|
||||
|
||||
setCurrentIndex(index);
|
||||
prev->loadMessages(messages, root);
|
||||
|
||||
return index;
|
||||
}
|
||||
|
||||
int TabWidget::addEmptyBrowser() {
|
||||
return addBrowser(false, true);
|
||||
}
|
||||
|
||||
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
||||
return addBrowser(true, false, initial_url);
|
||||
}
|
||||
|
||||
int TabWidget::addLinkedBrowser(const QString &initial_url) {
|
||||
return addLinkedBrowser(QUrl(initial_url));
|
||||
}
|
||||
|
||||
int TabWidget::addBrowser(bool move_after_current, bool make_active, const QUrl &initial_url) {
|
||||
// Create new WebBrowser.
|
||||
WebBrowser *browser = new WebBrowser(this);
|
||||
int final_index;
|
||||
|
||||
if (move_after_current) {
|
||||
// Insert web browser after current tab.
|
||||
final_index = insertTab(currentIndex() + 1, browser, qApp->icons()->fromTheme(QSL("text-html")),
|
||||
tr("Web browser"), TabBar::Closable);
|
||||
}
|
||||
else {
|
||||
// Add new browser as the last tab.
|
||||
final_index = addTab(browser, qApp->icons()->fromTheme(QSL("text-html")),
|
||||
//: Web browser default tab title.
|
||||
tr("Web browser"),
|
||||
TabBar::Closable);
|
||||
}
|
||||
|
||||
// Make connections.
|
||||
connect(browser, SIGNAL(titleChanged(int,QString)), this, SLOT(changeTitle(int,QString)));
|
||||
connect(browser, SIGNAL(iconChanged(int,QIcon)), this, SLOT(changeIcon(int,QIcon)));
|
||||
|
||||
// Setup the tab index.
|
||||
browser->setIndex(final_index);
|
||||
|
||||
// Load initial web page if desired.
|
||||
if (initial_url.isValid()) {
|
||||
browser->loadUrl(initial_url);
|
||||
}
|
||||
|
||||
// Make new web browser active if desired.
|
||||
if (make_active) {
|
||||
setCurrentIndex(final_index);
|
||||
browser->setFocus(Qt::OtherFocusReason);
|
||||
}
|
||||
|
||||
return final_index;
|
||||
}
|
||||
|
||||
void TabWidget::removeTab(int index, bool clear_from_memory) {
|
||||
if (clear_from_memory) {
|
||||
widget(index)->deleteLater();
|
||||
|
@ -18,16 +18,17 @@
|
||||
#ifndef TABWIDGET_H
|
||||
#define TABWIDGET_H
|
||||
|
||||
#include <QTabWidget>
|
||||
|
||||
#include "gui/tabbar.h"
|
||||
#include "gui/tabcontent.h"
|
||||
#include "core/message.h"
|
||||
|
||||
#include <QTabWidget>
|
||||
#include <QUrl>
|
||||
|
||||
|
||||
class QMenu;
|
||||
class PlainToolButton;
|
||||
class Message;
|
||||
class RootItem;
|
||||
class FeedMessageViewer;
|
||||
|
||||
@ -111,6 +112,19 @@ class TabWidget : public QTabWidget {
|
||||
// Closes all "closable" tabs except the active tab.
|
||||
void closeAllTabsExceptCurrent();
|
||||
|
||||
int addNewspaperView(RootItem *root, const QList<Message> &messages);
|
||||
|
||||
// Adds new WebBrowser tab to global TabWidget.
|
||||
int addEmptyBrowser();
|
||||
|
||||
// Adds new WebBrowser with link. This is used when user
|
||||
// selects to "Open link in new tab.".
|
||||
int addLinkedBrowser(const QUrl &initial_url = QUrl());
|
||||
int addLinkedBrowser(const QString &initial_url);
|
||||
|
||||
// General method for adding WebBrowsers.
|
||||
int addBrowser(bool move_after_current, bool make_active, const QUrl &initial_url = QUrl());
|
||||
|
||||
private:
|
||||
PlainToolButton *m_btnMainMenu;
|
||||
QMenu *m_menuMain;
|
||||
|
@ -52,8 +52,8 @@ void WebBrowser::createConnections() {
|
||||
connect(m_webView, SIGNAL(loadFinished(bool)), this, SLOT(onLoadingFinished(bool)));
|
||||
|
||||
// Forward title/icon changes.
|
||||
//connect(m_webView, SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString)));
|
||||
//connect(m_webView, SIGNAL(iconChanged(QIcon)), this, SLOT(onIconChanged(QIcon)));
|
||||
connect(m_webView, SIGNAL(titleChanged(QString)), this, SLOT(onTitleChanged(QString)));
|
||||
connect(m_webView, SIGNAL(iconChanged(QIcon)), this, SLOT(onIconChanged(QIcon)));
|
||||
}
|
||||
|
||||
void WebBrowser::updateUrl(const QUrl &url) {
|
||||
@ -164,6 +164,20 @@ void WebBrowser::receiveMessageStatusChangeRequest(int message_id, WebPage::Mess
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::onTitleChanged(const QString &new_title) {
|
||||
if (new_title.isEmpty()) {
|
||||
//: Webbrowser tab title when no title is available.
|
||||
emit titleChanged(m_index, tr("No title"));
|
||||
}
|
||||
else {
|
||||
emit titleChanged(m_index, new_title);
|
||||
}
|
||||
}
|
||||
|
||||
void WebBrowser::onIconChanged(const QIcon &icon) {
|
||||
emit iconChanged(m_index, m_webView->icon());
|
||||
}
|
||||
|
||||
void WebBrowser::initializeLayout() {
|
||||
m_toolBar->setFloatable(false);
|
||||
m_toolBar->setMovable(false);
|
||||
|
@ -66,12 +66,21 @@ class WebBrowser : public TabContent {
|
||||
|
||||
private slots:
|
||||
void updateUrl(const QUrl &url);
|
||||
|
||||
void onLoadingStarted();
|
||||
void onLoadingProgress(int progress);
|
||||
void onLoadingFinished(bool success);
|
||||
|
||||
void receiveMessageStatusChangeRequest(int message_id, WebPage::MessageStatusChange change);
|
||||
|
||||
void onTitleChanged(const QString &new_title);
|
||||
void onIconChanged(const QIcon &icon);
|
||||
|
||||
signals:
|
||||
// Title/icon is changed.
|
||||
void iconChanged(int index, const QIcon &icon);
|
||||
void titleChanged(int index, const QString &title);
|
||||
|
||||
void markMessageRead(int id, RootItem::ReadStatus read);
|
||||
void markMessageImportant(int id, RootItem::Importance important);
|
||||
void requestMessageListReload(bool mark_current_as_read);
|
||||
|
Loading…
x
Reference in New Issue
Block a user