Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ python -c "import src; print('OK')"
The regression suite uses `python -m unittest discover -s tests -v`. Each backend module also has a `__main__` smoke test:

```powershell
python -m src.icons # writes 3 test PNGs (32x32)
python -m src.icons # writes 3 test PNGs (64x64)
python -m src.config # prints defaults, DPAPI roundtrip, creates APP_DIR
python -m src.audio # records 3s -> test.wav, prints duration + RMS
python -m src.hotkey # prints pressed/released (Windows only)
python -m src.injector "hello" # types into active window (Windows only)
python -m src.stt test.wav # transcribes (needs API config)
python -m src.rewrite "test sentense" # corrects text (needs API config)
python -m src.settings_dialog # launches the 4-tab dialog standalone
python -m src.settings_dialog # launches the settings dialog standalone (themed)
```

CLI scripts resolve credentials in this order: `load_config()` (QSettings + DPAPI) → backfill empty fields from a `.env` at cwd via `import_from_env()` → if still empty, print a setup message to stderr and `exit(1)`. No hardcoded provider defaults.
Expand Down
33 changes: 30 additions & 3 deletions docs/IMPLEMENTATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ src/
├── recovery_dialog.py
├── icons.py
├── snackbar.py
├── theme.py (Hush design system: tokens, fonts, QSS, window polish)
├── assets/
│ ├── fonts/ (Geist + Geist Mono, SIL OFL — see OFL.txt)
│ └── icons/ (SVG glyphs referenced by the stylesheet)
├── utils.py
└── startup.py
requirements.txt (repo root)
Expand Down Expand Up @@ -454,7 +458,7 @@ class TrayState(Enum):
IDLE = "idle"; RECORDING = "recording"; PROCESSING = "processing"

def get_icon_pixmap(state: TrayState) -> QPixmap: ...
"""32x32 QPixmap from embedded base64 PNG. Grey=idle, red=recording, yellow=processing."""
"""64x64 QPixmap from embedded base64 PNG. Grey=idle, ember=recording, tide blue=processing."""

def get_icon_bytes(state: TrayState) -> bytes: ...
"""Raw PNG bytes for testing without Qt."""
Expand All @@ -481,6 +485,27 @@ class RecordingSnackbar(QWidget):
Processing/idle reset the meter. No gain, speech-quality, or device-health claim."""
```

### theme.py

```python
CANVAS, SURFACE, RAISED, HOVER, LINE, LINE_STRONG, TEXT, TEXT_2, TEXT_3: str # surface/text tokens
EMBER, TIDE, MOSS, ROSE, AMBER: str # signal colors: recording, processing, success, error, warning

def apply_theme(app: QApplication) -> None: ...
"""Fusion style + bundled fonts, dark palette, app stylesheet; on Windows also a
dark native title bar for every window/dialog on first show. Idempotent."""
def set_role(widget: QWidget, role: str) -> QWidget: ...
"""Tag a widget for `[hush="role"]` selectors (title, section, hint, error, warning,
primary, ghost, danger, ...)."""
def polish_menu(menu: QMenu) -> QMenu: ...
"""Rounded, shadow-free popup; call before the menu is first shown."""
def draw_mark(painter: QPainter, rect: QRectF, color: QColor) -> None: ...
"""Paint the three-bar Screamer mark (also baked into the tray PNGs)."""
```

Appearance only: theme functions never alter widget state, signals or text.
`main.py` and the standalone `settings_dialog` entry point call `apply_theme()`.

### settings_dialog.py

```python
Expand All @@ -496,7 +521,8 @@ class SettingsDialog(QDialog):
calibrate_fn: Callable[[int | None], float] | None = None,
refresh_devices_fn: Callable[[], list[tuple[int, str]]] | None = None,
): ...
"""6-tab dialog (General, STT, LLM, Audio, Vocabulary, Rewrite Profiles) prefilled from config.
"""6-page dialog (General, STT, LLM, Audio, Vocabulary, Rewrite Profiles) prefilled from config.
Pages sit behind a sidebar whose `_tabs` object keeps QTabWidget index semantics.
Edits a copy; Apply and OK persist validated settings.
*devices*: list of (device_id, display_name) for the Audio tab.
*calibrate_fn*: fn(device_id) -> float for RMS calibration, after fresh identity validation.
Expand Down Expand Up @@ -544,7 +570,8 @@ No public exports. Entry point only:
| Rule | Detail |
|------|--------|
| Composition root | `main.py` imports all other modules. Nothing imports `main.py`. |
| Settings dialog | `settings_dialog.py` imports `config.py`, `startup.py`, `utils.py`, and the shared `audio.py` device-resolution policy. |
| Settings dialog | `settings_dialog.py` imports `config.py`, `startup.py`, `utils.py`, `theme.py`, and the shared `audio.py` device-resolution policy. |
| Theme | UI modules (`settings_dialog.py`, `recovery_dialog.py`, `snackbar.py`, `main.py`) may import `theme.py`; `theme.py` imports only Qt. |
| Shared utilities | `audio.py`, `hotkey.py`, `stt.py`, `rewrite.py`, `injector.py`, `startup.py` may import `utils.py`. |
| Zero peer imports | The six backend modules must NOT import each other. |
| Config consumer | `stt.py` and `rewrite.py` import config value types and receive `AppConfig` as a parameter; `audio.py` and `hotkey.py` use config constants and value objects. |
Expand Down
2 changes: 1 addition & 1 deletion screamer.spec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ a = Analysis(
["src/main.py"],
pathex=[],
binaries=[],
datas=[],
datas=[("src/assets", "src/assets")],
hiddenimports=collect_submodules("PySide6") + ["sounddevice", "numpy", "httpx", "dotenv"],
hookspath=[],
hooksconfig={},
Expand Down
Binary file added src/assets/fonts/Geist-Medium.ttf
Binary file not shown.
Binary file added src/assets/fonts/Geist-Regular.ttf
Binary file not shown.
Binary file added src/assets/fonts/Geist-SemiBold.ttf
Binary file not shown.
Binary file added src/assets/fonts/GeistMono-Medium.ttf
Binary file not shown.
Binary file added src/assets/fonts/GeistMono-Regular.ttf
Binary file not shown.
93 changes: 93 additions & 0 deletions src/assets/fonts/OFL.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
Copyright 2024 The Geist Project Authors (https://github.com/vercel/geist-font)

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
https://openfontlicense.org


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
1 change: 1 addition & 0 deletions src/assets/icons/check.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/chevron-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/chevron-up.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/radio-off.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/icons/radio-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 34 additions & 12 deletions src/icons.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
"""Embedded 32x32 PNG icons for tray states: idle, recording, processing."""
"""Embedded 64x64 PNG icons for tray states: idle, recording, processing."""

from __future__ import annotations

Expand All @@ -14,22 +14,44 @@ class TrayState(Enum):
PROCESSING = "processing"


# Embedded base64 PNG data (32x32 RGBA) for each tray state.
# Embedded base64 PNG data (64x64 RGBA, the Hush waveform mark) for each tray state.
_EMBEDDED_PNG: dict[TrayState, bytes] = {
TrayState.IDLE: base64.b64decode(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAAR0lEQVR42u3WwQkAIAzF0O7P31kX"
"8NBLDWICnvtAKK0ye7Ek6/QECBAgQIAAbPAVSHf4GAIH4F/QRSCXEX6aCcA34B+LyKbaY7Gl8Ci"
"VH8wAAAAASUVORK5CYII="
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACM0lE"
"QVR4nO2asWobQRCG/zmldHCR8lTkOhkXATcqLfA7mBQCByNi/BTLPYWwMMIiDgSV6Q1S6QcwdqfGeoKo"
"lSaFL+msXaHR7B6ar/7Z/fVrd2ZgDzAMwzAMY18h7Q2dc1mzaPWY6RKEYwAA44mIh6+zl9uyLFeaflQD"
"6I/GeYNX9wA670gmS8q61xfncy1PDa2NnHPZ4eGn3yDqrJF9zsAnJ1+Of0ynU9bwlWlsAgDNotUD0WmA"
"tNMsWr2dG6pQC4CZLneh3Ra1AP4XPGntlnzQ2gjAgaRWqpvonQBB+qNxnhdHDwy6AaGNt8AOQGgz6CYv"
"jh76o3EeslbtAnDOZY3V8ifeb6UA0Gnw6t455/19tQtAupsE14BUJrhq/3AtMFinCToBkndua4S7iTcA"
"6TsngGg38RpOdYKTwhtAqhOcFP4jm+gEJ0XInRW9c6lRuzlAGgsgtoHYWACxDcTGAohtIDYWQGwDsbEA"
"YhuIjQUQ20BsLIDYBmITEsBig/U20SaBPwDGU/Bqm2gTwRsAEQ9DF9tEmwreAF5nL7cAJgFrTSptrfAG"
"UJblaklZF+tDmCwp6yq9DonWpKAucH1xPp/Pns8IfAXGY7XwAoxHAl/NZ89nat/1CNek4LfB6t8dwPPW"
"tmuIeMigdqjWp6ndHCBdk2oXgHRNql0AgGxNUvtQcn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8F89p1tUggvgAAAABJRU5ErkJggg=="
),
TrayState.PROCESSING: base64.b64decode(
"iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAASklEQVR42mNgGAWjYCiCO1tE/mPD"
"ow4YdcCoA0YdMOqAUQcMmMV0cQixltPMEQPugAGPAmIdMSAtowFvmo06YMBLwJFREI0CWgEA4LGl"
"8JJpBiYAAAAASUVORK5CYII="
"iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAAACXBIWXMAAA7EAAAOxAGVKw4bAAAB/UlE"
"QVR4nO2aMWpCQRCG/3laWgoWHiEHEDQQwWtYBcFDWIiFh1DEyhxDsFDBA3gEiweWlvomRR6k0t0XJ7P7"
"cL4yDLuTz30zA7uAYRiGYRivCmlvOGZOsm06YMIngLf8z0diLJP3xmJClGnmoypgtD83KbuuAHTvhGw4"
"qfan7fpJK6dEa6Mxc0J8/cL9fx4AupRdV2NmtbzUNsq26QCMD4/QbrZNB/+eUI6agPybF499FjUB+C14"
"0rFPUdXaCEBNMlaqm2ieADFG+3PztkvXTJgBaOFHWA1Aiwmz2y5dj/bnps9apRMg3U1KJ0C6m3jXgFgm"
"uD90k/mjGK8TIPnNCSDaTZwCIpzgRLuJM+FYJzgpnAJineCk8DmyUU5wUvgIEP3mYqN0c4A0JiB0AqEx"
"AaETCI0JCJ1AaExA6ARCYwJCJxAaExA6gdCYgNAJhMZHwKXAekVio8BHwLHAekVio8ApgBhL38WKxMaC"
"++rovbEAsPFYa5PHlgqngAlRxkm1j8cSNpxU+0q3Q6I1yasLTNv1U6XT6BFjCOCQL3wBcCDGsNJp9BTf"
"9YjWJO+7wfzXncNx1/bfEGPJhJZvrCumdHOAdE0qnQDpmlQ6AYBsTdJ8I3SB/82Rs3pL1STNExDlRKkm"
"INaJUu9JaqQTpZqACCdKAPZc3jAMwzCMF+YbTHPprRi3kvgAAAAASUVORK5CYII="
),
}

Expand All @@ -41,7 +63,7 @@ class TrayState(Enum):


def get_icon_pixmap(state: TrayState) -> QPixmap:
"""32x32 QPixmap from embedded base64 PNG data (decoded once per state, then cached)."""
"""64x64 QPixmap from embedded base64 PNG data (decoded once per state, then cached)."""
pixmap = _pixmap_cache.get(state)
if pixmap is None:
pixmap = QPixmap()
Expand Down
7 changes: 4 additions & 3 deletions src/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
save_config,
validate_config,
)
from src import http_client
from src import http_client, theme
from src.hotkey import HotkeyListener, HotkeyMode
from src.icons import TrayState, get_icon_pixmap
from src.injector import WindowIdentity, get_foreground_target, type_text
Expand Down Expand Up @@ -288,7 +288,7 @@ def _build_tray(self) -> None:
self._tray = QSystemTrayIcon(self)
self._tray.setIcon(QIcon(get_icon_pixmap(TrayState.IDLE)))
self._tray.setToolTip("Screamer — Idle")
self._menu = QMenu()
self._menu = theme.polish_menu(QMenu())
self._tray.setContextMenu(self._menu)
self._rebuild_menu()
self._tray.activated.connect(self._on_tray_activated)
Expand All @@ -301,7 +301,7 @@ def _add_choice_submenu(
current: str,
on_select: Any,
) -> QMenu:
submenu = QMenu(title, self._menu)
submenu = theme.polish_menu(QMenu(title, self._menu))
submenu.setEnabled(self._settings_dlg is None)
self._menu.addMenu(submenu)
group = QButtonGroup(submenu)
Expand Down Expand Up @@ -1386,6 +1386,7 @@ def main(argv: list[str] | None = None) -> None:

app = QApplication([])
app.setQuitOnLastWindowClosed(False)
theme.apply_theme(app)

directory = Path(APP_DIR).resolve()
tray_app: _TrayApp | None = None
Expand Down
Loading
Loading