mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Disable selection of 'first letter' if tag browser not sorted by name.
This commit is contained in:
parent
64d1b9560c
commit
93bed22d15
@ -12,7 +12,7 @@ from functools import partial
|
|||||||
from itertools import izip
|
from itertools import izip
|
||||||
|
|
||||||
from PyQt4.Qt import (QItemDelegate, Qt, QTreeView, pyqtSignal, QSize, QIcon,
|
from PyQt4.Qt import (QItemDelegate, Qt, QTreeView, pyqtSignal, QSize, QIcon,
|
||||||
QApplication, QMenu, QPoint, QModelIndex)
|
QApplication, QMenu, QPoint, QModelIndex, QCursor, QToolTip)
|
||||||
|
|
||||||
from calibre.gui2.tag_browser.model import (TagTreeItem, TAG_SEARCH_STATES,
|
from calibre.gui2.tag_browser.model import (TagTreeItem, TAG_SEARCH_STATES,
|
||||||
TagsModel)
|
TagsModel)
|
||||||
@ -477,6 +477,7 @@ class TagsView(QTreeView): # {{{
|
|||||||
partial(self.context_menu_handler, action='categorization', category='first letter'))
|
partial(self.context_menu_handler, action='categorization', category='first letter'))
|
||||||
pa = m.addAction('Partition',
|
pa = m.addAction('Partition',
|
||||||
partial(self.context_menu_handler, action='categorization', category='partition'))
|
partial(self.context_menu_handler, action='categorization', category='partition'))
|
||||||
|
|
||||||
if self.collapse_model == 'disable':
|
if self.collapse_model == 'disable':
|
||||||
da.setCheckable(True)
|
da.setCheckable(True)
|
||||||
da.setChecked(True)
|
da.setChecked(True)
|
||||||
@ -487,10 +488,25 @@ class TagsView(QTreeView): # {{{
|
|||||||
pa.setCheckable(True)
|
pa.setCheckable(True)
|
||||||
pa.setChecked(True)
|
pa.setChecked(True)
|
||||||
|
|
||||||
|
if config['sort_tags_by'] != "name":
|
||||||
|
fla.setEnabled(False)
|
||||||
|
m.hovered.connect(self.collapse_menu_hovered)
|
||||||
|
fla.setToolTip(_('First letter is usable only when sorting by name'))
|
||||||
|
# Apparently one cannot set a tooltip to empty, so use a star and
|
||||||
|
# deal with it in the hover method
|
||||||
|
da.setToolTip('*')
|
||||||
|
pa.setToolTip('*')
|
||||||
|
|
||||||
if not self.context_menu.isEmpty():
|
if not self.context_menu.isEmpty():
|
||||||
self.context_menu.popup(self.mapToGlobal(point))
|
self.context_menu.popup(self.mapToGlobal(point))
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def collapse_menu_hovered(self, action):
|
||||||
|
tip = action.toolTip()
|
||||||
|
if tip == '*':
|
||||||
|
tip = ''
|
||||||
|
QToolTip.showText(QCursor.pos(), tip)
|
||||||
|
|
||||||
def dragMoveEvent(self, event):
|
def dragMoveEvent(self, event):
|
||||||
QTreeView.dragMoveEvent(self, event)
|
QTreeView.dragMoveEvent(self, event)
|
||||||
self.setDropIndicatorShown(False)
|
self.setDropIndicatorShown(False)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user