feat: HushKey 1.0.0 — per-app mute hotkeys for Windows, macOS and Linux
Native Rust tray app that binds global shortcuts to mute/unmute individual applications' audio, plus a Mute All / Restore All shortcut. - AudioController trait with per-OS backends: WASAPI sessions (Windows), Core Audio process taps (macOS 14.2+, mute only), PulseAudio/PipeWire sink inputs (Linux) - Dedicated audio thread; hotkey presses go straight to it - Snapshot-based Mute All that restores exactly the previous state - Slint UI with software renderer; window destroyed on close - Non-activating on-screen confirmation and tray icon flash - TOML config, launch at login, start minimized, dark/light theme - Procedurally drawn icon embedded into the Windows executable - Docs, AGENTS.md, CLAUDE.md, contributing guide and CI for all three OSes
This commit is contained in:
commit
8f476dbe52
40 files changed
+11604
No files matched your search
+595
@@ -0,0 +1,595 @@
|
||||
import { ListView, ScrollView, Palette } from "std-widgets.slint";
|
||||
import { Theme } from "theme.slint";
|
||||
import {
|
||||
SpeakerIcon, ThemeIcon, IconButton, Tabs, Switch, ShortcutChip, SettingRow, Card, SectionLabel
|
||||
} from "widgets.slint";
|
||||
|
||||
export { Toast } from "toast.slint";
|
||||
|
||||
export struct AppRow {
|
||||
key: string,
|
||||
name: string,
|
||||
subtitle: string,
|
||||
icon: image,
|
||||
has-icon: bool,
|
||||
initial: string,
|
||||
tint: color,
|
||||
running: bool,
|
||||
muted: bool,
|
||||
volume: float, // 0..1, < 0 when unknown
|
||||
shortcut: string, // display label, "" when unbound
|
||||
}
|
||||
|
||||
component Avatar inherits Rectangle {
|
||||
in property <AppRow> app;
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 10px;
|
||||
background: app.has-icon ? transparent : app.tint;
|
||||
if app.has-icon: Image {
|
||||
source: root.app.icon;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
image-fit: contain;
|
||||
}
|
||||
if !app.has-icon: Text {
|
||||
text: root.app.initial;
|
||||
color: white;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
|
||||
component MuteButton inherits Rectangle {
|
||||
in property <bool> muted;
|
||||
in property <bool> enabled: true;
|
||||
in property <string> label;
|
||||
callback clicked;
|
||||
width: 34px;
|
||||
height: 34px;
|
||||
border-radius: 17px;
|
||||
background: muted ? Theme.danger-soft : (touch.has-hover ? Theme.surface-sunken : transparent);
|
||||
opacity: enabled ? 1 : 0.4;
|
||||
animate background { duration: Theme.fast; }
|
||||
accessible-role: button;
|
||||
accessible-label: (muted ? "Unmute " : "Mute ") + label;
|
||||
accessible-action-default => { if (root.enabled) { root.clicked(); } }
|
||||
SpeakerIcon {
|
||||
muted: root.muted;
|
||||
color: root.muted ? Theme.danger : Theme.text-muted;
|
||||
}
|
||||
touch := TouchArea {
|
||||
enabled: root.enabled;
|
||||
mouse-cursor: pointer;
|
||||
clicked => { root.clicked(); }
|
||||
}
|
||||
}
|
||||
|
||||
component AppRowView inherits Rectangle {
|
||||
in property <AppRow> app;
|
||||
in property <bool> capturing;
|
||||
in property <bool> show-volume;
|
||||
callback toggle();
|
||||
callback capture();
|
||||
callback clear();
|
||||
|
||||
height: 64px;
|
||||
border-radius: 12px;
|
||||
background: hover.has-hover ? Theme.surface-hover : Theme.surface;
|
||||
border-width: 1px;
|
||||
border-color: capturing ? Theme.accent : Theme.border;
|
||||
animate background, border-color { duration: Theme.fast; }
|
||||
|
||||
hover := TouchArea { }
|
||||
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 10px;
|
||||
spacing: 12px;
|
||||
alignment: stretch;
|
||||
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Avatar { app: root.app; opacity: root.app.running ? 1 : 0.45; }
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 3px;
|
||||
horizontal-stretch: 1;
|
||||
Text {
|
||||
text: root.app.name;
|
||||
font-size: 13.5px;
|
||||
font-weight: 600;
|
||||
color: root.app.running ? Theme.text : Theme.text-muted;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: root.app.subtitle;
|
||||
font-size: 11.5px;
|
||||
color: root.app.muted ? Theme.danger : Theme.text-faint;
|
||||
overflow: elide;
|
||||
}
|
||||
if root.show-volume && root.app.running && root.app.volume >= 0: Rectangle {
|
||||
height: 3px;
|
||||
border-radius: 1.5px;
|
||||
background: Theme.surface-sunken;
|
||||
Rectangle {
|
||||
x: 0;
|
||||
width: parent.width * clamp(root.app.volume, 0, 1);
|
||||
height: parent.height;
|
||||
border-radius: 1.5px;
|
||||
background: root.app.muted ? Theme.text-faint : Theme.accent;
|
||||
animate width { duration: 200ms; }
|
||||
}
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
ShortcutChip {
|
||||
width: 132px;
|
||||
shortcut: root.app.shortcut;
|
||||
capturing: root.capturing;
|
||||
label: root.app.name + " shortcut";
|
||||
clicked => { root.capture(); }
|
||||
cleared => { root.clear(); }
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
MuteButton {
|
||||
muted: root.app.muted;
|
||||
enabled: root.app.running;
|
||||
label: root.app.name;
|
||||
clicked => { root.toggle(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component MuteAllCard inherits Rectangle {
|
||||
in property <bool> all-muted;
|
||||
in property <int> app-count;
|
||||
in property <string> shortcut;
|
||||
in property <string> restore-shortcut;
|
||||
in property <string> capturing;
|
||||
callback toggle();
|
||||
callback capture(string);
|
||||
callback clear(string);
|
||||
|
||||
border-radius: 18px;
|
||||
background: all-muted
|
||||
? @linear-gradient(135deg, #ff6b78 0%, #e0405a 100%)
|
||||
: @linear-gradient(135deg, #8a7bff 0%, #5b49f2 100%);
|
||||
drop-shadow-blur: 18px;
|
||||
drop-shadow-offset-y: 6px;
|
||||
drop-shadow-color: all-muted ? #e0405a40 : #5b49f240;
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 14px;
|
||||
HorizontalLayout {
|
||||
spacing: 12px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 2px;
|
||||
horizontal-stretch: 1;
|
||||
Text {
|
||||
text: root.all-muted ? "Everything is muted" : "Mute everything";
|
||||
color: white;
|
||||
font-size: 16px;
|
||||
font-weight: 700;
|
||||
}
|
||||
Text {
|
||||
text: root.all-muted
|
||||
? "Press again to restore exactly what was playing"
|
||||
: root.app-count == 1 ? "Instantly silence 1 app" : "Instantly silence " + root.app-count + " apps";
|
||||
color: #ffffffcc;
|
||||
font-size: 12px;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
width: 46px;
|
||||
height: 46px;
|
||||
border-radius: 23px;
|
||||
background: big.has-hover ? #ffffff : #fffffff0;
|
||||
drop-shadow-blur: 8px;
|
||||
drop-shadow-color: #00000033;
|
||||
accessible-role: button;
|
||||
accessible-label: root.all-muted ? "Restore all apps" : "Mute all apps";
|
||||
accessible-action-default => { root.toggle(); }
|
||||
SpeakerIcon {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
muted: root.all-muted;
|
||||
color: root.all-muted ? #e0405a : #5b49f2;
|
||||
}
|
||||
big := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => { root.toggle(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
horizontal-stretch: 1;
|
||||
Text { text: "TOGGLE"; color: #ffffffa6; font-size: 10px; font-weight: 700; letter-spacing: 0.8px; }
|
||||
ShortcutChip {
|
||||
on-accent: true;
|
||||
shortcut: root.shortcut;
|
||||
capturing: root.capturing == "@all";
|
||||
label: "Mute all shortcut";
|
||||
clicked => { root.capture("@all"); }
|
||||
cleared => { root.clear("@all"); }
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
horizontal-stretch: 1;
|
||||
Text { text: "RESTORE (OPTIONAL)"; color: #ffffffa6; font-size: 10px; font-weight: 700; letter-spacing: 0.8px; }
|
||||
ShortcutChip {
|
||||
on-accent: true;
|
||||
shortcut: root.restore-shortcut;
|
||||
placeholder: "Same as toggle";
|
||||
capturing: root.capturing == "@restore";
|
||||
label: "Restore all shortcut";
|
||||
clicked => { root.capture("@restore"); }
|
||||
cleared => { root.clear("@restore"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component MainWindow inherits Window {
|
||||
title: "HushKey";
|
||||
icon: root.app-icon;
|
||||
preferred-width: 460px;
|
||||
preferred-height: 660px;
|
||||
min-width: 400px;
|
||||
min-height: 480px;
|
||||
background: Theme.bg;
|
||||
default-font-size: 13px;
|
||||
|
||||
in property <bool> dark: true;
|
||||
in property <image> app-icon;
|
||||
in property <[AppRow]> apps;
|
||||
in property <bool> all-muted;
|
||||
in property <int> running-count;
|
||||
in property <string> mute-all-shortcut;
|
||||
in property <string> restore-shortcut;
|
||||
in property <string> capturing; // "" | "@all" | "@restore" | app key
|
||||
in property <string> status;
|
||||
in property <bool> status-is-error;
|
||||
in property <string> backend;
|
||||
in property <string> platform-note;
|
||||
in property <bool> show-volume: true;
|
||||
in property <string> config-path;
|
||||
in property <string> version;
|
||||
in property <string> hotkey-hint;
|
||||
in property <bool> launch-on-startup;
|
||||
in property <bool> start-minimized;
|
||||
in property <bool> show-toast: true;
|
||||
in-out property <int> page;
|
||||
|
||||
callback start-capture(string);
|
||||
callback key-captured(string, bool, bool, bool, bool);
|
||||
callback cancel-capture();
|
||||
callback clear-shortcut(string);
|
||||
callback toggle-app(string);
|
||||
callback toggle-all();
|
||||
callback set-launch-on-startup(bool);
|
||||
callback set-start-minimized(bool);
|
||||
callback set-show-toast(bool);
|
||||
callback set-dark(bool);
|
||||
callback open-config-dir();
|
||||
callback refresh();
|
||||
callback dismiss-status();
|
||||
|
||||
init => {
|
||||
Theme.dark = root.dark;
|
||||
Palette.color-scheme = root.dark ? ColorScheme.dark : ColorScheme.light;
|
||||
}
|
||||
changed dark => {
|
||||
Theme.dark = root.dark;
|
||||
Palette.color-scheme = root.dark ? ColorScheme.dark : ColorScheme.light;
|
||||
}
|
||||
|
||||
function begin-capture(target: string) {
|
||||
root.start-capture(target);
|
||||
key-sink.focus();
|
||||
}
|
||||
|
||||
// Receives the key combo while a shortcut chip is recording.
|
||||
key-sink := FocusScope {
|
||||
key-pressed(event) => {
|
||||
if (root.capturing != "") {
|
||||
root.key-captured(event.text, event.modifiers.control, event.modifiers.alt, event.modifiers.shift, event.modifiers.meta);
|
||||
return accept;
|
||||
}
|
||||
return reject;
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
// ── Header ──────────────────────────────────────────────
|
||||
HorizontalLayout {
|
||||
padding-left: 18px;
|
||||
padding-right: 14px;
|
||||
padding-top: 14px;
|
||||
padding-bottom: 10px;
|
||||
spacing: 10px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Image { source: root.app-icon; width: 26px; height: 26px; }
|
||||
}
|
||||
Text {
|
||||
text: "HushKey";
|
||||
font-size: 17px;
|
||||
font-weight: 750;
|
||||
color: Theme.text;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
Tabs {
|
||||
items: ["Apps", "Settings"];
|
||||
selected <=> root.page;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
IconButton {
|
||||
tooltip: root.dark ? "Switch to light mode" : "Switch to dark mode";
|
||||
clicked => { root.set-dark(!root.dark); }
|
||||
ThemeIcon { dark: root.dark; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Apps page ───────────────────────────────────────────
|
||||
if root.page == 0: VerticalLayout {
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
padding-top: 4px;
|
||||
spacing: 12px;
|
||||
vertical-stretch: 1;
|
||||
|
||||
MuteAllCard {
|
||||
all-muted: root.all-muted;
|
||||
app-count: root.running-count;
|
||||
shortcut: root.mute-all-shortcut;
|
||||
restore-shortcut: root.restore-shortcut;
|
||||
capturing: root.capturing;
|
||||
toggle => { root.toggle-all(); }
|
||||
capture(t) => { root.begin-capture(t); }
|
||||
clear(t) => { root.clear-shortcut(t); }
|
||||
}
|
||||
|
||||
if root.platform-note != "": Rectangle {
|
||||
border-radius: 10px;
|
||||
background: Theme.accent-soft;
|
||||
HorizontalLayout {
|
||||
padding: 10px;
|
||||
Text {
|
||||
text: root.platform-note;
|
||||
font-size: 12px;
|
||||
color: Theme.text;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
padding-top: 2px;
|
||||
SectionLabel { text: "APPLICATIONS"; vertical-alignment: center; }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
Text {
|
||||
text: root.capturing != "" ? root.hotkey-hint : (root.running-count + " with audio");
|
||||
font-size: 11.5px;
|
||||
color: root.capturing != "" ? Theme.accent : Theme.text-faint;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
|
||||
if root.apps.length == 0: Rectangle {
|
||||
vertical-stretch: 1;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 6px;
|
||||
SpeakerIcon { width: 30px; height: 30px; color: Theme.text-faint; }
|
||||
Text {
|
||||
text: "No apps with audio yet";
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: Theme.text-muted;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
Text {
|
||||
text: "Start playing something — it will show up here.";
|
||||
font-size: 12px;
|
||||
color: Theme.text-faint;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if root.apps.length > 0: ListView {
|
||||
vertical-stretch: 1;
|
||||
for row in root.apps: VerticalLayout {
|
||||
padding-bottom: 8px;
|
||||
padding-right: 12px; // keep clear of the overlay scrollbar
|
||||
AppRowView {
|
||||
app: row;
|
||||
capturing: root.capturing == row.key;
|
||||
show-volume: root.show-volume;
|
||||
toggle => { root.toggle-app(row.key); }
|
||||
capture => { root.begin-capture(row.key); }
|
||||
clear => { root.clear-shortcut(row.key); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Settings page ───────────────────────────────────────
|
||||
if root.page == 1: ScrollView {
|
||||
vertical-stretch: 1;
|
||||
VerticalLayout {
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
padding-top: 4px;
|
||||
padding-bottom: 16px;
|
||||
spacing: 10px;
|
||||
alignment: start;
|
||||
|
||||
SectionLabel { text: "GENERAL"; }
|
||||
Card {
|
||||
VerticalLayout {
|
||||
SettingRow {
|
||||
title: "Launch at login";
|
||||
subtitle: "Start HushKey in the tray when you sign in.";
|
||||
Switch {
|
||||
label: "Launch at login";
|
||||
checked: root.launch-on-startup;
|
||||
toggled(v) => { root.set-launch-on-startup(v); }
|
||||
}
|
||||
}
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
SettingRow {
|
||||
title: "Start minimized";
|
||||
subtitle: "Open straight to the tray instead of showing this window.";
|
||||
Switch {
|
||||
label: "Start minimized";
|
||||
checked: root.start-minimized;
|
||||
toggled(v) => { root.set-start-minimized(v); }
|
||||
}
|
||||
}
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
SettingRow {
|
||||
title: "On-screen confirmation";
|
||||
subtitle: "Show a small popup when a shortcut mutes or unmutes something.";
|
||||
Switch {
|
||||
label: "On-screen confirmation";
|
||||
checked: root.show-toast;
|
||||
toggled(v) => { root.set-show-toast(v); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SectionLabel { text: "APPEARANCE"; }
|
||||
Card {
|
||||
SettingRow {
|
||||
title: "Theme";
|
||||
Tabs {
|
||||
items: ["Dark", "Light"];
|
||||
selected: root.dark ? 0 : 1;
|
||||
changed selected => { root.set-dark(self.selected == 0); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
SectionLabel { text: "ABOUT"; }
|
||||
Card {
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 6px;
|
||||
Text {
|
||||
text: "HushKey " + root.version;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
color: Theme.text;
|
||||
}
|
||||
Text {
|
||||
text: "Audio backend: " + root.backend;
|
||||
font-size: 12px;
|
||||
color: Theme.text-muted;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
Text {
|
||||
text: "Settings file: " + root.config-path;
|
||||
font-size: 12px;
|
||||
color: Theme.text-muted;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: start;
|
||||
padding-top: 4px;
|
||||
Rectangle {
|
||||
height: 30px;
|
||||
border-radius: 8px;
|
||||
background: open.has-hover ? Theme.surface-hover : Theme.surface-sunken;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border;
|
||||
accessible-role: button;
|
||||
accessible-label: "Open settings folder";
|
||||
accessible-action-default => { root.open-config-dir(); }
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
Text { text: "Open settings folder"; font-size: 12px; font-weight: 600; color: Theme.text; vertical-alignment: center; }
|
||||
}
|
||||
open := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => { root.open-config-dir(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: "MIT License · Built with Slint (slint.dev) · Created using Claude Opus 5.5";
|
||||
font-size: 11px;
|
||||
color: Theme.text-faint;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Status banner ───────────────────────────────────────
|
||||
if root.status != "": HorizontalLayout {
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
padding-bottom: 12px;
|
||||
Rectangle {
|
||||
border-radius: 10px;
|
||||
background: root.status-is-error ? Theme.danger-soft : Theme.accent-soft;
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 6px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: root.status;
|
||||
font-size: 12px;
|
||||
color: Theme.text;
|
||||
wrap: word-wrap;
|
||||
vertical-alignment: center;
|
||||
horizontal-stretch: 1;
|
||||
}
|
||||
IconButton {
|
||||
width: 26px;
|
||||
height: 26px;
|
||||
tooltip: "Dismiss";
|
||||
clicked => { root.dismiss-status(); }
|
||||
Path {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
viewbox-width: 10;
|
||||
viewbox-height: 10;
|
||||
commands: "M1 1l8 8 M9 1l-8 8";
|
||||
stroke: Theme.text-muted;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Design tokens. Dark is the default; `Theme.dark` is driven from Rust via MainWindow.dark.
|
||||
|
||||
export global Theme {
|
||||
in-out property <bool> dark: true;
|
||||
|
||||
out property <color> bg: dark ? #0d0f13 : #f3f4f7;
|
||||
out property <color> surface: dark ? #161920 : #ffffff;
|
||||
out property <color> surface-hover: dark ? #1c2029 : #f7f8fa;
|
||||
out property <color> surface-sunken: dark ? #11141a : #eceef2;
|
||||
out property <color> border: dark ? #232833 : #e2e5eb;
|
||||
out property <color> border-strong: dark ? #323949 : #cfd4dc;
|
||||
out property <color> text: dark ? #e9ebf0 : #12141a;
|
||||
out property <color> text-muted: dark ? #8b92a1 : #687080;
|
||||
out property <color> text-faint: dark ? #5d6473 : #9aa1ae;
|
||||
|
||||
out property <color> accent: #7b6bff;
|
||||
out property <color> accent-strong: #5b49f2;
|
||||
out property <color> accent-soft: dark ? #7b6bff24 : #7b6bff1a;
|
||||
out property <color> danger: #ff5a6a;
|
||||
out property <color> danger-soft: dark ? #ff5a6a26 : #ff5a6a1c;
|
||||
out property <color> success: #34c98a;
|
||||
|
||||
out property <length> radius: 14px;
|
||||
out property <length> radius-sm: 9px;
|
||||
out property <duration> fast: 140ms;
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
// On-screen confirmation shown when a shortcut fires. Created as a non-activating,
|
||||
// click-through, always-on-top window (see src/ui/toast.rs) so it never steals focus
|
||||
// from a game or fullscreen app.
|
||||
|
||||
import { Theme } from "theme.slint";
|
||||
import { SpeakerIcon } from "widgets.slint";
|
||||
|
||||
export component Toast inherits Window {
|
||||
title: "HushKey notification";
|
||||
no-frame: true;
|
||||
always-on-top: true;
|
||||
background: transparent;
|
||||
width: 300px;
|
||||
height: 76px;
|
||||
|
||||
in property <bool> dark: true;
|
||||
in property <string> headline;
|
||||
in property <string> detail;
|
||||
in property <bool> muted;
|
||||
in property <bool> error;
|
||||
in-out property <bool> shown;
|
||||
|
||||
init => { Theme.dark = root.dark; }
|
||||
changed dark => { Theme.dark = root.dark; }
|
||||
|
||||
panel := Rectangle {
|
||||
x: 10px;
|
||||
y: root.shown ? 8px : 14px;
|
||||
width: parent.width - 20px;
|
||||
height: parent.height - 20px;
|
||||
border-radius: 16px;
|
||||
background: Theme.dark ? #1a1d25f5 : #fffffff7;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border;
|
||||
drop-shadow-blur: 10px;
|
||||
drop-shadow-color: #00000059;
|
||||
drop-shadow-offset-y: 3px;
|
||||
opacity: root.shown ? 1 : 0;
|
||||
animate opacity { duration: 170ms; easing: ease-out; }
|
||||
animate y { duration: 220ms; easing: ease-out; }
|
||||
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 16px;
|
||||
spacing: 12px;
|
||||
alignment: start;
|
||||
Rectangle {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
border-radius: 18px;
|
||||
background: root.error ? Theme.surface-sunken : (root.muted ? Theme.danger-soft : #34c98a2e);
|
||||
SpeakerIcon {
|
||||
muted: root.muted || root.error;
|
||||
color: root.error ? Theme.text-muted : (root.muted ? Theme.danger : Theme.success);
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 1px;
|
||||
Text {
|
||||
text: root.headline;
|
||||
font-size: 14px;
|
||||
font-weight: 650;
|
||||
color: Theme.text;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: root.detail;
|
||||
font-size: 12px;
|
||||
color: Theme.text-muted;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
// Small reusable building blocks. Everything is drawn with Slint primitives
|
||||
// (no icon fonts, no images) so it renders identically on every OS.
|
||||
|
||||
import { Theme } from "theme.slint";
|
||||
|
||||
export component SpeakerIcon inherits Path {
|
||||
in property <bool> muted;
|
||||
in property <color> color: Theme.text;
|
||||
viewbox-width: 24;
|
||||
viewbox-height: 24;
|
||||
width: 18px;
|
||||
height: 18px;
|
||||
stroke: color;
|
||||
stroke-width: 1.9px;
|
||||
fill: transparent;
|
||||
commands: muted
|
||||
? "M4 9.5h3.5L12 5.5v13l-4.5-4H4z M15.5 9.5l5 5 M20.5 9.5l-5 5"
|
||||
: "M4 9.5h3.5L12 5.5v13l-4.5-4H4z M15.5 9a4 4 0 0 1 0 6 M18.2 6.5a7.6 7.6 0 0 1 0 11";
|
||||
}
|
||||
|
||||
export component ThemeIcon inherits Path {
|
||||
in property <bool> dark;
|
||||
viewbox-width: 24;
|
||||
viewbox-height: 24;
|
||||
width: 17px;
|
||||
height: 17px;
|
||||
stroke: Theme.text-muted;
|
||||
stroke-width: 1.8px;
|
||||
fill: transparent;
|
||||
// Moon in dark mode (click → light), sun in light mode.
|
||||
commands: dark
|
||||
? "M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z"
|
||||
: "M16 12a4 4 0 1 1-8 0a4 4 0 1 1 8 0z M12 2.5v2 M12 19.5v2 M2.5 12h2 M19.5 12h2 M5.3 5.3l1.4 1.4 M17.3 17.3l1.4 1.4 M5.3 18.7l1.4-1.4 M17.3 6.7l1.4-1.4";
|
||||
}
|
||||
|
||||
export component IconButton inherits Rectangle {
|
||||
callback clicked;
|
||||
in property <string> tooltip;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 9px;
|
||||
background: touch.has-hover ? Theme.surface-hover : transparent;
|
||||
animate background { duration: Theme.fast; }
|
||||
accessible-role: button;
|
||||
accessible-label: tooltip;
|
||||
accessible-action-default => { root.clicked(); }
|
||||
touch := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => { root.clicked(); }
|
||||
}
|
||||
@children
|
||||
}
|
||||
|
||||
export component Tabs inherits Rectangle {
|
||||
in property <[string]> items;
|
||||
in-out property <int> selected;
|
||||
height: 32px;
|
||||
border-radius: 10px;
|
||||
background: Theme.surface-sunken;
|
||||
HorizontalLayout {
|
||||
padding: 3px;
|
||||
spacing: 2px;
|
||||
for item[i] in root.items: Rectangle {
|
||||
border-radius: 7px;
|
||||
background: i == root.selected ? Theme.surface : transparent;
|
||||
drop-shadow-blur: i == root.selected ? 4px : 0;
|
||||
drop-shadow-color: #0000001f;
|
||||
animate background { duration: Theme.fast; }
|
||||
accessible-role: tab;
|
||||
accessible-label: item;
|
||||
accessible-action-default => { root.selected = i; }
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
Text {
|
||||
text: item;
|
||||
font-size: 12.5px;
|
||||
font-weight: i == root.selected ? 600 : 500;
|
||||
color: i == root.selected ? Theme.text : Theme.text-muted;
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: center;
|
||||
}
|
||||
}
|
||||
TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => { root.selected = i; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component Switch inherits Rectangle {
|
||||
in-out property <bool> checked;
|
||||
in property <string> label;
|
||||
callback toggled(bool);
|
||||
width: 40px;
|
||||
height: 23px;
|
||||
border-radius: self.height / 2;
|
||||
background: checked ? Theme.accent : Theme.border-strong;
|
||||
animate background { duration: Theme.fast; }
|
||||
accessible-role: switch;
|
||||
accessible-checkable: true;
|
||||
accessible-checked: checked;
|
||||
accessible-label: label;
|
||||
accessible-action-default => { touch.clicked(); }
|
||||
knob := Rectangle {
|
||||
width: parent.height - 6px;
|
||||
height: self.width;
|
||||
y: 3px;
|
||||
x: root.checked ? parent.width - self.width - 3px : 3px;
|
||||
border-radius: self.width / 2;
|
||||
background: white;
|
||||
drop-shadow-blur: 3px;
|
||||
drop-shadow-color: #00000040;
|
||||
animate x { duration: 160ms; easing: ease-out; }
|
||||
}
|
||||
touch := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => {
|
||||
root.checked = !root.checked;
|
||||
root.toggled(root.checked);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Click → "Press keys…" → shows the captured combo. × clears it.
|
||||
export component ShortcutChip inherits Rectangle {
|
||||
in property <string> shortcut;
|
||||
in property <bool> capturing;
|
||||
in property <bool> on-accent; // white-on-gradient styling for the Mute All card
|
||||
in property <bool> enabled: true;
|
||||
in property <string> placeholder: "Set shortcut";
|
||||
in property <string> label; // accessibility label, e.g. "Spotify shortcut"
|
||||
callback clicked;
|
||||
callback cleared;
|
||||
|
||||
property <bool> blink;
|
||||
property <bool> bound: shortcut != "";
|
||||
|
||||
height: 30px;
|
||||
min-width: 104px;
|
||||
border-radius: 8px;
|
||||
border-width: 1px;
|
||||
border-color: capturing
|
||||
? (on-accent ? white : Theme.accent)
|
||||
: on-accent ? #ffffff59 : (bound ? Theme.border-strong : Theme.border);
|
||||
background: on-accent
|
||||
? (capturing ? #ffffff38 : (touch.has-hover ? #ffffff2e : #ffffff1f))
|
||||
: capturing ? Theme.accent-soft : (bound ? Theme.surface-sunken : (touch.has-hover ? Theme.surface-hover : transparent));
|
||||
opacity: enabled ? 1 : 0.5;
|
||||
animate background, border-color { duration: Theme.fast; }
|
||||
|
||||
accessible-role: button;
|
||||
accessible-label: label + ": " + (capturing ? "press a key combination" : (bound ? shortcut : "not set"));
|
||||
accessible-action-default => { root.clicked(); }
|
||||
|
||||
Timer {
|
||||
interval: 450ms;
|
||||
running: root.capturing;
|
||||
triggered => { root.blink = !root.blink; }
|
||||
}
|
||||
|
||||
touch := TouchArea {
|
||||
enabled: root.enabled;
|
||||
mouse-cursor: pointer;
|
||||
clicked => { root.clicked(); }
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
padding-left: 10px;
|
||||
padding-right: root.bound && !root.capturing ? 4px : 10px;
|
||||
spacing: 6px;
|
||||
if root.capturing: Rectangle {
|
||||
width: 7px;
|
||||
height: 7px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
border-radius: 3.5px;
|
||||
background: root.on-accent ? white : Theme.accent;
|
||||
opacity: root.blink ? 0.25 : 1;
|
||||
animate opacity { duration: 200ms; }
|
||||
}
|
||||
Text {
|
||||
text: root.capturing ? "Press keys…" : (root.bound ? root.shortcut : root.placeholder);
|
||||
font-size: 12px;
|
||||
font-weight: root.bound && !root.capturing ? 600 : 500;
|
||||
color: root.on-accent ? white : (root.capturing ? Theme.accent : (root.bound ? Theme.text : Theme.text-muted));
|
||||
vertical-alignment: center;
|
||||
horizontal-alignment: center;
|
||||
horizontal-stretch: 1;
|
||||
overflow: elide;
|
||||
}
|
||||
if root.bound && !root.capturing: Rectangle {
|
||||
width: 22px;
|
||||
height: 22px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
border-radius: 6px;
|
||||
background: clear.has-hover ? (root.on-accent ? #ffffff33 : Theme.border) : transparent;
|
||||
accessible-role: button;
|
||||
accessible-label: "Clear shortcut";
|
||||
accessible-action-default => { root.cleared(); }
|
||||
Path {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
viewbox-width: 10;
|
||||
viewbox-height: 10;
|
||||
commands: "M1 1l8 8 M9 1l-8 8";
|
||||
stroke: root.on-accent ? white : Theme.text-muted;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
clear := TouchArea {
|
||||
mouse-cursor: pointer;
|
||||
clicked => { root.cleared(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component SettingRow inherits Rectangle {
|
||||
in property <string> title;
|
||||
in property <string> subtitle;
|
||||
min-height: 58px;
|
||||
HorizontalLayout {
|
||||
padding-left: 16px;
|
||||
padding-right: 16px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
spacing: 12px;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 2px;
|
||||
horizontal-stretch: 1;
|
||||
Text { text: root.title; font-size: 13.5px; font-weight: 600; color: Theme.text; }
|
||||
if root.subtitle != "": Text {
|
||||
text: root.subtitle;
|
||||
font-size: 12px;
|
||||
color: Theme.text-muted;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
@children
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component Card inherits Rectangle {
|
||||
background: Theme.surface;
|
||||
border-radius: Theme.radius;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border;
|
||||
@children
|
||||
}
|
||||
|
||||
export component SectionLabel inherits Text {
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0.8px;
|
||||
color: Theme.text-faint;
|
||||
}
|
||||
Reference in new issue
Block a user