added confirmation dialog before opening online help

This commit is contained in:
Minnowo 2023-07-24 01:58:07 -04:00
parent 8297911995
commit 1d1fb3c125
No known key found for this signature in database
GPG Key ID: B5E504E1ECA46D32
4 changed files with 40 additions and 38 deletions

View File

@ -5,6 +5,8 @@ from hydrus.core import HydrusConstants as HC
from hydrus.core import HydrusGlobals as HG
from hydrus.core import HydrusPaths
from hydrus.client.gui import ClientGUIDialogsQuick
def DeletePath( path, always_delete_fully = False ):
delete_to_recycle_bin = HC.options[ 'delete_to_recycle_bin' ]
@ -52,4 +54,10 @@ def OpenDocumentation( documentation_path : str ):
else:
remote = ClientGUIDialogsQuick.ConfirmOpenOnlineHelpIfLocalDoesntExist( None, remote )
if remote is None:
return
LaunchURLInWebBrowser( remote )

View File

@ -4964,41 +4964,7 @@ class FrameGUI( CAC.ApplicationCommandProcessorMixin, ClientGUITopLevelWindows.M
def _OpenHelp( self ):
help_path = os.path.join( HC.HELP_DIR, 'index.html' )
if os.path.exists( help_path ):
ClientPaths.LaunchPathInWebBrowser( help_path )
else:
message = 'You do not have a local help! Are you running from source? Would you like to open the online help or see a guide on how to build your own?'
yes_tuples = []
yes_tuples.append( ( 'open online help', 0 ) )
yes_tuples.append( ( 'open how to build guide', 1 ) )
try:
result = ClientGUIDialogsQuick.GetYesYesNo( self, message, yes_tuples = yes_tuples, no_label = 'forget it' )
except HydrusExceptions.CancelledException:
return
if result == 0:
url = 'https://hydrusnetwork.github.io/hydrus/'
elif result == 1:
url = 'https://hydrusnetwork.github.io/hydrus/about_docs.html'
ClientPaths.LaunchURLInWebBrowser( url )
ClientPaths.OpenDocumentation( HC.DOCUMENTATION_INDEX )
def _OpenInstallFolder( self ):

View File

@ -255,4 +255,31 @@ def SelectServiceKey( service_types = None, service_keys = None, unallowed = Non
return None
def ConfirmOpenOnlineHelpIfLocalDoesntExist( dialog_owner, online_help_link : str ) -> str:
message = 'You do not have a local help! Are you running from source? Would you like to open the online help or see a guide on how to build your own?'
yes_tuples = []
yes_tuples.append( ( 'open online help', 0 ) )
yes_tuples.append( ( 'open how to build guide', 1 ) )
try:
result = GetYesYesNo( dialog_owner, message, yes_tuples = yes_tuples, no_label = 'forget it' )
except HydrusExceptions.CancelledException:
return
if result == 0:
url = online_help_link
elif result == 1:
url = "/".join( ( HC.REMOTE_HELP.rstrip("/"), HC.DOCUMENTATION_ABOUT_DOCS.lstrip("/") ) )
return url

View File

@ -1098,6 +1098,7 @@ url_type_string_lookup = {
REMOTE_HELP = "https://hydrusnetwork.github.io/hydrus"
DOCUMENTATION_INDEX = "index.html"
DOCUMENTATION_CHANGELOG = f"changelog.html#version_{SOFTWARE_VERSION}"
DOCUMENTATION_DOWNLOADER_GUGS = "downloader_gugs.html"
DOCUMENTATION_DOWNLOADER_LOGIN = 'downloader_login.html'
@ -1113,7 +1114,7 @@ DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__COMPOUND_FORMULA = 'downloader_parser
DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__CONTEXT_VARIABLE_FORMULA = 'downloader_parsers_formulae.html#context_variable_formula'
DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__HTML_FORMULA = 'downloader_parsers_formulae.html#html_formula'
DOCUMENTATION_DOWNLOADER_PARSERS_FORMULAE__JSON_FORMULA = 'downloader_parsers_formulae.html#json_formula'
DOCUMENTATION_ABOUT_DOCS = "about_docs.html"
# default options