Skip to content

Commit

Permalink
Merge pull request #3210 from irgolic/helper-pane
Browse files Browse the repository at this point in the history
[ENH] Empty helper pane message
  • Loading branch information
lanzagar authored Sep 12, 2018
2 parents 6d54212 + abb5721 commit 1e5efdd
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
43 changes: 28 additions & 15 deletions Orange/canvas/application/canvasmain.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,12 @@ def touch():
self.dock_help = canvas_tool_dock.help
self.dock_help.setMaximumHeight(150)
self.dock_help.document().setDefaultStyleSheet("h3, a {color: orange;}")
default_help = "Select a widget to show its description." \
"<br><br>" \
"See <a href='orange://examples'>workflow examples</a>, " \
"<a href='orange://tutorials'>YouTube tutorials</a>, " \
"or open the <a href='orange://welcome'>welcome screen</a>."
self.dock_help.setDefaultText(default_help)

self.dock_help_action = canvas_tool_dock.toogleQuickHelpAction()
self.dock_help_action.setText(self.tr("Show Help"))
Expand Down Expand Up @@ -460,15 +466,15 @@ def setup_actions(self):
)

self.tutorials_action = \
QAction(self.tr("Tutorials"), self,
QAction(self.tr("YouTube Tutorials"), self,
objectName="tutorials-action",
toolTip=self.tr("View YouTube tutorials."),
triggered=self.tutorials,
icon=canvas_icons("YouTube.svg")
)

self.examples_action = \
QAction(self.tr("Examples"), self,
QAction(self.tr("Workflow Examples"), self,
objectName="tutorial-action",
toolTip=self.tr("Browse example workflows."),
triggered=self.tutorial_scheme,
Expand Down Expand Up @@ -1531,12 +1537,13 @@ def open_examples():
)

examples_action = \
QAction(self.examples_action.text(), dialog,
icon=self.examples_action.icon(),
toolTip=self.examples_action.toolTip(),
whatsThis=self.examples_action.whatsThis(),
triggered=open_examples,
QAction(self.tr("Examples"), self,
icon=canvas_icons("Examples.svg"),
toolTip=self.tr("Browse example workflows."),
objectName="tutorial-action",
triggered=open_examples
)

tutorials_action = \
QAction(self.tr("Tutorials"), self,
objectName="tutorials-action",
Expand Down Expand Up @@ -1922,16 +1929,22 @@ def event(self, event):
if url.scheme() == "help" and url.authority() == "search":
try:
url = self.help.search(url)
self.show_help(url)
except KeyError:
url = None
log.info("No help topic found for %r", url)

if url:
self.show_help(url)
else:
message_information(
self.tr("There is no documentation for this widget yet."),
parent=self)
message_information(
self.tr("There is no documentation for this widget yet."),
parent=self)
elif url.scheme() == "orange":
target = url.host()
if target == "examples":
self.tutorial_scheme()
elif target == "tutorials":
self.tutorials()
elif target == "welcome":
self.welcome_dialog()
else:
log.error("No target found for %r", url)

return True

Expand Down
16 changes: 15 additions & 1 deletion Orange/canvas/gui/quickhelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def __init__(self, *args, **kwargs):

self.__text = ""
self.__permanentText = ""
self.__defaultText = ""

self.__timer = QTimer(self, timeout=self.__on_timeout,
singleShot=True)
Expand Down Expand Up @@ -57,6 +58,17 @@ def showPermanentHelp(self, text):
self.__update()
self.textChanged.emit()

def setDefaultText(self, text):
"""
Set default help text. The text is overriden by normal and permanent help messages,
but is show again after such messages are cleared.
"""
if self.__defaultText != text:
self.__defaultText = text
self.__update()
self.textChanged.emit()

def currentText(self):
"""
Return the current shown text.
Expand All @@ -66,8 +78,10 @@ def currentText(self):
def __update(self):
if self.__text:
self.setHtml(self.__text)
else:
elif self.__permanentText:
self.setHtml(self.__permanentText)
else:
self.setHtml(self.__defaultText)

def __on_timeout(self):
if self.__text:
Expand Down

0 comments on commit 1e5efdd

Please sign in to comment.