diff options
| author | Felix (xq) Queißner <git@mq32.de> | 2020-06-10 00:31:56 +0200 |
|---|---|---|
| committer | Felix (xq) Queißner <git@mq32.de> | 2020-06-10 00:31:56 +0200 |
| commit | 656391ecc0555b3462266b886434ae0f120a401c (patch) | |
| tree | bb87b6889c2dae9a5c65c6b9bcb783139bebdf3c /src/browsertab.cpp | |
| parent | 0739bce0be84e8ccebdc632726efd0fd6f612789 (diff) | |
| download | kristall-656391ecc0555b3462266b886434ae0f120a401c.tar.gz | |
Adds some right click menus, fixes bug in gopher.
Diffstat (limited to 'src/browsertab.cpp')
| -rw-r--r-- | src/browsertab.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/browsertab.cpp b/src/browsertab.cpp index cde8fc7..2cd4fff 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -64,6 +64,8 @@ BrowserTab::BrowserTab(MainWindow * mainWindow) : this->ui->graphics_browser->setVisible(false); this->ui->text_browser->setVisible(true); + this->ui->text_browser->setContextMenuPolicy(Qt::CustomContextMenu); + this->ui->graphics_browser->setScene(&graphics_scene); } @@ -591,3 +593,37 @@ void BrowserTab::updateUI() this->ui->fav_button->setEnabled(this->successfully_loaded); this->ui->fav_button->setChecked(this->mainWindow->favourites.contains(this->current_location)); } + +#include <QClipboard> + +void BrowserTab::on_text_browser_customContextMenuRequested(const QPoint &pos) +{ + QMenu menu; + + QString anchor = ui->text_browser->anchorAt(pos); + if(not anchor.isEmpty()) { + QUrl real_url { anchor }; + if(real_url.isRelative()) + real_url = this->current_location.resolved(real_url); + + connect(menu.addAction("Follow link…"), &QAction::triggered, [this,real_url]() { + this->navigateTo(real_url, PushImmediate); + }); + + connect(menu.addAction("Open in new tab…"), &QAction::triggered, [this,real_url]() { + mainWindow->addNewTab(false, real_url); + }); + + connect(menu.addAction("Copy link"), &QAction::triggered, [this,real_url]() { + global_clipboard->setText(real_url.toString(QUrl::FullyEncoded)); + }); + + menu.addSeparator(); + } + + connect(menu.addAction("Select all"), &QAction::triggered, [this]() { + this->ui->text_browser->selectAll(); + }); + + menu.exec(ui->text_browser->mapToGlobal(pos)); +} |
