Skip to content

Conversation

@blaskocode
Copy link

@blaskocode blaskocode commented Nov 26, 2025

Resolves: Feature request for lyrics spellchecking in MuseScore

Summary

This PR adds a new Tools > Check lyrics spelling... feature that allows users to scan all lyrics in their score for spelling errors using the Hunspell spell checking library.

Problem Solved

Lyrics entry in MuseScore is error-prone. The current workaround requires:

  1. Tools → Copy lyrics to clipboard
  2. Paste into a word processor
  3. Spellcheck externally
  4. Manually fix typos back in MuseScore

This is slow and brittle, especially on large scores or multi-verse choral works.

Feature Overview

  • Menu action: Tools > Check lyrics spelling...
  • Dialog: Shows unknown words with count and first location (measure, staff, verse)
  • Navigation: Click "Go to" or double-click to navigate to the lyric in the score
  • Rescan: Re-run spellcheck after making corrections
  • Language: Auto-detects from system locale with platform-specific dictionary discovery

Architecture

This is an end-to-end feature spanning:

Layer Components
Build System CMake Hunspell detection via pkg-config
Backend HunspellSpellChecker with platform-specific dictionary discovery
Service LyricsSpellCheckService with word reconstruction from syllables
Model LyricsSpellingIssuesModel (QAbstractListModel)
UI QML dialog following existing patterns

Files Added (22 files, ~1,500 lines)

  • Interfaces: ispellchecker.h, ilyricsspellcheckservice.h
  • Implementation: hunspellspellchecker.cpp/.h, lyricsspellcheckservice.cpp/.h, stubspellchecker.h
  • UI: LyricsSpellingIssuesDialog.qml, lyricsspellingissuesmodel.cpp/.h
  • Build: SetupHunspell.cmake, CMakeLists changes
  • Tests: lyricsspellcheck_tests.cpp, spellcheckermock.h
  • Integration: Action controller, UI actions, menu model changes

Test Plan

  • Build succeeds with Hunspell (cmake -DMUE_COMPILE_USE_SYSTEM_HUNSPELL=ON)
  • Build succeeds without Hunspell (stub implementation used)
  • Menu item appears under Tools menu when score is open
  • Warning shown when no dictionaries installed
  • Dialog correctly lists misspelled words from test scores
  • "Go to" navigates to and selects the correct Lyrics element
  • Score viewport scrolls to show the selected lyric
  • "Rescan" updates list after fixing typos
  • Empty state shows "All lyrics are spelled correctly!" when no issues
  • Dialog can remain open while editing score
  • Multi-verse/multi-staff scores handled correctly
  • Hyphenated lyrics reconstructed as words

Prerequisites for Testing

macOS: brew install hunspell
Linux: sudo apt install hunspell libhunspell-dev hunspell-en-us
Windows: Install hunspell and place dictionaries in %APPDATA%/hunspell/

Checklist

  • I signed the CLA
  • The title of the PR describes the problem it addresses
  • Each commit's message describes its purpose and effects
  • If changes are extensive, there is a sequence of easily reviewable commits
  • The code in the PR follows the coding rules
  • There are no unnecessary changes
  • The code compiles and runs on my machine
  • I created a unit test to verify the changes I made

@blaskocode blaskocode force-pushed the spell-check branch 3 times, most recently from 0e2b7e1 to e1348aa Compare November 26, 2025 15:52
Introduce ISpellChecker interface for spell checking with:
- HunspellSpellChecker: Platform-specific dictionary discovery
  (Linux: /usr/share/hunspell, macOS: /Library/Spelling, Windows: %APPDATA%)
- StubSpellChecker: Fallback when Hunspell is unavailable
- CMake integration via SetupHunspell.cmake using pkg-config

Build option MUE_COMPILE_USE_SYSTEM_HUNSPELL controls compilation.
Introduce ILyricsSpellCheckService for checking lyrics spelling:
- Collects all lyrics from score via Score::lyrics()
- Reconstructs words from hyphenated syllables using LyricsSyllabic
- Maps misspelled words to Lyrics elements for navigation
- Formats human-readable locations (measure, staff, verse)
- Returns LyricsSpellCheckResult with issues list and statistics
Add user interface for lyrics spellchecking:
- LyricsSpellingIssuesDialog.qml: Non-modal dialog showing issues list
  with word, count, and location columns; Go to, Rescan, Close buttons
- LyricsSpellingIssuesModel: QAbstractListModel backing the dialog
- "check-lyrics-spelling" action registered in NotationUiActions
- Handler in NotationActionController with availability warning
- Menu item added to Tools menu in AppMenuModel
- Services registered in NotationModule

Access via: Tools > Check lyrics spelling...
Add test suite Notation_LyricsSpellCheckTests with:
- SpellCheckerMock for testing ISpellChecker interface
- Tests for service availability based on spellchecker state
- Tests for language selection delegation
- Tests for error handling (unavailable spellchecker, null notation)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant