mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Refactor RightClickButton to make it globally available
This commit is contained in:
parent
e127994456
commit
f90360f4a8
@ -18,7 +18,7 @@ from PyQt5.Qt import (
|
||||
QUndoStack)
|
||||
|
||||
from calibre.gui2.widgets import EnLineEdit, FormatList as _FormatList, ImageView
|
||||
from calibre.gui2.widgets2 import access_key, populate_standard_spinbox_context_menu
|
||||
from calibre.gui2.widgets2 import access_key, populate_standard_spinbox_context_menu, RightClickButton
|
||||
from calibre.utils.icu import sort_key
|
||||
from calibre.utils.config import tweaks, prefs
|
||||
from calibre.ebooks.metadata import (
|
||||
@ -180,15 +180,6 @@ def make_undoable(spinbox):
|
||||
|
||||
return UndoableSpinbox
|
||||
|
||||
class RightClickButton(QToolButton):
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
if ev.button() == Qt.RightButton and self.menu() is not None:
|
||||
self.showMenu()
|
||||
ev.accept()
|
||||
return
|
||||
return QToolButton.mousePressEvent(self, ev)
|
||||
|
||||
# Title {{{
|
||||
class TitleEdit(EnLineEdit, ToMetadataMixin):
|
||||
|
||||
|
@ -6,7 +6,9 @@ from __future__ import (unicode_literals, division, absolute_import,
|
||||
__license__ = 'GPL v3'
|
||||
__copyright__ = '2013, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
|
||||
from PyQt5.Qt import QPushButton, QPixmap, QIcon, QColor, Qt, QColorDialog, pyqtSignal, QKeySequence
|
||||
from PyQt5.Qt import (
|
||||
QPushButton, QPixmap, QIcon, QColor, Qt, QColorDialog, pyqtSignal,
|
||||
QKeySequence, QToolButton)
|
||||
|
||||
from calibre.gui2.complete2 import LineEdit, EditWithComplete
|
||||
from calibre.gui2.widgets import history
|
||||
@ -120,3 +122,12 @@ def populate_standard_spinbox_context_menu(spinbox, menu, add_clear=False):
|
||||
m.addAction(_('Step &down'), spinbox.stepDown)
|
||||
m.setAttribute(Qt.WA_DeleteOnClose)
|
||||
|
||||
class RightClickButton(QToolButton):
|
||||
|
||||
def mousePressEvent(self, ev):
|
||||
if ev.button() == Qt.RightButton and self.menu() is not None:
|
||||
self.showMenu()
|
||||
ev.accept()
|
||||
return
|
||||
return QToolButton.mousePressEvent(self, ev)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user