Fixed #100.
This commit is contained in:
parent
7498565be8
commit
5f5841aeb2
6 changed files with 52 additions and 21 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
Fixed:
|
Fixed:
|
||||||
<ul>
|
<ul>
|
||||||
<li>Fixed issue #53 - removing of duplicate messages. Feature is available globally in "Settings -> Messages".</li>
|
<li>Fixed issue #53 - removing of duplicate messages. Feature is available globally in "Settings -> Messages".</li>
|
||||||
|
<li>Fixed issue #100 - saving HTML web pages.</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
|
|
|
||||||
|
|
@ -107,8 +107,6 @@ void FormImportExport::selectExportFile() {
|
||||||
QString selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"),
|
QString selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"),
|
||||||
qApp->homeFolderPath(), filter, &selected_filter);
|
qApp->homeFolderPath(), filter, &selected_filter);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!selected_file.isEmpty()) {
|
if (!selected_file.isEmpty()) {
|
||||||
if (selected_filter == filter_opml20) {
|
if (selected_filter == filter_opml20) {
|
||||||
m_conversionType = OPML20;
|
m_conversionType = OPML20;
|
||||||
|
|
|
||||||
|
|
@ -376,13 +376,18 @@ void FormMain::loadWebBrowserMenu(int index) {
|
||||||
WebBrowser *active_browser = m_ui->m_tabWidget->widget(index)->webBrowser();
|
WebBrowser *active_browser = m_ui->m_tabWidget->widget(index)->webBrowser();
|
||||||
|
|
||||||
m_ui->m_menuCurrentTab->clear();
|
m_ui->m_menuCurrentTab->clear();
|
||||||
|
|
||||||
if (active_browser != NULL) {
|
if (active_browser != NULL) {
|
||||||
|
m_ui->m_menuCurrentTab->setEnabled(true);
|
||||||
m_ui->m_menuCurrentTab->addActions(active_browser->globalMenu());
|
m_ui->m_menuCurrentTab->addActions(active_browser->globalMenu());
|
||||||
|
|
||||||
if (m_ui->m_menuCurrentTab->actions().size() == 0) {
|
if (m_ui->m_menuCurrentTab->actions().size() == 0) {
|
||||||
m_ui->m_menuCurrentTab->insertAction(NULL, m_ui->m_actionNoActions);
|
m_ui->m_menuCurrentTab->insertAction(NULL, m_ui->m_actionNoActions);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
m_ui->m_menuCurrentTab->setEnabled(false);
|
||||||
|
}
|
||||||
|
|
||||||
m_ui->m_actionCloseCurrentTab->setEnabled(m_ui->m_tabWidget->tabBar()->tabType(index) == TabBar::Closable);
|
m_ui->m_actionCloseCurrentTab->setEnabled(m_ui->m_tabWidget->tabBar()->tabType(index) == TabBar::Closable);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -221,8 +221,7 @@ void TabWidget::removeTab(int index) {
|
||||||
QTabWidget::removeTab(index);
|
QTabWidget::removeTab(index);
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::addTab(TabContent *widget, const QIcon &icon,
|
int TabWidget::addTab(TabContent *widget, const QIcon &icon, const QString &label, const TabBar::TabType &type) {
|
||||||
const QString &label, const TabBar::TabType &type) {
|
|
||||||
int index = QTabWidget::addTab(widget, icon, label);
|
int index = QTabWidget::addTab(widget, icon, label);
|
||||||
tabBar()->setTabType(index, type);
|
tabBar()->setTabType(index, type);
|
||||||
|
|
||||||
|
|
@ -236,16 +235,14 @@ int TabWidget::addTab(TabContent *widget, const QString &label, const TabBar::Ta
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::insertTab(int index, QWidget *widget, const QIcon &icon,
|
int TabWidget::insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label, const TabBar::TabType &type) {
|
||||||
const QString &label, const TabBar::TabType &type) {
|
|
||||||
int tab_index = QTabWidget::insertTab(index, widget, icon, label);
|
int tab_index = QTabWidget::insertTab(index, widget, icon, label);
|
||||||
tabBar()->setTabType(tab_index, type);
|
tabBar()->setTabType(tab_index, type);
|
||||||
|
|
||||||
return tab_index;
|
return tab_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::insertTab(int index, QWidget *widget, const QString &label,
|
int TabWidget::insertTab(int index, QWidget *widget, const QString &label, const TabBar::TabType &type) {
|
||||||
const TabBar::TabType &type) {
|
|
||||||
int tab_index = QTabWidget::insertTab(index, widget, label);
|
int tab_index = QTabWidget::insertTab(index, widget, label);
|
||||||
tabBar()->setTabType(tab_index, type);
|
tabBar()->setTabType(tab_index, type);
|
||||||
|
|
||||||
|
|
@ -271,14 +268,10 @@ int TabWidget::addLinkedBrowser(const QString &initial_url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
||||||
return addBrowser(qApp->settings()->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool(),
|
return addBrowser(qApp->settings()->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool(), false, initial_url);
|
||||||
false,
|
|
||||||
initial_url);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int TabWidget::addBrowser(bool move_after_current,
|
int TabWidget::addBrowser(bool move_after_current, bool make_active, const QUrl &initial_url) {
|
||||||
bool make_active,
|
|
||||||
const QUrl &initial_url) {
|
|
||||||
// Create new WebBrowser.
|
// Create new WebBrowser.
|
||||||
WebBrowser *browser = new WebBrowser(this);
|
WebBrowser *browser = new WebBrowser(this);
|
||||||
browser->setupIcons();
|
browser->setupIcons();
|
||||||
|
|
@ -287,16 +280,12 @@ int TabWidget::addBrowser(bool move_after_current,
|
||||||
|
|
||||||
if (move_after_current) {
|
if (move_after_current) {
|
||||||
// Insert web browser after current tab.
|
// Insert web browser after current tab.
|
||||||
final_index = insertTab(currentIndex() + 1,
|
final_index = insertTab(currentIndex() + 1, browser, qApp->icons()->fromTheme("text-html"),
|
||||||
browser,
|
tr("Web browser"), TabBar::Closable);
|
||||||
qApp->icons()->fromTheme("text-html"),
|
|
||||||
tr("Web browser"),
|
|
||||||
TabBar::Closable);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Add new browser as the last tab.
|
// Add new browser as the last tab.
|
||||||
final_index = addTab(browser,
|
final_index = addTab(browser, qApp->icons()->fromTheme("text-html"),
|
||||||
qApp->icons()->fromTheme("text-html"),
|
|
||||||
//: Web browser default tab title.
|
//: Web browser default tab title.
|
||||||
tr("Web browser"),
|
tr("Web browser"),
|
||||||
TabBar::Closable);
|
TabBar::Closable);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "miscellaneous/iconfactory.h"
|
#include "miscellaneous/iconfactory.h"
|
||||||
#include "network-web/webpage.h"
|
#include "network-web/webpage.h"
|
||||||
#include "network-web/webfactory.h"
|
#include "network-web/webfactory.h"
|
||||||
|
#include "gui/messagebox.h"
|
||||||
|
|
||||||
#include <QStyleOptionFrameV3>
|
#include <QStyleOptionFrameV3>
|
||||||
#include <QAction>
|
#include <QAction>
|
||||||
|
|
@ -33,6 +34,7 @@
|
||||||
#include <QContextMenuEvent>
|
#include <QContextMenuEvent>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
#include <QClipboard>
|
#include <QClipboard>
|
||||||
|
#include <QFileDialog>
|
||||||
|
|
||||||
#if QT_VERSION >= 0x050000
|
#if QT_VERSION >= 0x050000
|
||||||
#include <QtPrintSupport/QPrintPreviewDialog>
|
#include <QtPrintSupport/QPrintPreviewDialog>
|
||||||
|
|
@ -76,10 +78,41 @@ void WebView::openImageInNewTab() {
|
||||||
emit linkMiddleClicked(m_contextImageUrl);
|
emit linkMiddleClicked(m_contextImageUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void WebView::saveCurrentPageToFile() {
|
||||||
|
QString filter_html = tr("HTML web pages (*.html)");
|
||||||
|
|
||||||
|
QString filter;
|
||||||
|
QString selected_filter;
|
||||||
|
|
||||||
|
// Add more filters here.
|
||||||
|
filter += filter_html;
|
||||||
|
|
||||||
|
QString selected_file = QFileDialog::getSaveFileName(this, tr("Select destination file for web page"),
|
||||||
|
qApp->homeFolderPath(), filter, &selected_filter);
|
||||||
|
|
||||||
|
if (!selected_file.isEmpty()) {
|
||||||
|
QFile selected_file_handle(selected_file);
|
||||||
|
|
||||||
|
if (selected_file_handle.open(QIODevice::WriteOnly | QIODevice::Unbuffered)) {
|
||||||
|
QString html_text = page()->mainFrame()->toHtml();
|
||||||
|
QTextStream str(&selected_file_handle);
|
||||||
|
|
||||||
|
str.setCodec("UTF-16");
|
||||||
|
str << html_text;
|
||||||
|
selected_file_handle.close();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
MessageBox::show(this, QMessageBox::Critical, tr("Cannot save web page"),
|
||||||
|
tr("Web page cannot be saved because destination file is not writtable."));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void WebView::createConnections() {
|
void WebView::createConnections() {
|
||||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
|
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
|
||||||
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupContextMenu(QPoint)));
|
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupContextMenu(QPoint)));
|
||||||
|
|
||||||
|
connect(m_actionSavePageAs, SIGNAL(triggered()), this, SLOT(saveCurrentPageToFile()));
|
||||||
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(printCurrentPage()));
|
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(printCurrentPage()));
|
||||||
connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
|
connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
|
||||||
connect(m_actionOpenImageNewTab, SIGNAL(triggered()), this, SLOT(openImageInNewTab()));
|
connect(m_actionOpenImageNewTab, SIGNAL(triggered()), this, SLOT(openImageInNewTab()));
|
||||||
|
|
@ -133,6 +166,8 @@ void WebView::initializeActions() {
|
||||||
m_actionCopyImage->setText(tr("Copy image"));
|
m_actionCopyImage->setText(tr("Copy image"));
|
||||||
m_actionCopyImage->setToolTip(tr("Copy image to clipboard."));
|
m_actionCopyImage->setToolTip(tr("Copy image to clipboard."));
|
||||||
|
|
||||||
|
m_actionSavePageAs = new QAction(qApp->icons()->fromTheme("document-export"), tr("Save page as..."), this);
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040800
|
#if QT_VERSION >= 0x040800
|
||||||
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
|
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
|
||||||
m_actionCopyImageUrl->setParent(this);
|
m_actionCopyImageUrl->setParent(this);
|
||||||
|
|
@ -197,6 +232,7 @@ void WebView::popupContextMenu(const QPoint &pos) {
|
||||||
}
|
}
|
||||||
|
|
||||||
context_menu.addAction(m_actionCopySelectedItem);
|
context_menu.addAction(m_actionCopySelectedItem);
|
||||||
|
context_menu.addAction(m_actionSavePageAs);
|
||||||
|
|
||||||
QUrl hit_url = hit_result.linkUrl();
|
QUrl hit_url = hit_result.linkUrl();
|
||||||
QUrl hit_image_url = hit_result.imageUrl();
|
QUrl hit_image_url = hit_result.imageUrl();
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,7 @@ class WebView : public QWebView {
|
||||||
void openLinkInNewTab();
|
void openLinkInNewTab();
|
||||||
void openLinkExternally();
|
void openLinkExternally();
|
||||||
void openImageInNewTab();
|
void openImageInNewTab();
|
||||||
|
void saveCurrentPageToFile();
|
||||||
|
|
||||||
// Provides custom context menu.
|
// Provides custom context menu.
|
||||||
void popupContextMenu(const QPoint &pos);
|
void popupContextMenu(const QPoint &pos);
|
||||||
|
|
@ -95,6 +96,7 @@ class WebView : public QWebView {
|
||||||
QAction *m_actionCopySelectedItem;
|
QAction *m_actionCopySelectedItem;
|
||||||
QAction *m_actionCopyLink;
|
QAction *m_actionCopyLink;
|
||||||
QAction *m_actionCopyImage;
|
QAction *m_actionCopyImage;
|
||||||
|
QAction *m_actionSavePageAs;
|
||||||
|
|
||||||
#if QT_VERSION >= 0x040800
|
#if QT_VERSION >= 0x040800
|
||||||
QAction *m_actionCopyImageUrl;
|
QAction *m_actionCopyImageUrl;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue