diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-03 18:38:02 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-05-03 18:38:02 +0200 |
commit | fe3785a986bea374b6ee52aa92d5774860fd282b (patch) | |
tree | eb0d9db3e9964940c2b276de47f840c73425ce9a /src | |
parent | QTBUG-65223 workaround (diff) | |
download | smolbote-fe3785a986bea374b6ee52aa92d5774860fd282b.tar.xz |
Merge address bar menus
Diffstat (limited to 'src')
-rw-r--r-- | src/webengine/widgets/pagemenu.cpp | 69 | ||||
-rw-r--r-- | src/webengine/widgets/pagetoolsmenu.cpp | 2 |
2 files changed, 23 insertions, 48 deletions
diff --git a/src/webengine/widgets/pagemenu.cpp b/src/webengine/widgets/pagemenu.cpp index b66c787..dc104e6 100644 --- a/src/webengine/widgets/pagemenu.cpp +++ b/src/webengine/widgets/pagemenu.cpp @@ -9,8 +9,6 @@ #include "pagemenu.h" #include "../webview.h" #include "webengine/webprofile.h" -#include <QApplication> -#include <QClipboard> #include <QFileDialog> #include <QLabel> #include <QPrintDialog> @@ -22,35 +20,37 @@ #include <QWidgetAction> PageMenu::PageMenu(WebView *parent) - : QMenu(parent) + : QMenu(tr("Page"), parent) { setMinimumWidth(240); - auto *copyUrlAction = addAction(tr("Copy page URL")); - connect(copyUrlAction, &QAction::triggered, parent, [parent]() { - qApp->clipboard()->setText(parent->url().toString()); - parent->setFocus(); - }); - - auto *loadUrlAction = addAction(tr("Load URL")); - connect(loadUrlAction, &QAction::triggered, parent, [=]() { - parent->load(QUrl::fromUserInput(qApp->clipboard()->text())); - parent->setFocus(); + auto *bookmarkAction = addAction(tr("Bookmark page")); + connect(bookmarkAction, &QAction::triggered, parent, [parent]() { + parent->profile()->addBookmark(parent->title(), parent->url().toString()); }); - auto *searchAction = addAction(tr("Search")); - connect(searchAction, &QAction::triggered, parent, [=]() { - parent->search(qApp->clipboard()->text()); + auto *savePageAction = addAction(tr("Save Page")); + connect(savePageAction, &QAction::triggered, parent, [parent]() { + parent->triggerPageAction(QWebEnginePage::SavePage); }); - connect(this, &PageMenu::aboutToShow, this, [=]() { - loadUrlAction->setText(tr("Load URL: '%1'").arg(qApp->clipboard()->text())); - searchAction->setText(tr("Search: '%1'").arg(qApp->clipboard()->text())); + auto *printAction = addAction(tr("Print Page")); + connect(printAction, &QAction::triggered, parent, [parent]() { + auto *printer = new QPrinter(QPrinterInfo::defaultPrinter()); + auto *dlg = new QPrintDialog(printer, nullptr); + if(dlg->exec() == QDialog::Accepted) { + parent->page()->print(printer, [printer](bool success) { + qDebug("print %s", success ? "ok" : "failed"); + delete printer; + }); + } + delete dlg; }); - auto *bookmarkAction = addAction(tr("Bookmark page")); - connect(bookmarkAction, &QAction::triggered, parent, [parent]() { - parent->profile()->addBookmark(parent->title(), parent->url().toString()); + auto *printPdfAction = addAction(tr("Print to PDF")); + connect(printPdfAction, &QAction::triggered, parent, [parent]() { + const QString path = QFileDialog::getSaveFileName(parent, tr("Print to PDF"), QDir::homePath(), tr("PDF files (*.pdf)")); + parent->page()->printToPdf(path); }); addSeparator(); @@ -89,29 +89,4 @@ PageMenu::PageMenu(WebView *parent) } addAction(zoomWidgetAction); - addSeparator(); - - auto *savePageAction = addAction(tr("Save Page")); - connect(savePageAction, &QAction::triggered, parent, [parent]() { - parent->triggerPageAction(QWebEnginePage::SavePage); - }); - - auto *printAction = addAction(tr("Print Page")); - connect(printAction, &QAction::triggered, parent, [parent]() { - auto *printer = new QPrinter(QPrinterInfo::defaultPrinter()); - auto *dlg = new QPrintDialog(printer, nullptr); - if(dlg->exec() == QDialog::Accepted) { - parent->page()->print(printer, [printer](bool success) { - qDebug("print %s", success ? "ok" : "failed"); - delete printer; - }); - } - delete dlg; - }); - - auto *printPdfAction = addAction(tr("Print to PDF")); - connect(printPdfAction, &QAction::triggered, parent, [parent]() { - const QString path = QFileDialog::getSaveFileName(parent, tr("Print to PDF"), QDir::homePath(), tr("PDF files (*.pdf)")); - parent->page()->printToPdf(path); - }); } diff --git a/src/webengine/widgets/pagetoolsmenu.cpp b/src/webengine/widgets/pagetoolsmenu.cpp index 2a227ea..6e48798 100644 --- a/src/webengine/widgets/pagetoolsmenu.cpp +++ b/src/webengine/widgets/pagetoolsmenu.cpp @@ -16,7 +16,7 @@ #include <QWebEngineView> PageToolsMenu::PageToolsMenu(WebView *parent) - : QMenu(parent) + : QMenu(tr("Tools"), parent) { Q_CHECK_PTR(parent); parentView = parent; |