meerk40t / meerk40t

Hackable Laser software for K40 / GRBL / Fibre Lasers
MIT License
233 stars 62 forks source link

Make Beep sound user-configurable #2675

Closed jpirnay closed 1 week ago

jpirnay commented 1 week ago

Summary by Sourcery

Add user-configurable beep sound feature, enabling users to select custom sound files for the beep command across different operating systems.

New Features:

Enhancements:

sourcery-ai[bot] commented 1 week ago

Reviewer's Guide by Sourcery

The PR implements user-configurable beep sounds by adding a new preference setting and refactoring the sound playing logic. The implementation uses a dictionary-based approach for platform-specific sound file paths and introduces dedicated player functions for each supported platform. The changes also include improved error handling and sound file validation.

Sequence diagram for user-configurable beep sound

sequenceDiagram
    actor User
    participant System
    participant WindowsPlayer
    participant DarwinPlayer
    participant LinuxPlayer

    User->>System: Issue 'beep' command
    System->>System: Determine OS_NAME
    alt Windows
        System->>WindowsPlayer: Play sound
        WindowsPlayer->>System: Use default or custom sound
    else Darwin
        System->>DarwinPlayer: Play sound
        DarwinPlayer->>System: Use default or custom sound
    else Linux
        System->>LinuxPlayer: Play sound
        LinuxPlayer->>System: Use default or custom sound
    end

Updated class diagram for sound configuration

classDiagram
    class Kernel {
        +console_command beep
        +console_argument sleeptime
    }
    class SoundPlayer {
        +_play_windows()
        +_play_darwin()
        +_play_linux()
    }
    class Preferences {
        +beep_soundfile: str
        +default_snd: str
        +wildcard: str
    }
    Kernel --> SoundPlayer
    Kernel --> Preferences
    note for Preferences "Handles user-configurable sound settings"

File-Level Changes

Change Details Files
Refactor beep command implementation with platform-specific sound handling
  • Add dictionary mapping for default system sounds per platform
  • Create dedicated player functions for Windows, Darwin, and Linux
  • Add sound file validation check
  • Replace nested if-else with dictionary-based function dispatch
  • Add support for custom sound file playback on all platforms
meerk40t/kernel/kernel.py
Add user interface elements for custom sound file configuration
  • Add file picker preference for sound file selection
  • Configure platform-specific file wildcards for sound file types
  • Add helpful tooltip with installation instructions for Linux users
  • Define default system sound paths per platform
meerk40t/gui/wxmeerk40t.py

Tips and commands #### Interacting with Sourcery - **Trigger a new review:** Comment `@sourcery-ai review` on the pull request. - **Continue discussions:** Reply directly to Sourcery's review comments. - **Generate a GitHub issue from a review comment:** Ask Sourcery to create an issue from a review comment by replying to it. - **Generate a pull request title:** Write `@sourcery-ai` anywhere in the pull request title to generate a title at any time. - **Generate a pull request summary:** Write `@sourcery-ai summary` anywhere in the pull request body to generate a PR summary at any time. You can also use this command to specify where the summary should be inserted. #### Customizing Your Experience Access your [dashboard](https://app.sourcery.ai) to: - Enable or disable review features such as the Sourcery-generated pull request summary, the reviewer's guide, and others. - Change the review language. - Add, remove or edit custom review instructions. - Adjust other review settings. #### Getting Help - [Contact our support team](mailto:support@sourcery.ai) for questions or feedback. - Visit our [documentation](https://docs.sourcery.ai) for detailed guides and information. - Keep in touch with the Sourcery team by following us on [X/Twitter](https://x.com/SourceryAI), [LinkedIn](https://www.linkedin.com/company/sourcery-ai/) or [GitHub](https://github.com/sourcery-ai).
jpirnay commented 1 week ago

@sourcery-ai review

jpirnay commented 1 week ago

@sourcery-ai review