88from AnyQt .QtWidgets import (
99 QWidget , QDialog , QVBoxLayout , QSizePolicy , QApplication , QStyle ,
1010 QShortcut , QSplitter , QSplitterHandle , QPushButton , QStatusBar ,
11- QProgressBar
11+ QProgressBar , QAction
1212)
1313from AnyQt .QtCore import (
1414 Qt , QByteArray , QSettings , QUrl , pyqtSignal as Signal
@@ -170,6 +170,7 @@ class OWWidget(QDialog, OWComponent, Report, ProgressBarMixin,
170170 contextOpened = Signal ()
171171 contextClosed = Signal ()
172172
173+ # pylint: disable=protected-access
173174 def __new__ (cls , * args , captionTitle = None , ** kwargs ):
174175 self = super ().__new__ (cls , None , cls .get_flags ())
175176 QDialog .__init__ (self , None , self .get_flags ())
@@ -208,6 +209,12 @@ def __new__(cls, *args, captionTitle=None, **kwargs):
208209 self .__msgwidget = None
209210 self .__msgchoice = 0
210211
212+ self .__help_action = QAction (
213+ "Help" , self , objectName = "action-help" , toolTip = "Show help" ,
214+ enabled = False , visible = False , shortcut = QKeySequence (Qt .Key_F1 )
215+ )
216+ self .addAction (self .__help_action )
217+
211218 self .left_side = None
212219 self .controlArea = self .mainArea = self .buttonsArea = None
213220 self .splitter = None
@@ -219,6 +226,7 @@ def __new__(cls, *args, captionTitle=None, **kwargs):
219226
220227 sc = QShortcut (QKeySequence .Copy , self )
221228 sc .activated .connect (self .copy_to_clipboard )
229+
222230 if self .controlArea is not None :
223231 # Otherwise, the first control has focus
224232 self .controlArea .setFocus (Qt .ActiveWindowFocusReason )
@@ -347,11 +355,20 @@ def set_basic_layout(self):
347355 sb .setSizeGripEnabled (self .resizing_enabled )
348356 c .layout ().addWidget (sb )
349357
350- b = SimpleButton (
358+ help = self .__help_action
359+ help_button = SimpleButton (
351360 icon = QIcon (gui .resource_filename ("icons/help.svg" )),
352- toolTip = "Show widget help" ,
361+ toolTip = "Show widget help" , visible = help . isVisible (),
353362 )
354- sb .addWidget (b )
363+ @help .changed .connect
364+ def _ ():
365+ help_button .setVisible (help .isVisible ())
366+ help_button .setEnabled (help .isEnabled ())
367+ if not help .icon ().isNull ():
368+ help_button .setIcon (help .icon ())
369+ help_button .clicked .connect (help .trigger )
370+ sb .addWidget (help_button )
371+
355372 if self .graph_name is not None :
356373 b = SimpleButton (
357374 icon = QIcon (gui .resource_filename ("icons/chart.svg" )),
0 commit comments