From c7f2b45cbd38f4fc40bd44fff2af481e39aeef40 Mon Sep 17 00:00:00 2001 From: Florian Bruhin Date: Tue, 24 Jun 2014 12:04:36 +0200 Subject: [PATCH] Always yank to clipboard if primary selection is unavailable --- qutebrowser/browser/commands.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index c9e260978..7784234e1 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -377,16 +377,17 @@ class CommandDispatcher: Args: sel: True to use primary selection, False to use clipboard """ + clipboard = QApplication.clipboard() urlstr = self._current_url().toString(QUrl.FullyEncoded | QUrl.RemovePassword) - if sel: + if sel and clipboard.supportsSelection(): mode = QClipboard.Selection target = "primary selection" else: mode = QClipboard.Clipboard target = "clipboard" log.misc.debug("Yanking to {}: '{}'".format(target, urlstr)) - QApplication.clipboard().setText(urlstr, mode) + clipboard.setText(urlstr, mode) message.info("URL yanked to {}".format(target)) @cmdutils.register(instance='mainwindow.tabs.cmd') @@ -396,16 +397,17 @@ class CommandDispatcher: Args: sel: True to use primary selection, False to use clipboard """ + clipboard = QApplication.clipboard() title = self._tabs.tabText(self._tabs.currentIndex()) mode = QClipboard.Selection if sel else QClipboard.Clipboard - if sel: + if sel and clipboard.supportsSelection(): mode = QClipboard.Selection target = "primary selection" else: mode = QClipboard.Clipboard target = "clipboard" log.misc.debug("Yanking to {}: '{}'".format(target, title)) - QApplication.clipboard().setText(title, mode) + clipboard.setText(title, mode) message.info("Title yanked to {}".format(target)) @cmdutils.register(instance='mainwindow.tabs.cmd')