diff --git a/FyneApp.toml b/FyneApp.toml index a336c14..528f447 100644 --- a/FyneApp.toml +++ b/FyneApp.toml @@ -2,5 +2,5 @@ Icon = "Icon.png" Name = "TurtleSilicon" ID = "com.tairasu.turtlesilicon" - Version = "1.2.0" - Build = 33 + Version = "1.2.1" + Build = 37 diff --git a/main.go b/main.go index 962de52..35075f2 100644 --- a/main.go +++ b/main.go @@ -15,7 +15,7 @@ import ( "fyne.io/fyne/v2/widget" ) -const appVersion = "1.2.0" +const appVersion = "1.2.1" func main() { TSApp := app.NewWithID("com.tairasu.turtlesilicon") diff --git a/pkg/ui/components.go b/pkg/ui/components.go index 6659aca..3608a9e 100644 --- a/pkg/ui/components.go +++ b/pkg/ui/components.go @@ -173,6 +173,7 @@ func createWineRegistryComponents() { enableOptionAsAltButton = widget.NewButton("Enable", func() { enableOptionAsAltButton.Disable() disableOptionAsAltButton.Disable() + remapOperationInProgress = true // Show loading state in status label fyne.Do(func() { @@ -182,6 +183,10 @@ func createWineRegistryComponents() { // Run in goroutine to avoid blocking UI go func() { + defer func() { + remapOperationInProgress = false + }() + if err := utils.SetOptionAsAltEnabled(true); err != nil { debug.Printf("Failed to enable Option-as-Alt mapping: %v", err) // Update UI on main thread @@ -210,6 +215,7 @@ func createWineRegistryComponents() { disableOptionAsAltButton = widget.NewButton("Disable", func() { enableOptionAsAltButton.Disable() disableOptionAsAltButton.Disable() + remapOperationInProgress = true // Show loading state in status label fyne.Do(func() { @@ -219,6 +225,10 @@ func createWineRegistryComponents() { // Run in goroutine to avoid blocking UI go func() { + defer func() { + remapOperationInProgress = false + }() + if err := utils.SetOptionAsAltEnabled(false); err != nil { debug.Printf("Failed to disable Option-as-Alt mapping: %v", err) // Update UI on main thread @@ -298,33 +308,31 @@ func startPulsingEffect() { dots := "" for pulsingActive { - select { - case <-pulsingTicker.C: - if pulsingActive { - // Cycle through different dot patterns for visual effect - switch len(dots) { - case 0: - dots = "." - case 1: - dots = ".." - case 2: - dots = "..." - default: - dots = "" - } - - // Update the label with pulsing dots - fyne.Do(func() { - if pulsingActive && optionAsAltStatusLabel != nil { - // Use the dots directly in the status text - if strings.Contains(optionAsAltStatusLabel.String(), "Enabling") { - optionAsAltStatusLabel.ParseMarkdown("**Remap Option key as Alt key:** Enabling" + dots) - } else if strings.Contains(optionAsAltStatusLabel.String(), "Disabling") { - optionAsAltStatusLabel.ParseMarkdown("**Remap Option key as Alt key:** Disabling" + dots) - } - } - }) + <-pulsingTicker.C + if pulsingActive { + // Cycle through different dot patterns for visual effect + switch len(dots) { + case 0: + dots = "." + case 1: + dots = ".." + case 2: + dots = "..." + default: + dots = "" } + + // Update the label with pulsing dots + fyne.Do(func() { + if pulsingActive && optionAsAltStatusLabel != nil { + // Use the dots directly in the status text + if strings.Contains(optionAsAltStatusLabel.String(), "Enabling") { + optionAsAltStatusLabel.ParseMarkdown("**Remap Option key as Alt key:** Enabling" + dots) + } else if strings.Contains(optionAsAltStatusLabel.String(), "Disabling") { + optionAsAltStatusLabel.ParseMarkdown("**Remap Option key as Alt key:** Disabling" + dots) + } + } + }) } } }() diff --git a/pkg/ui/popup.go b/pkg/ui/popup.go index 513bb95..3e0ba17 100644 --- a/pkg/ui/popup.go +++ b/pkg/ui/popup.go @@ -66,8 +66,55 @@ func showOptionsPopup() { // Set the close button action to hide the popup closeButton.OnTapped = func() { - popup.Hide() + if remapOperationInProgress { + // Show warning popup instead of closing + showRemapWarningPopup() + } else { + popup.Hide() + } } popup.Show() } + +// showRemapWarningPopup shows a warning popup when user tries to close options during remap operation +func showRemapWarningPopup() { + if currentWindow == nil { + return + } + + // Create warning content + warningTitle := widget.NewRichTextFromMarkdown("# ⚠️ Please Wait") + warningMessage := widget.NewRichTextFromMarkdown("**Remap operation is in progress.**\n\nThe wine registry is being modified. This will take a moment.\n\nPlease wait for the operation to complete before closing the options.") + + // Create OK button + okButton := widget.NewButton("OK", func() { + // This will be set when the popup is created + }) + okButton.Importance = widget.HighImportance + + // Create warning content container + warningContent := container.NewVBox( + container.NewCenter(warningTitle), + widget.NewSeparator(), + warningMessage, + widget.NewSeparator(), + container.NewCenter(okButton), + ) + + // Calculate smaller popup size + windowSize := currentWindow.Content().Size() + popupWidth := windowSize.Width * 2 / 3 + popupHeight := windowSize.Height / 2 + + // Create the warning popup + warningPopup := widget.NewModalPopUp(container.NewPadded(warningContent), currentWindow.Canvas()) + warningPopup.Resize(fyne.NewSize(popupWidth, popupHeight)) + + // Set the OK button action to hide the warning popup + okButton.OnTapped = func() { + warningPopup.Hide() + } + + warningPopup.Show() +} diff --git a/pkg/ui/variables.go b/pkg/ui/variables.go index 01c987d..817a0e1 100644 --- a/pkg/ui/variables.go +++ b/pkg/ui/variables.go @@ -45,6 +45,7 @@ var ( // State variables currentWineRegistryEnabled bool + remapOperationInProgress bool // Pulsing effect variables (pulsingActive is in status.go) pulsingTicker *time.Ticker diff --git a/pkg/utils/wine_registry.go b/pkg/utils/wine_registry.go index 0943489..a746f2a 100644 --- a/pkg/utils/wine_registry.go +++ b/pkg/utils/wine_registry.go @@ -10,7 +10,7 @@ import ( ) const ( - wineRegistrySection = "[Software\\Wine\\Mac Driver]" + wineRegistrySection = "[Software\\\\Wine\\\\Mac Driver]" leftOptionKey = "\"LeftOptionIsAlt\"=\"Y\"" rightOptionKey = "\"RightOptionIsAlt\"=\"Y\"" wineLoaderPath = "/Applications/CrossOver.app/Contents/SharedSupport/CrossOver/CrossOver-Hosted Application/wineloader2" diff --git a/turtlesilicon b/turtlesilicon new file mode 100755 index 0000000..cb42c00 Binary files /dev/null and b/turtlesilicon differ diff --git a/winerosetta/libSiliconPatch.dll b/winerosetta/libSiliconPatch.dll index 3f9ae85..1e72171 100644 Binary files a/winerosetta/libSiliconPatch.dll and b/winerosetta/libSiliconPatch.dll differ