aboutsummaryrefslogtreecommitdiff
path: root/src/mainwindow.cpp
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2017-08-24 20:13:27 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2017-08-24 20:13:27 +0200
commit1fcbe65981295f11d8a09b61a09736ba2a1b44b7 (patch)
treee441005f59280464331b6e24b1eb95d9eaca7c33 /src/mainwindow.cpp
parentAStyle pass (diff)
downloadsmolbote-1fcbe65981295f11d8a09b61a09736ba2a1b44b7.tar.xz
Implemented Print to PDF action
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r--src/mainwindow.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp
index bce1716..dd16172 100644
--- a/src/mainwindow.cpp
+++ b/src/mainwindow.cpp
@@ -30,6 +30,8 @@
#include <QToolButton>
#include <QStyle>
+#include <QFileDialog>
+
MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow),
@@ -55,6 +57,11 @@ MainWindow::MainWindow(QUrl defaultUrl, QWidget *parent) :
MainWindowMenuBar *menuBar = new MainWindowMenuBar(this);
menuBar->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+ connect(menuBar->printAction(), &QAction::triggered, [this]() {
+ QString path = QFileDialog::getSaveFileName(this, tr("Print to PDF"), QDir::homePath(), tr("PDF files (*.pdf)"));
+ m_currentView->page()->printToPdf(path);
+ });
+
// Add the toolbars
// tabToolBar: main menu and tab list
tabToolBar->setMovable(sSettings->value("window.ui.tabtoolbarMovable").toBool());
@@ -213,6 +220,8 @@ void MainWindow::handleTabChanged(WebView *view)
{
Q_ASSERT(view != nullptr);
+ m_currentView = view;
+
// centralWidget can be a nullptr
if(centralWidget()) {
// clear the parent of the central widget so it doesn't get deleted