Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH: Enable Find text at Slicer start/restart #73

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion LanguageTools/LanguageTools.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ def updateGUIFromSettings(self):
self.ui.weblateDownloadUrlEdit.text = settings.value("WeblateDownloadUrl", "https://hosted.weblate.org/download/3d-slicer")
self.ui.githubRepositoryUrlEdit.text = settings.value("GitRepository", "https://github.com/Slicer/SlicerLanguageTranslations")

# Boolean values are stored as strings in the settings.
# False becomes 'false' and True becomes 'true'
textFinderIsEnabled = settings.value("EnableFindText", True)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it disabled by default.
Use slicer.util.toBool to always get Boolean.

Suggested change
textFinderIsEnabled = settings.value("EnableFindText", True)
textFinderIsEnabled = slicer.util.toBool(settings().value("EnableFindText", False))

self.ui.enableTextFindercheckBox.checked = True if (textFinderIsEnabled in [True, 'true']) else False
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
self.ui.enableTextFindercheckBox.checked = True if (textFinderIsEnabled in [True, 'true']) else False
self.ui.enableTextFindercheckBox.checked = textFinderIsEnabled

self.ui.textFinderLanguageEdit.text = settings.value("FindTextLanguage", "fr-FR")

finally:
Expand Down Expand Up @@ -379,6 +383,7 @@ def updateSettingsFromGUI(self):
settings.setValue("WeblateDownloadUrl", self.ui.weblateDownloadUrlEdit.text)
settings.setValue("LreleaseFilePath", self.ui.lreleasePathLineEdit.currentPath)

settings.setValue("EnableFindText", self.ui.enableTextFindercheckBox.checked)
settings.setValue("FindTextLanguage", self.ui.textFinderLanguageEdit.text)

languages = self.selectedWeblateLanguages()
Expand Down Expand Up @@ -429,8 +434,8 @@ def onRestartButton(self):
slicer.util.restart()

def enableTextFinder(self, enable):
self.updateSettingsFromGUI()
if enable:
self.updateSettingsFromGUI()
self.logic.preferredLanguage = self.ui.textFinderLanguageEdit.text
self.textFinder.enableShortcut(enable)
# Only allow changing language if finder is disabled
Expand Down