diff --git a/src/calibre/gui2/tweak_book/diff/main.py b/src/calibre/gui2/tweak_book/diff/main.py index 647711fcf6..2ef6dbe909 100644 --- a/src/calibre/gui2/tweak_book/diff/main.py +++ b/src/calibre/gui2/tweak_book/diff/main.py @@ -11,7 +11,7 @@ from functools import partial from PyQt4.Qt import ( QGridLayout, QToolButton, QIcon, QRadioButton, QMenu, QApplication, Qt, QSize, QWidget, QLabel, QStackedLayout, QPainter, QRect, QVBoxLayout, - QCursor, QEventLoop) + QCursor, QEventLoop, QKeySequence) from calibre.gui2 import info_dialog from calibre.gui2.progress_indicator import ProgressIndicator @@ -244,6 +244,10 @@ class Diff(Dialog): return # The enter key is used by the search box, so prevent it closing the dialog if ev.key() == Qt.Key_Slash: return self.search.setFocus(Qt.OtherFocusReason) + if ev.matches(QKeySequence.Copy): + text = self.view.view.left.selected_text + self.view.view.right.selected_text + if text: + QApplication.clipboard().setText(text) return Dialog.keyPressEvent(self, ev) if __name__ == '__main__': diff --git a/src/calibre/gui2/tweak_book/diff/view.py b/src/calibre/gui2/tweak_book/diff/view.py index 703ece9881..8e8a78e8de 100644 --- a/src/calibre/gui2/tweak_book/diff/view.py +++ b/src/calibre/gui2/tweak_book/diff/view.py @@ -20,7 +20,7 @@ from PyQt4.Qt import ( QTextCursor, QTextCharFormat, Qt, QRect, QPainter, QPalette, QPen, QBrush, QColor, QTextLayout, QCursor, QFont, QSplitterHandle, QPainterPath, QHBoxLayout, QWidget, QScrollBar, QEventLoop, pyqtSignal, QImage, QPixmap, - QMenu, QIcon) + QMenu, QIcon, QKeySequence) from calibre import human_readable, fit_image from calibre.gui2 import info_dialog @@ -119,7 +119,7 @@ class TextBrowser(PlainTextEdit): # {{{ a = m.addAction i = unicode(self.textCursor().selectedText()) if i: - a(QIcon(I('edit-copy.png')), _('Copy to clipboard'), self.copy) + a(QIcon(I('edit-copy.png')), _('Copy to clipboard'), self.copy).setShortcut(QKeySequence.Copy) if len(self.changes) > 0: try: @@ -148,6 +148,8 @@ class TextBrowser(PlainTextEdit): # {{{ m.exec_(self.mapToGlobal(pos)) def search(self, query, reverse=False): + ''' Search for query, also searching the headers. Matches in headers + are not highlighted as managing the highlight is too much of a pain.''' if not query.strip(): return c = self.textCursor()