diff options
| author | Mike Skec <skec@protonmail.ch> | 2020-12-24 16:32:14 +1100 |
|---|---|---|
| committer | Felix Queißner <felix@ib-queissner.de> | 2020-12-24 09:21:59 +0100 |
| commit | 237d3a8bc9ed6be7196115e0c7b640ca59349b1d (patch) | |
| tree | b038f16f524b409f42a4e4d815b36c5a5630265d /src | |
| parent | eb4b49245ece1bf1e3d04fcd25e6968b482ff285 (diff) | |
| download | kristall-237d3a8bc9ed6be7196115e0c7b640ca59349b1d.tar.gz | |
Add 'view source' to right-click context menu
Diffstat (limited to 'src')
| -rw-r--r-- | src/browsertab.cpp | 10 | ||||
| -rw-r--r-- | src/mainwindow.cpp | 13 | ||||
| -rw-r--r-- | src/mainwindow.hpp | 2 | ||||
| -rw-r--r-- | src/mainwindow.ui | 2 |
4 files changed, 21 insertions, 6 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index 1c9bcd6..e88225b 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -1192,11 +1192,19 @@ void BrowserTab::on_text_browser_customContextMenuRequested(const QPoint &pos) menu.addSeparator(); QAction * copy = menu.addAction("Copy to clipboard"); - copy->setShortcut(QKeySequence("Ctrl-C")); + copy->setShortcut(QKeySequence("Ctrl+C")); connect(copy, &QAction::triggered, [this]() { this->ui->text_browser->copy(); }); + menu.addSeparator(); + + QAction * viewsrc = menu.addAction("View document source"); + viewsrc->setShortcut(QKeySequence("Ctrl+U")); + connect(viewsrc, &QAction::triggered, [this]() { + mainWindow->viewPageSource(); + }); + menu.exec(ui->text_browser->mapToGlobal(pos)); } diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 706394e..6d1964a 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -143,6 +143,14 @@ void MainWindow::setUrlPreview(const QUrl &url) } } +void MainWindow::viewPageSource() +{ + BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget()); + if(tab != nullptr) { + tab->openSourceView(); + } +} + void MainWindow::on_browser_tabs_currentChanged(int index) { if(index >= 0) { @@ -477,8 +485,5 @@ void MainWindow::on_actionManage_Certificates_triggered() void MainWindow::on_actionShow_document_source_triggered() { - BrowserTab * tab = qobject_cast<BrowserTab*>(this->ui->browser_tabs->currentWidget()); - if(tab != nullptr) { - tab->openSourceView(); - } + this->viewPageSource(); } diff --git a/src/mainwindow.hpp b/src/mainwindow.hpp index 6cfee9f..75e814b 100644 --- a/src/mainwindow.hpp +++ b/src/mainwindow.hpp @@ -32,6 +32,8 @@ public: void setUrlPreview(QUrl const & url); + void viewPageSource(); + private slots: void on_browser_tabs_currentChanged(int index); diff --git a/src/mainwindow.ui b/src/mainwindow.ui index ea7c7cd..5698074 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -392,7 +392,7 @@ </action> <action name="actionShow_document_source"> <property name="text"> - <string>Show document source</string> + <string>View document source</string> </property> </action> </widget> |
