diff options
Diffstat (limited to 'src/mainwindow.cpp')
-rw-r--r-- | src/mainwindow.cpp | 9 |
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 |