Printing now works on Windows, fixed sorting bug in feed list.

This commit is contained in:
Martin Rotter 2014-11-17 17:18:02 +01:00
parent dea0a1a274
commit a8681c040c
8 changed files with 45 additions and 3 deletions

View File

@ -244,7 +244,7 @@ endif(${USE_QT_5})
# Setup librar ies.
if(${USE_QT_5})
find_package(Qt5 REQUIRED Sql WebKit WebKitWidgets Widgets Xml XmlPatterns Network LinguistTools)
find_package(Qt5 REQUIRED Sql WebKit WebKitWidgets Widgets Xml XmlPatterns Network LinguistTools PrintSupport)
else(${USE_QT_5})
set(QT_MIN_VERSION ${MINIMUM_QT_VERSION})
find_package(Qt4 REQUIRED QtCore QtGui QtSql QtNetwork QtWebkit QtXml QtXmlPatterns)
@ -616,6 +616,7 @@ if(${USE_QT_5})
Xml
WebKit
WebKitWidgets
PrintSupport
)
# Setup compilation for Qt 4.
else(${USE_QT_5})

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

View File

@ -1,5 +1,5 @@
<body>
<center><h2>2.0.5</h2></center>
<center><h2>2.1.0</h2></center>
Fixed:
<ul>
@ -8,6 +8,7 @@ Fixed:
Added:
<ul>
<li>Embedded web browser supports printing of its contents, feature is accessible via web browser context menu.</li>
<li>Embedded web browser now displays navigation toolbar even in message preview mode/newspaper mode when user loads external links.</li>
</ul>

View File

@ -61,6 +61,7 @@
#define MIN_CATEGORY_NAME_LENGTH 3
#define INTERNAL_URL_NEWSPAPER "@APP_LOW_NAME@:newspaper"
#define INTERNAL_URL_EMPTY "@APP_LOW_NAME@:empty"
#define INTERNAL_URL_BLANK "about:blank"
#define DEFAULT_AUTO_UPDATE_INTERVAL 15
#define AUTO_UPDATE_INTERVAL 60000
#define STARTUP_UPDATE_DELAY 1500

View File

@ -75,6 +75,12 @@ void FeedsView::quit() {
}
}
void FeedsView::setSortingEnabled(bool enable) {
disconnect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
QTreeView::setSortingEnabled(enable);
connect(header(), SIGNAL(sortIndicatorChanged(int,Qt::SortOrder)), this, SLOT(saveSortState(int,Qt::SortOrder)));
}
void FeedsView::updateAutoUpdateStatus() {
// Restore global intervals.
// NOTE: Specific per-feed interval are left intact.

View File

@ -50,6 +50,8 @@ class FeedsView : public QTreeView {
// Does necessary job before quitting this component.
void quit();
void setSortingEnabled(bool enable);
// Resets global auto-update intervals according to settings
// and starts/stop the timer as needed.
void updateAutoUpdateStatus();

View File

@ -34,6 +34,12 @@
#include <QDateTime>
#include <QClipboard>
#if QT_VERSION >= 0x050000
#include <QtPrintSupport/QPrintPreviewDialog>
#else
#include <QPrintPreviewDialog>
#endif
WebView::WebView(QWidget *parent)
: QWebView(parent), m_page(new WebPage(this)) {
@ -74,12 +80,14 @@ void WebView::createConnections() {
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(onLoadFinished(bool)));
connect(this, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(popupContextMenu(QPoint)));
connect(m_actionPrint, SIGNAL(triggered()), this, SLOT(printCurrentPage()));
connect(m_actionOpenLinkNewTab, SIGNAL(triggered()), this, SLOT(openLinkInNewTab()));
connect(m_actionOpenImageNewTab, SIGNAL(triggered()), this, SLOT(openImageInNewTab()));
connect(m_actionOpenLinkExternally, SIGNAL(triggered()), this, SLOT(openLinkExternally()));
}
void WebView::setupIcons() {
m_actionPrint->setIcon(qApp->icons()->fromTheme("print-web-page"));
m_actionReload->setIcon(qApp->icons()->fromTheme("go-refresh"));
m_actionCopySelectedItem->setIcon(qApp->icons()->fromTheme("edit-copy"));
m_actionCopyLink->setIcon(qApp->icons()->fromTheme("edit-copy"));
@ -102,6 +110,9 @@ void WebView::initializeActions() {
m_actionReload->setText(tr("Reload web page"));
m_actionReload->setToolTip(tr("Reload current web page."));
m_actionPrint = new QAction(tr("Print"), this);
m_actionPrint->setToolTip(tr("Print current web page."));
m_actionCopySelectedItem = pageAction(QWebPage::Copy);
m_actionCopySelectedItem->setParent(this);
m_actionCopySelectedItem->setText(tr("Copy selection"));
@ -174,7 +185,17 @@ void WebView::popupContextMenu(const QPoint &pos) {
link_submenu.setIcon(qApp->icons()->fromTheme("text-html"));
// Assemble the menu from actions.
context_menu.addAction(m_actionReload);
QString current_url = url().toString();
if (!current_url.isEmpty() && current_url != INTERNAL_URL_EMPTY && current_url != INTERNAL_URL_BLANK) {
context_menu.addAction(m_actionPrint);
if (current_url != INTERNAL_URL_NEWSPAPER) {
context_menu.addAction(m_actionReload);
}
}
context_menu.addAction(m_actionCopySelectedItem);
QUrl hit_url = hit_result.linkUrl();
@ -209,6 +230,12 @@ void WebView::popupContextMenu(const QPoint &pos) {
context_menu.exec(mapToGlobal(pos));
}
void WebView::printCurrentPage() {
QPointer<QPrintPreviewDialog> print_preview = new QPrintPreviewDialog(this);
connect(print_preview.data(), SIGNAL(paintRequested(QPrinter*)), this, SLOT(print(QPrinter*)));
print_preview.data()->exec();
}
void WebView::mousePressEvent(QMouseEvent *event) {
if (event->button() & Qt::LeftButton && event->modifiers() & Qt::ControlModifier) {
QWebHitTestResult hit_result = page()->mainFrame()->hitTestContent(event->pos());
@ -239,6 +266,7 @@ void WebView::mousePressEvent(QMouseEvent *event) {
void WebView::mouseReleaseEvent(QMouseEvent *event) {
if (event->button() & Qt::MiddleButton) {
bool are_gestures_enabled = qApp->settings()->value(GROUP(Browser), SETTING(Browser::GesturesEnabled)).toBool();
if (are_gestures_enabled) {
QPoint release_point = event->pos();
int left_move = m_gestureOrigin.x() - release_point.x();

View File

@ -68,6 +68,8 @@ class WebView : public QWebView {
// Provides custom context menu.
void popupContextMenu(const QPoint &pos);
void printCurrentPage();
protected:
// Initializes all actions.
void initializeActions();
@ -89,6 +91,7 @@ class WebView : public QWebView {
WebPage *m_page;
QAction *m_actionReload;
QAction *m_actionPrint;
QAction *m_actionCopySelectedItem;
QAction *m_actionCopyLink;
QAction *m_actionCopyImage;