aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/widgets/pagemenu.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/widgets/pagemenu.cpp')
-rw-r--r--src/webengine/widgets/pagemenu.cpp122
1 files changed, 0 insertions, 122 deletions
diff --git a/src/webengine/widgets/pagemenu.cpp b/src/webengine/widgets/pagemenu.cpp
deleted file mode 100644
index deff511..0000000
--- a/src/webengine/widgets/pagemenu.cpp
+++ /dev/null
@@ -1,122 +0,0 @@
-/*
- * This file is part of smolbote. It's copyrighted by the contributors recorded
- * in the version control history of the file, available from its original
- * location: https://neueland.iserlohn-fortress.net/smolbote.hg
- *
- * SPDX-License-Identifier: GPL-3.0
- */
-
-#include "pagemenu.h"
-#include "../webview.h"
-#include "browser.h"
-#include <QFileDialog>
-#include <QLabel>
-#include <QPrintDialog>
-#include <QPrinterInfo>
-#include <QSlider>
-#include <QStyle>
-#include <QToolButton>
-#include <QVBoxLayout>
-#include <QWidgetAction>
-#include <bookmarks/bookmarkswidget.h>
-#include <webprofile.h>
-#include "profilemanager.h"
-
-PageMenu::PageMenu(WebView *parent)
- : QMenu(tr("Page"), parent)
-{
- setMinimumWidth(240);
- view = parent;
-
- auto *bookmarkAction = addAction(tr("Bookmark page"));
- connect(bookmarkAction, &QAction::triggered, parent, [parent]() {
- auto *browser = qobject_cast<Browser *>(qApp);
- Q_CHECK_PTR(browser);
- browser->bookmarks()->addBookmark(parent->title(), parent->url().toString());
- });
-
- 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);
- });
-
- addSeparator();
-
- auto *zoomWidgetAction = new QWidgetAction(this);
- {
- auto *widget = new QWidget(this);
- zoomWidgetAction->setDefaultWidget(widget);
-
- auto *layout = new QVBoxLayout(widget);
- widget->setLayout(layout);
-
- QLabel *zoomLabel = new QLabel(tr("Zoom: 1x"));
- layout->addWidget(zoomLabel);
-
- auto *zoomLayout = new QHBoxLayout();
- layout->addLayout(zoomLayout);
-
- auto *zoomSlider = new QSlider(Qt::Horizontal);
- zoomSlider->setMinimum(5);
- zoomSlider->setMaximum(50);
- zoomSlider->setValue(10);
- zoomLayout->addWidget(zoomSlider);
-
- auto *zoomResetButton = new QToolButton(widget);
- zoomResetButton->setIcon(widget->style()->standardIcon(QStyle::SP_BrowserReload));
- zoomLayout->addWidget(zoomResetButton);
-
- connect(zoomResetButton, &QToolButton::clicked, [zoomSlider]() {
- zoomSlider->setValue(10);
- });
- connect(zoomSlider, &QSlider::valueChanged, parent, [parent, zoomLabel](int value) {
- zoomLabel->setText(tr("Zoom: %1x").arg(static_cast<qreal>(value) / 10));
- parent->setZoomFactor(static_cast<qreal>(value) / 10);
- });
- }
- addAction(zoomWidgetAction);
-
- addSeparator();
-
- loadProfile_menu = addMenu(tr("Load Profile"));
- connect(this, &PageMenu::aboutToShow, this, &PageMenu::updateLoadProfileMenu);
-}
-
-void PageMenu::updateLoadProfileMenu()
-{
- Q_CHECK_PTR(loadProfile_menu);
- loadProfile_menu->clear();
-
- auto *browser = qobject_cast<Browser *>(qApp);
- Q_CHECK_PTR(browser);
-
- ProfileIterator it(ProfileManager::profileList());
- while(it.hasNext()) {
- it.next();
- auto *profile =it.value();
- auto *loadAction = loadProfile_menu->addAction(profile->name());
-
- connect(loadAction, &QAction::triggered, this, [=]() {
- view->setProfile(profile);
- });
- }
-}