Fixed #100.
This commit is contained in:
parent
7498565be8
commit
5f5841aeb2
@ -4,6 +4,7 @@
|
||||
Fixed:
|
||||
<ul>
|
||||
<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>
|
||||
|
||||
Added:
|
||||
|
@ -107,8 +107,6 @@ void FormImportExport::selectExportFile() {
|
||||
QString selected_file = QFileDialog::getSaveFileName(this, tr("Select file for feeds export"),
|
||||
qApp->homeFolderPath(), filter, &selected_filter);
|
||||
|
||||
|
||||
|
||||
if (!selected_file.isEmpty()) {
|
||||
if (selected_filter == filter_opml20) {
|
||||
m_conversionType = OPML20;
|
||||
|
@ -376,13 +376,18 @@ void FormMain::loadWebBrowserMenu(int index) {
|
||||
WebBrowser *active_browser = m_ui->m_tabWidget->widget(index)->webBrowser();
|
||||
|
||||
m_ui->m_menuCurrentTab->clear();
|
||||
|
||||
if (active_browser != NULL) {
|
||||
m_ui->m_menuCurrentTab->setEnabled(true);
|
||||
m_ui->m_menuCurrentTab->addActions(active_browser->globalMenu());
|
||||
|
||||
if (m_ui->m_menuCurrentTab->actions().size() == 0) {
|
||||
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);
|
||||
}
|
||||
|
@ -221,8 +221,7 @@ void TabWidget::removeTab(int index) {
|
||||
QTabWidget::removeTab(index);
|
||||
}
|
||||
|
||||
int TabWidget::addTab(TabContent *widget, const QIcon &icon,
|
||||
const QString &label, const TabBar::TabType &type) {
|
||||
int TabWidget::addTab(TabContent *widget, const QIcon &icon, const QString &label, const TabBar::TabType &type) {
|
||||
int index = QTabWidget::addTab(widget, icon, label);
|
||||
tabBar()->setTabType(index, type);
|
||||
|
||||
@ -236,16 +235,14 @@ int TabWidget::addTab(TabContent *widget, const QString &label, const TabBar::Ta
|
||||
return index;
|
||||
}
|
||||
|
||||
int TabWidget::insertTab(int index, QWidget *widget, const QIcon &icon,
|
||||
const QString &label, const TabBar::TabType &type) {
|
||||
int TabWidget::insertTab(int index, QWidget *widget, const QIcon &icon, const QString &label, const TabBar::TabType &type) {
|
||||
int tab_index = QTabWidget::insertTab(index, widget, icon, label);
|
||||
tabBar()->setTabType(tab_index, type);
|
||||
|
||||
return tab_index;
|
||||
}
|
||||
|
||||
int TabWidget::insertTab(int index, QWidget *widget, const QString &label,
|
||||
const TabBar::TabType &type) {
|
||||
int TabWidget::insertTab(int index, QWidget *widget, const QString &label, const TabBar::TabType &type) {
|
||||
int tab_index = QTabWidget::insertTab(index, widget, label);
|
||||
tabBar()->setTabType(tab_index, type);
|
||||
|
||||
@ -271,14 +268,10 @@ int TabWidget::addLinkedBrowser(const QString &initial_url) {
|
||||
}
|
||||
|
||||
int TabWidget::addLinkedBrowser(const QUrl &initial_url) {
|
||||
return addBrowser(qApp->settings()->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool(),
|
||||
false,
|
||||
initial_url);
|
||||
return addBrowser(qApp->settings()->value(GROUP(Browser), SETTING(Browser::QueueTabs)).toBool(), false, initial_url);
|
||||
}
|
||||
|
||||
int TabWidget::addBrowser(bool move_after_current,
|
||||
bool make_active,
|
||||
const 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);
|
||||
browser->setupIcons();
|
||||
@ -287,16 +280,12 @@ int TabWidget::addBrowser(bool move_after_current,
|
||||
|
||||
if (move_after_current) {
|
||||
// Insert web browser after current tab.
|
||||
final_index = insertTab(currentIndex() + 1,
|
||||
browser,
|
||||
qApp->icons()->fromTheme("text-html"),
|
||||
tr("Web browser"),
|
||||
TabBar::Closable);
|
||||
final_index = insertTab(currentIndex() + 1, browser, qApp->icons()->fromTheme("text-html"),
|
||||
tr("Web browser"), TabBar::Closable);
|
||||
}
|
||||
else {
|
||||
// Add new browser as the last tab.
|
||||
final_index = addTab(browser,
|
||||
qApp->icons()->fromTheme("text-html"),
|
||||
final_index = addTab(browser, qApp->icons()->fromTheme("text-html"),
|
||||
//: Web browser default tab title.
|
||||
tr("Web browser"),
|
||||
TabBar::Closable);
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "miscellaneous/iconfactory.h"
|
||||
#include "network-web/webpage.h"
|
||||
#include "network-web/webfactory.h"
|
||||
#include "gui/messagebox.h"
|
||||
|
||||
#include <QStyleOptionFrameV3>
|
||||
#include <QAction>
|
||||
@ -33,6 +34,7 @@
|
||||
#include <QContextMenuEvent>
|
||||
#include <QDateTime>
|
||||
#include <QClipboard>
|
||||
#include <QFileDialog>
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
#include <QtPrintSupport/QPrintPreviewDialog>
|
||||
@ -76,10 +78,41 @@ void WebView::openImageInNewTab() {
|
||||
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() {
|
||||
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
|
||||
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_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
|
||||
connect(m_actionOpenImageNewTab, SIGNAL(triggered()), this, SLOT(openImageInNewTab()));
|
||||
@ -133,6 +166,8 @@ void WebView::initializeActions() {
|
||||
m_actionCopyImage->setText(tr("Copy image"));
|
||||
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
|
||||
m_actionCopyImageUrl = pageAction(QWebPage::CopyImageUrlToClipboard);
|
||||
m_actionCopyImageUrl->setParent(this);
|
||||
@ -197,6 +232,7 @@ void WebView::popupContextMenu(const QPoint &pos) {
|
||||
}
|
||||
|
||||
context_menu.addAction(m_actionCopySelectedItem);
|
||||
context_menu.addAction(m_actionSavePageAs);
|
||||
|
||||
QUrl hit_url = hit_result.linkUrl();
|
||||
QUrl hit_image_url = hit_result.imageUrl();
|
||||
|
@ -64,6 +64,7 @@ class WebView : public QWebView {
|
||||
void openLinkInNewTab();
|
||||
void openLinkExternally();
|
||||
void openImageInNewTab();
|
||||
void saveCurrentPageToFile();
|
||||
|
||||
// Provides custom context menu.
|
||||
void popupContextMenu(const QPoint &pos);
|
||||
@ -95,6 +96,7 @@ class WebView : public QWebView {
|
||||
QAction *m_actionCopySelectedItem;
|
||||
QAction *m_actionCopyLink;
|
||||
QAction *m_actionCopyImage;
|
||||
QAction *m_actionSavePageAs;
|
||||
|
||||
#if QT_VERSION >= 0x040800
|
||||
QAction *m_actionCopyImageUrl;
|
||||
|
Loading…
x
Reference in New Issue
Block a user