Skip to content

Latest commit

 

History

History
127 lines (100 loc) · 4.46 KB

File metadata and controls

127 lines (100 loc) · 4.46 KB

Training Start Button Feature

Overview

Added a Start/Stop button to the training window, allowing users to configure their training settings before starting a session.

Problem Solved

Previously, the training session would start immediately when the training window opened or settings were changed. This didn't give users time to:

  • Review and adjust session settings
  • Select the appropriate session number
  • Choose the practice type (Characters, Words, Q-Codes, Mixed)
  • Configure Random Blocks mode parameters
  • Select Sending vs Listening practice mode

Solution

Added a training session state that separates configuration from active training:

  1. Configuration Mode (session not started): Users can adjust all settings
  2. Active Training Mode (session started): Practice exercises are displayed

Changes Made

1. New State Field

  • Added training_session_active: bool to AppState
  • Default value: false (not started)

2. Start/Stop Button

  • Large, prominent button in the center of the training window
  • Green color when stopped: "▶ Start Training Session"
  • Red color when active: "⏹ Stop Training Session"
  • Toggles between configuration and active training modes

3. Configuration Section

  • All training settings now grouped in a configuration panel
  • Settings remain accessible but won't regenerate content until session is started
  • Settings include:
    • Session selection (1-26)
    • Practice type selection
    • Random Blocks mode toggle and settings
    • Training mode selection (Sending/Listening)

4. Session Lifecycle

Starting a Session (Click Start)

When clicking "Start Training Session":

  1. training_session_active = true
  2. training_mode = true (enables training features)
  3. Clears any previous training state
  4. Generates first training item based on settings
  5. Shows training content area

Active Session

  • Training exercises are displayed
  • Configuration settings still visible but changes only apply to new items
  • User can practice sending or listening
  • Statistics are tracked

Stopping a Session (Click Stop)

When clicking "Stop Training Session":

  1. training_session_active = false
  2. training_mode = false
  3. Clears all training state (decoded text, answers, timers)
  4. Returns to configuration mode
  5. Hides training content

5. Content Visibility

  • Before Start: Shows message "Configure your training settings above, then click Start!"
  • After Start: Shows full training interface (practice text, play buttons, statistics, etc.)

User Workflow

Typical Training Session

  1. Open Training Window

    • Click "🎓 Open Training Window" in main window
  2. Configure Settings

    • Select Session (e.g., Session 5)
    • Choose Practice Type (e.g., "Mixed")
    • Optional: Enable Random Blocks mode
    • Choose Training Mode (Sending or Listening)
  3. Start Session

    • Click "▶ Start Training Session" button
    • Training content appears immediately
    • First exercise is generated
  4. Practice

    • For Sending: Practice sending the displayed text
    • For Listening: Play morse code and decode it
    • Statistics are tracked automatically
  5. Stop Session (Optional)

    • Click "⏹ Stop Training Session" to end
    • Can reconfigure settings and start a new session

Benefits

  1. No Rushed Configuration: Take time to set up training parameters properly
  2. Clear Intent: Explicit action required to start training
  3. Easy Reset: Stop and restart with new settings anytime
  4. Better UX: Separates setup from active practice
  5. No Accidental Starts: Training won't begin until user is ready
  6. Session Control: Clear start and stop points for training sessions

Technical Details

State Management

  • training_session_active controls visibility of training content
  • Separate from training_mode which controls broader training features
  • Both must be true for active training

Conditional Regeneration

  • Settings changes during active session only affect new items
  • Previous training state is preserved during configuration changes
  • Fresh start when session is stopped and restarted

Thread Safety

  • State changes are properly synchronized with Arc<Mutex>
  • Lock is dropped before spawning audio playback threads

Future Enhancements

Possible improvements:

  • Session timer (how long user has been practicing)
  • Session statistics summary on stop
  • Auto-save last session configuration
  • Session pause/resume functionality
  • Multiple session presets