From c1ca708a876f1ccc7a095435273995bcc88f39da Mon Sep 17 00:00:00 2001 From: Karol Kosek Date: Fri, 8 Jan 2021 17:27:02 +0100 Subject: BrowserTab: show "Copy to clipboard" action only on selection --- src/browsertab.cpp | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) (limited to 'src/browsertab.cpp') diff --git a/src/browsertab.cpp b/src/browsertab.cpp index e870fe0..cc89155 100644 --- a/src/browsertab.cpp +++ b/src/browsertab.cpp @@ -1552,20 +1552,18 @@ void BrowserTab::on_text_browser_customContextMenuRequested(const QPoint pos) menu.addSeparator(); + if (ui->text_browser->textCursor().hasSelection()) { + menu.addAction("Copy to clipboard", [this]() { + this->ui->text_browser->copy(); + }, QKeySequence("Ctrl+C")); + } + connect(menu.addAction("Select all"), &QAction::triggered, [this]() { this->ui->text_browser->selectAll(); }); menu.addSeparator(); - QAction * copy = menu.addAction("Copy to clipboard"); - 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]() { -- cgit v1.2.3