M5 (part 2): Slint desktop UI (tsc-desktop)
- tsc-model: tree_rows/order_siblings (flattened channel tree in TeamSpeak's sibling order, collapsible). - tsc-ui: Slint (fluent-dark) window with server list and bookmark editor, channel tree (talking, muted, away, streaming, password markers; click opens channel chat, double-click joins), chat tabs with unread counts, connect/observe/mute/push-to-talk toolbar, narrow single-pane layout for small screens, About page with the Slint attribution. Engine events are marshalled to the UI thread; secrets go to the OS keyring (memory fallback). - Dev switches TSC_DATA_DIR, TSC_AUTOCONNECT and TSC_SCREENSHOT; the README screenshots were taken under Xvfb against the dev servers. - Workspace lint unsafe_code: deny (Slint's generated code needs a local allow). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NJvYyRmTjKcb9i8eyYXK5G
This commit is contained in:
1 parent
e4a9860727
commit
fe219dbf7b
13 files changed
+5148
-68
No files matched your search
@@ -0,0 +1,529 @@
|
||||
import { Button, LineEdit, ListView, ComboBox, AboutSlint, VerticalBox, HorizontalBox, ScrollView } from "std-widgets.slint";
|
||||
|
||||
export struct ServerItem {
|
||||
id: int,
|
||||
name: string,
|
||||
address: string,
|
||||
// "offline", "connecting", "observing" or "connected"
|
||||
status: string,
|
||||
}
|
||||
|
||||
export struct TreeItem {
|
||||
is-channel: bool,
|
||||
depth: int,
|
||||
id: int,
|
||||
name: string,
|
||||
own: bool,
|
||||
talking: bool,
|
||||
muted: bool,
|
||||
sound-off: bool,
|
||||
away: bool,
|
||||
streaming: bool,
|
||||
locked: bool,
|
||||
collapsed: bool,
|
||||
}
|
||||
|
||||
export struct ChatTab {
|
||||
title: string,
|
||||
// 0 = server chat, 1 = channel chat
|
||||
kind: int,
|
||||
id: int,
|
||||
unread: int,
|
||||
}
|
||||
|
||||
export struct ChatLine {
|
||||
author: string,
|
||||
text: string,
|
||||
time: string,
|
||||
relayed: bool,
|
||||
}
|
||||
|
||||
export struct BookmarkForm {
|
||||
id: int,
|
||||
name: string,
|
||||
address: string,
|
||||
nickname: string,
|
||||
server-password: string,
|
||||
gateway-url: string,
|
||||
query-transport: string,
|
||||
query-addr: string,
|
||||
query-user: string,
|
||||
query-password: string,
|
||||
}
|
||||
|
||||
export global Bridge {
|
||||
in property <[ServerItem]> servers;
|
||||
in-out property <int> current-server: -1;
|
||||
in property <[TreeItem]> tree;
|
||||
in property <[ChatTab]> tabs;
|
||||
in-out property <int> current-tab: 0;
|
||||
in property <[ChatLine]> messages;
|
||||
in property <string> status-text;
|
||||
in property <string> server-title: "No server selected";
|
||||
in property <bool> voice-connected;
|
||||
in property <bool> voice-connecting;
|
||||
in property <bool> observing;
|
||||
in property <bool> can-observe;
|
||||
in property <bool> input-muted;
|
||||
in property <bool> output-muted;
|
||||
in property <bool> transmitting;
|
||||
in property <string> presence-source;
|
||||
|
||||
callback select-server(int);
|
||||
callback connect-voice();
|
||||
callback disconnect-voice();
|
||||
callback toggle-observe();
|
||||
callback join-channel(int);
|
||||
callback open-channel-chat(int);
|
||||
callback toggle-collapse(int);
|
||||
callback select-tab(int);
|
||||
callback close-tab(int);
|
||||
callback send-message(string);
|
||||
callback set-input-muted(bool);
|
||||
callback set-output-muted(bool);
|
||||
callback push-to-talk(bool);
|
||||
callback edit-bookmark(int) -> BookmarkForm;
|
||||
callback save-bookmark(BookmarkForm);
|
||||
callback delete-bookmark(int);
|
||||
}
|
||||
|
||||
component StatusDot inherits Rectangle {
|
||||
in property <string> status;
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
border-radius: 5px;
|
||||
background: status == "connected" ? #3fb950 : status == "observing" ? #58a6ff : status == "connecting" ? #d29922 : #6e7681;
|
||||
}
|
||||
|
||||
component Field inherits HorizontalLayout {
|
||||
in property <string> label;
|
||||
in-out property <string> value;
|
||||
in property <string> placeholder;
|
||||
in property <InputType> input-type: InputType.text;
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: label;
|
||||
width: 130px;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
LineEdit {
|
||||
text <=> value;
|
||||
placeholder-text: placeholder;
|
||||
input-type: input-type;
|
||||
}
|
||||
}
|
||||
|
||||
component BookmarkEditor inherits Rectangle {
|
||||
in-out property <BookmarkForm> form;
|
||||
callback done();
|
||||
background: #000000a0;
|
||||
TouchArea { }
|
||||
Rectangle {
|
||||
width: min(parent.width - 32px, 520px);
|
||||
height: min(parent.height - 32px, 520px);
|
||||
background: #1f2328;
|
||||
border-radius: 8px;
|
||||
VerticalBox {
|
||||
Text {
|
||||
text: form.id < 0 ? "Add server" : "Edit server";
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
}
|
||||
ScrollView {
|
||||
VerticalLayout {
|
||||
spacing: 6px;
|
||||
Field { label: "Name"; value <=> form.name; placeholder: "My server"; }
|
||||
Field { label: "Address"; value <=> form.address; placeholder: "ts.example.org:9987"; }
|
||||
Field { label: "Nickname"; value <=> form.nickname; }
|
||||
Field { label: "Server password"; value <=> form.server-password; input-type: InputType.password; }
|
||||
Text {
|
||||
text: "Invisible presence and chat without joining (optional)";
|
||||
font-weight: 600;
|
||||
}
|
||||
Field { label: "Gateway URL"; value <=> form.gateway-url; placeholder: "wss://gw.example.org/v1"; }
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: "Query transport";
|
||||
width: 130px;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
ComboBox {
|
||||
model: ["none", "ssh", "raw", "http"];
|
||||
current-value <=> form.query-transport;
|
||||
}
|
||||
}
|
||||
Field { label: "Query address"; value <=> form.query-addr; placeholder: "ts.example.org:10022"; }
|
||||
Field { label: "Query login"; value <=> form.query-user; }
|
||||
Field { label: "Query password"; value <=> form.query-password; input-type: InputType.password; }
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
alignment: end;
|
||||
spacing: 8px;
|
||||
if form.id >= 0: Button {
|
||||
text: "Delete";
|
||||
clicked => {
|
||||
Bridge.delete-bookmark(form.id);
|
||||
done();
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: "Cancel";
|
||||
clicked => { done(); }
|
||||
}
|
||||
Button {
|
||||
text: "Save";
|
||||
primary: true;
|
||||
enabled: form.address != "" && form.nickname != "";
|
||||
clicked => {
|
||||
Bridge.save-bookmark(form);
|
||||
done();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component ServerList inherits Rectangle {
|
||||
callback add();
|
||||
callback edit(int);
|
||||
background: #161b22;
|
||||
VerticalBox {
|
||||
HorizontalLayout {
|
||||
Text {
|
||||
text: "Servers";
|
||||
font-weight: 700;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
Button {
|
||||
text: "+";
|
||||
width: 32px;
|
||||
clicked => { add(); }
|
||||
}
|
||||
}
|
||||
ListView {
|
||||
for server[i] in Bridge.servers: Rectangle {
|
||||
height: 48px;
|
||||
border-radius: 6px;
|
||||
background: Bridge.current-server == server.id ? #30363d : area.has-hover ? #21262d : transparent;
|
||||
area := TouchArea {
|
||||
clicked => { Bridge.select-server(server.id); }
|
||||
double-clicked => { edit(server.id); }
|
||||
}
|
||||
HorizontalLayout {
|
||||
padding: 6px;
|
||||
spacing: 8px;
|
||||
StatusDot {
|
||||
status: server.status;
|
||||
y: (parent.height - self.height) / 2;
|
||||
}
|
||||
VerticalLayout {
|
||||
Text {
|
||||
text: server.name;
|
||||
font-weight: 600;
|
||||
overflow: elide;
|
||||
}
|
||||
Text {
|
||||
text: server.address;
|
||||
font-size: 11px;
|
||||
color: #8b949e;
|
||||
overflow: elide;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component ChannelTree inherits Rectangle {
|
||||
background: #0d1117;
|
||||
ListView {
|
||||
for row in Bridge.tree: Rectangle {
|
||||
height: 26px;
|
||||
background: row-area.has-hover ? #161b22 : transparent;
|
||||
row-area := TouchArea {
|
||||
double-clicked => {
|
||||
if (row.is-channel) {
|
||||
Bridge.join-channel(row.id);
|
||||
}
|
||||
}
|
||||
clicked => {
|
||||
if (row.is-channel) {
|
||||
Bridge.open-channel-chat(row.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
padding-left: 8px + row.depth * 18px;
|
||||
padding-right: 8px;
|
||||
spacing: 6px;
|
||||
if row.is-channel: Text {
|
||||
text: row.collapsed ? "▸" : "▾";
|
||||
vertical-alignment: center;
|
||||
TouchArea {
|
||||
clicked => { Bridge.toggle-collapse(row.id); }
|
||||
}
|
||||
}
|
||||
if !row.is-channel: Rectangle {
|
||||
width: 10px;
|
||||
height: 10px;
|
||||
y: (parent.height - self.height) / 2;
|
||||
border-radius: 5px;
|
||||
background: row.talking ? #3fb950 : #30363d;
|
||||
}
|
||||
Text {
|
||||
text: (row.is-channel ? "# " : "") + row.name;
|
||||
horizontal-stretch: 1;
|
||||
horizontal-alignment: left;
|
||||
vertical-alignment: center;
|
||||
font-weight: row.is-channel || row.own ? 600 : 400;
|
||||
color: row.away ? #8b949e : row.own ? #58a6ff : #e6edf3;
|
||||
overflow: elide;
|
||||
}
|
||||
if row.locked: Text { text: "password"; font-size: 10px; color: #d29922; vertical-alignment: center; }
|
||||
if row.muted: Text { text: "mic off"; font-size: 10px; color: #f85149; vertical-alignment: center; }
|
||||
if row.sound-off: Text { text: "sound off"; font-size: 10px; color: #f85149; vertical-alignment: center; }
|
||||
if row.streaming: Text { text: "LIVE"; font-size: 10px; color: #a371f7; vertical-alignment: center; }
|
||||
if row.away: Text { text: "away"; font-size: 10px; color: #8b949e; vertical-alignment: center; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component ChatPanel inherits Rectangle {
|
||||
background: #0d1117;
|
||||
VerticalLayout {
|
||||
HorizontalLayout {
|
||||
height: 34px;
|
||||
spacing: 2px;
|
||||
for tab[i] in Bridge.tabs: Rectangle {
|
||||
width: tab-text.preferred-width + 28px;
|
||||
background: Bridge.current-tab == i ? #30363d : tab-area.has-hover ? #21262d : #161b22;
|
||||
tab-area := TouchArea {
|
||||
clicked => { Bridge.select-tab(i); }
|
||||
}
|
||||
HorizontalLayout {
|
||||
padding-left: 10px;
|
||||
padding-right: 6px;
|
||||
spacing: 4px;
|
||||
tab-text := Text {
|
||||
text: tab.title + (tab.unread > 0 ? " (" + tab.unread + ")" : "");
|
||||
vertical-alignment: center;
|
||||
font-weight: tab.unread > 0 ? 700 : 400;
|
||||
}
|
||||
if tab.kind == 1: Text {
|
||||
text: "×";
|
||||
vertical-alignment: center;
|
||||
TouchArea {
|
||||
clicked => { Bridge.close-tab(i); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { }
|
||||
}
|
||||
ListView {
|
||||
for line in Bridge.messages: VerticalLayout {
|
||||
padding: 6px;
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: line.author;
|
||||
font-weight: 700;
|
||||
color: line.relayed ? #58a6ff : #e6edf3;
|
||||
}
|
||||
Text {
|
||||
text: line.time + (line.relayed ? " via relay" : "");
|
||||
font-size: 11px;
|
||||
color: #8b949e;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: line.text;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
padding: 6px;
|
||||
spacing: 6px;
|
||||
input := LineEdit {
|
||||
placeholder-text: "Message";
|
||||
accepted(text) => {
|
||||
if (text != "") {
|
||||
Bridge.send-message(text);
|
||||
self.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: "Send";
|
||||
clicked => {
|
||||
if (input.text != "") {
|
||||
Bridge.send-message(input.text);
|
||||
input.text = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component MainWindow inherits Window {
|
||||
title: "TS Client";
|
||||
preferred-width: 1200px;
|
||||
preferred-height: 760px;
|
||||
min-width: 360px;
|
||||
min-height: 480px;
|
||||
background: #0d1117;
|
||||
default-font-size: 13px;
|
||||
|
||||
property <bool> editing: false;
|
||||
property <bool> show-about: false;
|
||||
property <BookmarkForm> form;
|
||||
// Phones and narrow windows show one pane at a time.
|
||||
property <bool> narrow: self.width < 800px;
|
||||
property <int> pane: 1;
|
||||
|
||||
VerticalLayout {
|
||||
// Toolbar
|
||||
Rectangle {
|
||||
height: 48px;
|
||||
background: #161b22;
|
||||
HorizontalLayout {
|
||||
padding: 6px;
|
||||
spacing: 6px;
|
||||
if narrow: Button {
|
||||
text: pane == 0 ? "Tree" : pane == 1 ? "Chat" : "Servers";
|
||||
clicked => { pane = mod(pane + 1, 3); }
|
||||
}
|
||||
Text {
|
||||
text: Bridge.server-title;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
vertical-alignment: center;
|
||||
overflow: elide;
|
||||
}
|
||||
Rectangle { }
|
||||
Button {
|
||||
text: Bridge.voice-connected ? "Disconnect" : Bridge.voice-connecting ? "Connecting…" : "Connect";
|
||||
enabled: Bridge.current-server >= 0 && !Bridge.voice-connecting;
|
||||
primary: !Bridge.voice-connected;
|
||||
clicked => {
|
||||
if (Bridge.voice-connected) {
|
||||
Bridge.disconnect-voice();
|
||||
} else {
|
||||
Bridge.connect-voice();
|
||||
}
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: Bridge.observing ? "Stop observing" : "Observe (invisible)";
|
||||
enabled: Bridge.can-observe;
|
||||
clicked => { Bridge.toggle-observe(); }
|
||||
}
|
||||
Button {
|
||||
text: Bridge.input-muted ? "Mic: off" : "Mic: on";
|
||||
enabled: Bridge.voice-connected;
|
||||
clicked => { Bridge.set-input-muted(!Bridge.input-muted); }
|
||||
}
|
||||
Button {
|
||||
text: Bridge.output-muted ? "Sound: off" : "Sound: on";
|
||||
enabled: Bridge.voice-connected;
|
||||
clicked => { Bridge.set-output-muted(!Bridge.output-muted); }
|
||||
}
|
||||
ptt := Rectangle {
|
||||
width: 110px;
|
||||
border-radius: 4px;
|
||||
background: Bridge.transmitting ? #238636 : ptt-area.has-hover ? #30363d : #21262d;
|
||||
opacity: Bridge.voice-connected ? 1.0 : 0.4;
|
||||
Text {
|
||||
text: Bridge.transmitting ? "Talking…" : "Hold to talk";
|
||||
}
|
||||
ptt-area := TouchArea {
|
||||
enabled: Bridge.voice-connected;
|
||||
pointer-event(e) => {
|
||||
if (e.kind == PointerEventKind.down) {
|
||||
Bridge.push-to-talk(true);
|
||||
} else if (e.kind == PointerEventKind.up || e.kind == PointerEventKind.cancel) {
|
||||
Bridge.push-to-talk(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Button {
|
||||
text: "About";
|
||||
clicked => { show-about = true; }
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
if !narrow || pane == 2: ServerList {
|
||||
width: narrow ? parent.width : 230px;
|
||||
add => {
|
||||
form = Bridge.edit-bookmark(-1);
|
||||
editing = true;
|
||||
}
|
||||
edit(id) => {
|
||||
form = Bridge.edit-bookmark(id);
|
||||
editing = true;
|
||||
}
|
||||
}
|
||||
if !narrow || pane == 0: ChannelTree {
|
||||
width: narrow ? parent.width : 360px;
|
||||
}
|
||||
if !narrow || pane == 1: ChatPanel { }
|
||||
}
|
||||
// Status bar
|
||||
Rectangle {
|
||||
height: 26px;
|
||||
background: #161b22;
|
||||
HorizontalLayout {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
Text {
|
||||
text: Bridge.status-text;
|
||||
color: #8b949e;
|
||||
vertical-alignment: center;
|
||||
overflow: elide;
|
||||
}
|
||||
Rectangle { }
|
||||
Text {
|
||||
text: Bridge.presence-source;
|
||||
color: #58a6ff;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if editing: BookmarkEditor {
|
||||
form <=> form;
|
||||
done => { editing = false; }
|
||||
}
|
||||
|
||||
if show-about: Rectangle {
|
||||
background: #000000c0;
|
||||
TouchArea {
|
||||
clicked => { show-about = false; }
|
||||
}
|
||||
VerticalBox {
|
||||
alignment: center;
|
||||
Text {
|
||||
text: "Unofficial TeamSpeak 3/6 compatible client. Not affiliated with TeamSpeak Systems GmbH.";
|
||||
horizontal-alignment: center;
|
||||
wrap: word-wrap;
|
||||
}
|
||||
AboutSlint { }
|
||||
Text {
|
||||
text: "Third-party licenses: see THIRD_PARTY_NOTICES. Click to close.";
|
||||
horizontal-alignment: center;
|
||||
color: #8b949e;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user