mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Preferences: Add tooltips to buddy labels as well. Fixes #7873 (No tooltip for some format conversion fields)
This commit is contained in:
parent
4a8551962f
commit
0e70bb8b59
@ -10,7 +10,7 @@ import textwrap
|
||||
from functools import partial
|
||||
|
||||
from PyQt4.Qt import QWidget, QSpinBox, QDoubleSpinBox, QLineEdit, QTextEdit, \
|
||||
QCheckBox, QComboBox, Qt, QIcon, pyqtSignal
|
||||
QCheckBox, QComboBox, Qt, QIcon, pyqtSignal, QLabel
|
||||
|
||||
from calibre.customize.conversion import OptionRecommendation
|
||||
from calibre.ebooks.conversion.config import load_defaults, \
|
||||
@ -81,6 +81,21 @@ class Widget(QWidget):
|
||||
self.apply_recommendations(defaults)
|
||||
self.setup_help(get_help)
|
||||
|
||||
def process_child(child):
|
||||
for g in child.children():
|
||||
if isinstance(g, QLabel):
|
||||
buddy = g.buddy()
|
||||
if buddy is not None and hasattr(buddy, '_help'):
|
||||
g._help = buddy._help
|
||||
htext = unicode(buddy.toolTip()).strip()
|
||||
g.setToolTip(htext)
|
||||
g.setWhatsThis(htext)
|
||||
g.__class__.enterEvent = lambda obj, event: self.set_help(getattr(obj, '_help', obj.toolTip()))
|
||||
else:
|
||||
process_child(g)
|
||||
process_child(self)
|
||||
|
||||
|
||||
def restore_defaults(self, get_option):
|
||||
defaults = GuiRecommendations()
|
||||
defaults.merge_recommendations(get_option, OptionRecommendation.LOW,
|
||||
|
@ -251,10 +251,28 @@ class Preferences(QMainWindow):
|
||||
self.close()
|
||||
self.run_wizard_requested.emit()
|
||||
|
||||
def set_tooltips_for_labels(self):
|
||||
|
||||
def process_child(child):
|
||||
for g in child.children():
|
||||
if isinstance(g, QLabel):
|
||||
buddy = g.buddy()
|
||||
if buddy is not None and hasattr(buddy, 'toolTip'):
|
||||
htext = unicode(buddy.toolTip()).strip()
|
||||
etext = unicode(g.toolTip()).strip()
|
||||
if htext and not etext:
|
||||
g.setToolTip(htext)
|
||||
g.setWhatsThis(htext)
|
||||
else:
|
||||
process_child(g)
|
||||
|
||||
process_child(self.showing_widget)
|
||||
|
||||
def show_plugin(self, plugin):
|
||||
self.showing_widget = plugin.create_widget(self.scroll_area)
|
||||
self.showing_widget.genesis(self.gui)
|
||||
self.showing_widget.initialize()
|
||||
self.set_tooltips_for_labels()
|
||||
self.scroll_area.setWidget(self.showing_widget)
|
||||
self.stack.setCurrentIndex(1)
|
||||
self.showing_widget.show()
|
||||
|
Loading…
x
Reference in New Issue
Block a user