mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Keyboard shortcut for copy in diff view
This commit is contained in:
parent
66e4fc9ae1
commit
cb63a16439
@ -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__':
|
||||
|
@ -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()
|
||||
|
Loading…
x
Reference in New Issue
Block a user