diff options
author | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-04-18 21:37:52 +0200 |
---|---|---|
committer | Aqua-sama <aqua@iserlohn-fortress.net> | 2018-04-18 21:37:52 +0200 |
commit | 0b70b2802e355a44e6ccbbfcabd03c0992f812e0 (patch) | |
tree | 26491a414e5711574aa3a925662b6ca78d59704f /src/webengine | |
parent | Style pass (diff) | |
download | smolbote-0b70b2802e355a44e6ccbbfcabd03c0992f812e0.tar.xz |
Load URL/Search page menu actions
Diffstat (limited to 'src/webengine')
-rw-r--r-- | src/webengine/webprofile.h | 10 | ||||
-rw-r--r-- | src/webengine/webview.h | 3 | ||||
-rw-r--r-- | src/webengine/widgets/pagemenu.cpp | 20 |
3 files changed, 32 insertions, 1 deletions
diff --git a/src/webengine/webprofile.h b/src/webengine/webprofile.h index 0b3ce7f..ddb642c 100644 --- a/src/webengine/webprofile.h +++ b/src/webengine/webprofile.h @@ -11,6 +11,7 @@ #include <QHash> #include <QUrl> +#include <QString> #include <QWebEngineProfile> class WebProfile : public QWebEngineProfile @@ -41,6 +42,15 @@ public: QUrl homepage() const; QUrl newtab() const; + void addBookmark(const QString &title, const QString &url) + { + if(!title.isEmpty() && !url.isEmpty()) + emit addBookmarkRequested(title, url); + } + +signals: + void addBookmarkRequested(const QString &title, const QString &url); + public slots: void loadProfile(QHash<QString, QString> conf); void saveProfile(const QString &path = QString()); diff --git a/src/webengine/webview.h b/src/webengine/webview.h index d59847b..5ab04cd 100644 --- a/src/webengine/webview.h +++ b/src/webengine/webview.h @@ -34,6 +34,9 @@ public: return m_toolsMenu; } + WebProfile *profile() { + return m_profile; + } void setPage(QWebEnginePage *page); bool isLoaded() const; int loadProgress() const; diff --git a/src/webengine/widgets/pagemenu.cpp b/src/webengine/widgets/pagemenu.cpp index a90d223..b66c787 100644 --- a/src/webengine/widgets/pagemenu.cpp +++ b/src/webengine/widgets/pagemenu.cpp @@ -8,6 +8,7 @@ #include "pagemenu.h" #include "../webview.h" +#include "webengine/webprofile.h" #include <QApplication> #include <QClipboard> #include <QFileDialog> @@ -28,11 +29,28 @@ PageMenu::PageMenu(WebView *parent) 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 *searchAction = addAction(tr("Search")); + connect(searchAction, &QAction::triggered, parent, [=]() { + parent->search(qApp->clipboard()->text()); + }); + + 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 *bookmarkAction = addAction(tr("Bookmark page")); connect(bookmarkAction, &QAction::triggered, parent, [parent]() { - parent->triggerViewAction(WebView::BookmarkPage); + parent->profile()->addBookmark(parent->title(), parent->url().toString()); }); addSeparator(); |