feat(client): redesign native UI, themes, settings and avatars
Separate conversation drafts and voice view state, add native settings and restricted CSS themes, implement validated avatar cropping, and refresh dependencies with documented desktop compatibility backports.
This commit is contained in:
parent
44d284a568
commit
8e5ab56611
276 changed files with 53546 additions and 3399 deletions
1
src/ui/slint/assets/vnox-mark.svg
Normal file
1
src/ui/slint/assets/vnox-mark.svg
Normal file
|
|
@ -0,0 +1 @@
|
|||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 64 64" role="img" aria-label="Vnox"><rect width="64" height="64" rx="17" fill="#202022"/><g fill="none" stroke="#dac5a6" stroke-width="5" stroke-linejoin="round" stroke-linecap="round"><path d="M16 20 32 46 48 20"/><path d="M16 20H26M38 20H48"/></g></svg>
|
||||
|
After Width: | Height: | Size: 308 B |
121
src/ui/slint/avatar-cropper.slint
Normal file
121
src/ui/slint/avatar-cropper.slint
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
import { Theme, ActionButton } from "theme.slint";
|
||||
import { AudioSlider } from "controls.slint";
|
||||
|
||||
export component AvatarCropper inherits Rectangle {
|
||||
in property <image> avatar-source;
|
||||
in property <float> source-width: 1;
|
||||
in property <float> source-height: 1;
|
||||
in property <float> offset-x;
|
||||
in property <float> offset-y;
|
||||
in-out property <float> zoom: 1;
|
||||
in property <string> error;
|
||||
callback crop-moved(float, float);
|
||||
callback zoom-changed(float);
|
||||
callback confirm();
|
||||
callback cancel();
|
||||
private property <length> frame-size: Math.min(320px, Math.max(220px, root.height - 350px));
|
||||
private property <float> cover-scale: Math.max(root.frame-size / 1px / Math.max(root.source-width, 1), root.frame-size / 1px / Math.max(root.source-height, 1)) * root.zoom;
|
||||
background: Theme.overlay;
|
||||
TouchArea { }
|
||||
keyboard := FocusScope {
|
||||
init => { self.focus(); }
|
||||
key-pressed(event) => {
|
||||
if event.text == Key.Escape { root.cancel(); return accept; }
|
||||
if event.text == "+" || event.text == "=" { root.set-zoom(root.zoom + 0.1); return accept; }
|
||||
if event.text == "-" { root.set-zoom(root.zoom - 0.1); return accept; }
|
||||
return reject;
|
||||
}
|
||||
Rectangle {
|
||||
width: 440px;
|
||||
height: Math.min(620px, root.height - 24px);
|
||||
x: (root.width - self.width) / 2;
|
||||
y: (root.height - self.height) / 2;
|
||||
background: Theme.bg-surface;
|
||||
border-radius: 12px;
|
||||
border-width: 1px;
|
||||
border-color: Theme.border;
|
||||
VerticalLayout {
|
||||
padding: 18px; spacing: 8px; alignment: start;
|
||||
HorizontalLayout {
|
||||
Text { text: "Выбрать область фото"; color: Theme.text-primary; font-size: Theme.font-size + 5px; font-weight: 600; horizontal-stretch: 1; vertical-alignment: center; }
|
||||
ActionButton { text: "×"; width: 30px; quiet: true; clicked => { root.cancel(); } }
|
||||
}
|
||||
Text { text: "Перетащи фото и выбери масштаб."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); }
|
||||
Rectangle { height: 4px; }
|
||||
HorizontalLayout {
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
frame := Rectangle {
|
||||
width: root.frame-size; height: root.frame-size;
|
||||
clip: true; background: Theme.bg-surface;
|
||||
accessible-role: image;
|
||||
accessible-label: "Область фото. Перетаскивай изображение, чтобы изменить кадрирование.";
|
||||
Image {
|
||||
source: root.avatar-source;
|
||||
width: root.source-width * root.cover-scale * 1px;
|
||||
height: root.source-height * root.cover-scale * 1px;
|
||||
x: (frame.width - self.width) / 2 + root.offset-x * frame.width;
|
||||
y: (frame.height - self.height) / 2 + root.offset-y * frame.height;
|
||||
image-fit: fill;
|
||||
}
|
||||
// The mask makes the final circular avatar explicit, independently
|
||||
// of renderer support for rounded clipping of bitmap images.
|
||||
Path {
|
||||
width: parent.width; height: parent.height;
|
||||
viewbox-width: 320; viewbox-height: 320;
|
||||
fill: Theme.bg-surface;
|
||||
fill-rule: evenodd;
|
||||
commands: "M0 0H320V320H0Z M320 160 A160 160 0 1 0 0 160 A160 160 0 1 0 320 160Z";
|
||||
}
|
||||
Rectangle {
|
||||
width: parent.width; height: parent.height;
|
||||
border-radius: parent.width / 2;
|
||||
border-width: 1px; border-color: Theme.border;
|
||||
background: transparent;
|
||||
}
|
||||
drag := TouchArea {
|
||||
property <float> start-x;
|
||||
property <float> start-y;
|
||||
pointer-event(event) => {
|
||||
if event.button == PointerEventButton.left && event.kind == PointerEventKind.down {
|
||||
self.start-x = root.offset-x;
|
||||
self.start-y = root.offset-y;
|
||||
keyboard.focus();
|
||||
}
|
||||
}
|
||||
moved => {
|
||||
if self.pressed {
|
||||
root.crop-moved(self.start-x + (self.mouse-x - self.pressed-x) / frame.width,
|
||||
self.start-y + (self.mouse-y - self.pressed-y) / frame.height);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
Rectangle { height: 2px; }
|
||||
HorizontalLayout {
|
||||
spacing: 10px;
|
||||
ActionButton { text: "−"; width: 32px; clicked => { root.set-zoom(root.zoom - 0.1); } }
|
||||
AudioSlider { minimum: 1; maximum: 3; value <=> root.zoom; changed(value) => { root.zoom-changed(value); } }
|
||||
ActionButton { text: "+"; width: 32px; clicked => { root.set-zoom(root.zoom + 0.1); } }
|
||||
}
|
||||
HorizontalLayout {
|
||||
Text { text: "Масштаб " + Math.round(root.zoom * 100) + "%"; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 4px, 11px); vertical-alignment: center; horizontal-stretch: 1; }
|
||||
ActionButton { text: "Сбросить кадр"; quiet: true; clicked => { root.crop-moved(0,0); root.set-zoom(1); } }
|
||||
}
|
||||
if root.error != "" : Text { text: root.error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Отмена"; quiet: true; clicked => { root.cancel(); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: "Использовать фото"; active: true; clicked => { root.confirm(); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
function set-zoom(value: float) {
|
||||
root.zoom = Math.clamp(value, 1, 3);
|
||||
root.zoom-changed(root.zoom);
|
||||
}
|
||||
}
|
||||
21
src/ui/slint/avatar-view.slint
Normal file
21
src/ui/slint/avatar-view.slint
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import { Theme } from "theme.slint";
|
||||
|
||||
export component AvatarView inherits Rectangle {
|
||||
in property <image> source;
|
||||
in property <bool> has-source;
|
||||
in property <string> initials;
|
||||
in property <brush> mask: Theme.bg-base;
|
||||
width: 34px; height: 34px;
|
||||
border-radius: self.width / 2;
|
||||
background: Theme.avatar-bg;
|
||||
clip: true;
|
||||
if root.has-source : Image { source: root.source; width: parent.width; height: parent.height; image-fit: cover; }
|
||||
if !root.has-source : Text { text: root.initials; color: Theme.accent; font-size: Math.max(11px, Theme.font-size - 3px); horizontal-alignment: center; vertical-alignment: center; overflow: elide; }
|
||||
// Explicit mask also works on software renderers that only clip rectangular bounds.
|
||||
Path {
|
||||
width: parent.width; height: parent.height;
|
||||
viewbox-width: 320; viewbox-height: 320;
|
||||
commands: "M0 0H320V320H0Z M320 160 A160 160 0 1 0 0 160 A160 160 0 1 0 320 160Z";
|
||||
fill-rule: evenodd; fill: root.mask;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,81 +1,72 @@
|
|||
import { Theme } from "theme.slint";
|
||||
import { AvatarView } from "avatar-view.slint";
|
||||
import { Theme, ActionButton } from "theme.slint";
|
||||
|
||||
export struct MessageItem {
|
||||
message_id: string,
|
||||
sender_id: string,
|
||||
sender_name: string,
|
||||
content: string,
|
||||
timestamp: string,
|
||||
is_own: bool,
|
||||
edited: bool,
|
||||
reply_to: string,
|
||||
message_id: string, sender_id: string, sender_name: string,
|
||||
content: string, timestamp: string, is_own: bool, edited: bool, reply_to: string, avatar_text: string, show_author: bool,
|
||||
}
|
||||
|
||||
export struct DmConversationItem {
|
||||
dm_id: string,
|
||||
other_user_id: string,
|
||||
other_nickname: string,
|
||||
e2ee_enabled: bool,
|
||||
messages: [MessageItem],
|
||||
dm_id: string, other_user_id: string, other_nickname: string,
|
||||
e2ee_enabled: bool, messages: [MessageItem],
|
||||
}
|
||||
export struct MemberItem { user_id: string, nickname: string, status: string, avatar_text: string }
|
||||
|
||||
export struct MemberItem {
|
||||
user_id: string,
|
||||
nickname: string,
|
||||
status: string,
|
||||
}
|
||||
|
||||
component MessageActions {
|
||||
in-out property <bool> is-own;
|
||||
in-out property <string> msg-id;
|
||||
|
||||
component MessageRow inherits Rectangle {
|
||||
in property <MessageItem> message;
|
||||
in property <bool> actions-enabled: true;
|
||||
in property <image> own-avatar;
|
||||
in property <bool> has-own-avatar;
|
||||
callback react(string, string);
|
||||
callback reply-to-msg(string);
|
||||
callback edit-msg(string);
|
||||
callback delete-msg(string);
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
Rectangle {
|
||||
width: 24px; height: 24px; border-radius: 4px;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea { clicked => { react(msg-id, "👍"); } }
|
||||
Text { text: "👍"; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
min-height: row-content.min-height;
|
||||
preferred-height: row-content.preferred-height;
|
||||
vertical-stretch: 0;
|
||||
background: row-touch.has-hover || row-focus.has-focus ? Theme.bg-hover : transparent;
|
||||
row-touch := TouchArea { }
|
||||
row-focus := FocusScope { }
|
||||
row-content := HorizontalLayout {
|
||||
padding-left: 22px; padding-right: 22px;
|
||||
padding-top: root.message.show_author ? 9px : 2px; padding-bottom: root.message.show_author ? 9px : 2px; spacing: 13px;
|
||||
AvatarView {
|
||||
width: 34px; height: root.message.show_author ? 34px : 0px; visible: root.message.show_author;
|
||||
source: root.own-avatar; has-source: root.has-own-avatar && root.message.is_own;
|
||||
initials: root.message.avatar_text; mask: root.background;
|
||||
}
|
||||
Rectangle {
|
||||
width: 24px; height: 24px; border-radius: 4px;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea { clicked => { react(msg-id, "❤️"); } }
|
||||
Text { text: "❤️"; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
if root.message.reply_to != "" : Text {
|
||||
text: "↳ " + root.message.reply_to;
|
||||
color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); wrap: word-wrap;
|
||||
}
|
||||
if root.message.show_author : HorizontalLayout {
|
||||
spacing: 9px;
|
||||
Text { text: root.message.sender_name; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.875); font-weight: 600; overflow: elide; }
|
||||
Text { text: root.message.timestamp + (root.message.edited ? " · изменено" : ""); color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
Text { text: root.message.content; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); wrap: word-wrap; }
|
||||
}
|
||||
Rectangle {
|
||||
width: 24px; height: 24px; border-radius: 4px;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea { clicked => { react(msg-id, "😂"); } }
|
||||
Text { text: "😂"; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle {
|
||||
width: 24px; height: 24px; border-radius: 4px;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea { clicked => { reply-to-msg(msg-id); } }
|
||||
Text { text: "↩"; color: Theme.text-secondary; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
if is-own : Rectangle {
|
||||
width: 24px; height: 24px; border-radius: 4px;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea { clicked => { edit-msg(msg-id); } }
|
||||
Text { text: "✏"; color: Theme.text-secondary; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
if is-own : Rectangle {
|
||||
width: 24px; height: 24px; border-radius: 4px;
|
||||
background: Theme.danger;
|
||||
TouchArea { clicked => { delete-msg(msg-id); } }
|
||||
Text { text: "✕"; color: Theme.text-primary; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
if root.actions-enabled && (row-touch.has-hover || row-focus.has-focus) : Rectangle {
|
||||
x: parent.width - self.width - 16px; y: 0px;
|
||||
width: root.message.is_own ? 245px : 136px; height: 32px;
|
||||
background: Theme.bg-surface; border-radius: 6px;
|
||||
border-width: 1px; border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
spacing: 3px;
|
||||
ActionButton { text: "👍"; quiet: true; clicked => { root.react(root.message.message_id, "👍"); } }
|
||||
ActionButton { text: "Ответить"; quiet: true; clicked => { root.reply-to-msg(root.message.message_id); } }
|
||||
if root.message.is_own : ActionButton { text: "Править"; quiet: true; clicked => { root.edit-msg(root.message.message_id); } }
|
||||
if root.message.is_own : ActionButton { text: "Удалить"; danger: true; quiet: true; clicked => { root.delete-msg(root.message.message_id); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component ChatPanel {
|
||||
export component ChatPanel inherits Rectangle {
|
||||
in property <image> own-avatar;
|
||||
in property <bool> has-own-avatar;
|
||||
in-out property <string> active-channel-id;
|
||||
in-out property <string> active-channel-name;
|
||||
in-out property <[MessageItem]> messages;
|
||||
|
|
@ -87,7 +78,9 @@ export component ChatPanel {
|
|||
in-out property <string> replying-to-message;
|
||||
in-out property <string> replying-to-sender;
|
||||
in-out property <string> replying-to-content;
|
||||
|
||||
in-out property <bool> members-visible: true;
|
||||
callback input-edited(string);
|
||||
callback toggle-members();
|
||||
callback send-message(string, string);
|
||||
callback load-more(string);
|
||||
callback react(string, string);
|
||||
|
|
@ -95,141 +88,104 @@ export component ChatPanel {
|
|||
callback edit-msg(string);
|
||||
callback delete-msg(string);
|
||||
callback cancel-reply();
|
||||
|
||||
background: Theme.bg-base;
|
||||
VerticalLayout {
|
||||
padding: 0;
|
||||
spacing: 0;
|
||||
|
||||
Rectangle {
|
||||
height: 48px;
|
||||
background: Theme.bg-surface;
|
||||
height: 56px; border-width: 1px; border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
padding: 8px;
|
||||
spacing: 4px;
|
||||
Text {
|
||||
text: e2ee-enabled ? "🔒 " : "";
|
||||
color: Theme.accent;
|
||||
}
|
||||
Text {
|
||||
text: is-dm ? dm-partner-name : "#" + active-channel-name;
|
||||
color: Theme.text-primary;
|
||||
font-size: 16px;
|
||||
}
|
||||
padding-left: 22px; padding-right: 16px; spacing: 12px;
|
||||
Text { text: root.is-dm ? "@" : "#"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 1.4375); width: 20px; vertical-alignment: center; }
|
||||
Text { text: root.is-dm ? root.dm-partner-name : root.active-channel-name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; overflow: elide; vertical-alignment: center; }
|
||||
if root.e2ee-enabled : Text { text: "Сквозное шифрование"; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.6875); }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
if !root.is-dm : ActionButton { text: "Участники"; active: root.members-visible; clicked => { root.toggle-members(); } }
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
HorizontalLayout {
|
||||
spacing: 0;
|
||||
VerticalLayout {
|
||||
for msg in messages: Rectangle {
|
||||
height: 72px;
|
||||
spacing: 0; horizontal-stretch: 1;
|
||||
Flickable {
|
||||
content-width: self.width;
|
||||
VerticalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
padding-top: 6px;
|
||||
padding-bottom: 6px;
|
||||
spacing: 2px;
|
||||
if msg.reply_to != "" : Text {
|
||||
text: "↳ " + msg.reply_to;
|
||||
color: Theme.text-muted;
|
||||
font-size: 11px;
|
||||
spacing: 0;
|
||||
if root.messages.length == 0 : Text {
|
||||
text: root.is-dm ? "Сообщений пока нет. Напиши первым." : "В этом канале пока нет сообщений.";
|
||||
color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); wrap: word-wrap;
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: msg.sender_name;
|
||||
color: Theme.accent;
|
||||
font-weight: 700;
|
||||
font-size: 13px;
|
||||
}
|
||||
Text {
|
||||
text: msg.timestamp;
|
||||
color: Theme.text-muted;
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: msg.content;
|
||||
wrap: word-wrap;
|
||||
color: Theme.text-primary;
|
||||
font-size: 14px;
|
||||
}
|
||||
HorizontalLayout {
|
||||
height: 22px;
|
||||
MessageActions {
|
||||
is-own: msg.is_own;
|
||||
msg-id: msg.message_id;
|
||||
react(id, emoji) => { root.react(id, emoji); }
|
||||
reply-to-msg(id) => { root.reply-to-msg(id); }
|
||||
edit-msg(id) => { root.edit-msg(id); }
|
||||
delete-msg(id) => { root.delete-msg(id); }
|
||||
for msg in root.messages: MessageRow {
|
||||
message: msg;
|
||||
own-avatar: root.own-avatar;
|
||||
has-own-avatar: root.has-own-avatar;
|
||||
actions-enabled: !root.is-dm;
|
||||
react(id, emoji) => { root.react(id, emoji); }
|
||||
reply-to-msg(id) => { root.reply-to-msg(id); }
|
||||
edit-msg(id) => { root.edit-msg(id); }
|
||||
delete-msg(id) => { root.delete-msg(id); }
|
||||
}
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
}
|
||||
}
|
||||
if root.replying-to-message != "" : Rectangle {
|
||||
height: 34px; background: Theme.bg-elevated;
|
||||
HorizontalLayout {
|
||||
padding-left: 16px; padding-right: 16px; spacing: 9px;
|
||||
Text { text: "Ответ " + root.replying-to-sender; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
Text { text: root.replying-to-content; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-stretch: 1; overflow: elide; }
|
||||
ActionButton { text: "×"; quiet: true; width: 28px; clicked => { root.cancel-reply(); } }
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
height: 92px;
|
||||
VerticalLayout {
|
||||
padding-left: 20px; padding-right: 20px; padding-top: 8px; spacing: 5px;
|
||||
Rectangle {
|
||||
background: Theme.bg-interactive; border-radius: 9px;
|
||||
border-width: 1px; border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
padding: 10px; spacing: 10px;
|
||||
editor := TextInput {
|
||||
text <=> root.input-text;
|
||||
single-line: false;
|
||||
color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.9375);
|
||||
horizontal-stretch: 1; wrap: word-wrap;
|
||||
edited => { root.input-edited(self.text); }
|
||||
key-pressed(event) => {
|
||||
if event.text == "\n" && !event.modifiers.shift {
|
||||
root.send-message(root.is-dm ? "" : root.active-channel-id, root.input-text);
|
||||
return accept;
|
||||
}
|
||||
return reject;
|
||||
}
|
||||
}
|
||||
ActionButton {
|
||||
text: "Отправить";
|
||||
clicked => { root.send-message(root.is-dm ? "" : root.active-channel-id, root.input-text); }
|
||||
}
|
||||
}
|
||||
}
|
||||
Text { text: "Enter — отправить · Shift+Enter — новая строка"; color: Theme.text-disabled; font-size: Math.max(11px, Theme.font-size * 0.6875); height: 18px; }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if replying-to-message != "" : Rectangle {
|
||||
height: 32px;
|
||||
background: Theme.bg-elevated;
|
||||
HorizontalLayout {
|
||||
padding-left: 8px;
|
||||
padding-right: 8px;
|
||||
spacing: 8px;
|
||||
Rectangle {
|
||||
width: 3px;
|
||||
height: 20px;
|
||||
background: Theme.accent;
|
||||
border-radius: 2px;
|
||||
}
|
||||
Text {
|
||||
text: "Replying to " + replying-to-sender;
|
||||
color: Theme.text-secondary;
|
||||
font-size: 12px;
|
||||
}
|
||||
Text {
|
||||
text: replying-to-content;
|
||||
color: Theme.text-muted;
|
||||
font-size: 12px;
|
||||
horizontal-stretch: 1;
|
||||
overflow: elide;
|
||||
}
|
||||
Rectangle {
|
||||
width: 20px; height: 20px; border-radius: 4px;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea { clicked => { cancel-reply(); } }
|
||||
Text { text: "✕"; color: Theme.text-muted; font-size: 12px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
height: 48px;
|
||||
background: Theme.bg-surface;
|
||||
HorizontalLayout {
|
||||
padding: 8px;
|
||||
spacing: 8px;
|
||||
TextInput {
|
||||
text <=> input-text;
|
||||
horizontal-stretch: 1;
|
||||
font-size: 14px;
|
||||
}
|
||||
Rectangle {
|
||||
width: 64px;
|
||||
height: 32px;
|
||||
background: Theme.accent;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => {
|
||||
send-message(active-channel-id, input-text);
|
||||
input-text = "";
|
||||
if root.members-visible && !root.is-dm : Rectangle {
|
||||
width: 210px; background: Theme.bg-surface;
|
||||
Flickable {
|
||||
content-width: self.width;
|
||||
VerticalLayout {
|
||||
padding: 16px; spacing: 12px;
|
||||
Text { text: "Участники — " + root.members.length; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 28px; }
|
||||
for member in root.members: HorizontalLayout {
|
||||
height: 38px; spacing: 9px;
|
||||
Rectangle { width: 28px; height: 28px; background: Theme.avatar-bg; border-radius: 11px; Text { text: member.avatar_text; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.6875); horizontal-alignment: center; vertical-alignment: center; } }
|
||||
VerticalLayout {
|
||||
spacing: 1px;
|
||||
Text { text: member.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.8125); overflow: elide; }
|
||||
Text { text: member.status; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
|
||||
}
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: "Send";
|
||||
color: Theme.text-primary;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,101 +1,88 @@
|
|||
import { Theme } from "theme.slint";
|
||||
import { Button, ListView, LineEdit } from "std-widgets.slint";
|
||||
import { Theme, ActionButton } from "theme.slint";
|
||||
|
||||
export struct BookmarkItem {
|
||||
name: string,
|
||||
address: string,
|
||||
}
|
||||
export struct BookmarkItem { name: string, address: string }
|
||||
|
||||
export component ConnectScreen {
|
||||
export component ConnectScreen inherits Rectangle {
|
||||
in-out property <[BookmarkItem]> bookmarks;
|
||||
in-out property <string> address-input;
|
||||
in-out property <string> status-text;
|
||||
in-out property <bool> connecting;
|
||||
in-out property <bool> auto-reconnect;
|
||||
in-out property <string> node-name;
|
||||
|
||||
callback address-edited(string);
|
||||
callback auto-reconnect-changed(bool);
|
||||
callback connect(string);
|
||||
callback disconnect();
|
||||
callback remove-bookmark(string);
|
||||
callback add-bookmark(string);
|
||||
|
||||
callback open-settings();
|
||||
background: Theme.bg-base;
|
||||
VerticalLayout {
|
||||
alignment: center;
|
||||
spacing: 16px;
|
||||
|
||||
Text { text: "VNOX"; color: Theme.accent; font-size: 36px; font-weight: 700; }
|
||||
Text { text: "Self-hosted voice & chat"; color: Theme.text-secondary; font-size: 14px; }
|
||||
|
||||
padding: 32px; spacing: 22px;
|
||||
HorizontalLayout {
|
||||
LineEdit {
|
||||
text <=> address-input;
|
||||
placeholder-text: "server:7600";
|
||||
width: 300px;
|
||||
}
|
||||
Rectangle {
|
||||
width: 100px;
|
||||
height: 30px;
|
||||
background: Theme.accent;
|
||||
border-radius: 6px;
|
||||
TouchArea {
|
||||
enabled: !connecting;
|
||||
clicked => { connect(address-input); }
|
||||
}
|
||||
Text {
|
||||
text: connecting ? "Connecting..." : "Connect";
|
||||
color: Theme.text-primary;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
Image { source: @image-url("assets/vnox-mark.svg"); width: 32px; height: 32px; image-fit: contain; }
|
||||
Text { text: "Vnox"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.1875); font-weight: 700; }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: "Настройки"; quiet: true; clicked => { root.open-settings(); } }
|
||||
}
|
||||
|
||||
Text { text: status-text; color: Theme.text-muted; }
|
||||
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
HorizontalLayout {
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
Rectangle {
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
background: auto-reconnect ? Theme.accent : Theme.bg-elevated;
|
||||
border-radius: 3px;
|
||||
border-width: 1px;
|
||||
border-color: Theme.text-muted;
|
||||
TouchArea {
|
||||
clicked => { auto-reconnect = !auto-reconnect; }
|
||||
}
|
||||
}
|
||||
Text { text: "Auto-reconnect"; color: Theme.text-secondary; }
|
||||
}
|
||||
|
||||
Text { text: "Saved Servers"; color: Theme.text-primary; font-size: 16px; }
|
||||
ListView {
|
||||
for bm in bookmarks: Rectangle {
|
||||
height: 40px;
|
||||
HorizontalLayout {
|
||||
padding: 8px;
|
||||
Text { text: bm.name; color: Theme.text-primary; }
|
||||
Text { text: bm.address; color: Theme.text-muted; }
|
||||
width: 540px;
|
||||
background: Theme.bg-surface; border-radius: 14px;
|
||||
VerticalLayout {
|
||||
padding: 28px; spacing: 15px;
|
||||
Text { text: "Подключиться к серверу"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.5); font-weight: 600; }
|
||||
Text { text: "Введи адрес своего сервера или выбери сохранённый."; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.8125); wrap: word-wrap; }
|
||||
Text { text: "Адрес сервера"; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
HorizontalLayout {
|
||||
Button { text: "Connect"; clicked => { connect(bm.address); } }
|
||||
Button { text: "✕"; clicked => { remove-bookmark(bm.address); } }
|
||||
spacing: 9px;
|
||||
Rectangle {
|
||||
height: 40px; background: Theme.bg-interactive; border-radius: 7px;
|
||||
border-width: 1px; border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
padding: 10px;
|
||||
TextInput {
|
||||
text <=> root.address-input;
|
||||
single-line: true; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875);
|
||||
edited => { root.address-edited(self.text); }
|
||||
accepted => { if !root.connecting { root.connect(root.address-input); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
if !root.connecting : ActionButton { text: "Подключиться"; height: 40px; clicked => { root.connect(root.address-input); } }
|
||||
if root.connecting : ActionButton { text: "Отмена"; height: 40px; clicked => { root.disconnect(); } }
|
||||
}
|
||||
HorizontalLayout {
|
||||
ActionButton { text: root.auto-reconnect ? "✓" : "○"; width: 30px; quiet: true; clicked => { root.auto-reconnect = !root.auto-reconnect; root.auto-reconnect-changed(root.auto-reconnect); } }
|
||||
Text { text: "Переподключаться при потере связи"; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
if root.connecting : Text { text: "Подключение…"; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.8125); }
|
||||
if root.status-text != "" : Text { text: root.status-text; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.8125); wrap: word-wrap; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
HorizontalLayout {
|
||||
Text { text: "Сохранённые серверы"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); font-weight: 600; }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: "+ Сохранить адрес"; quiet: true; clicked => { root.add-bookmark(root.address-input); } }
|
||||
}
|
||||
if root.bookmarks.length == 0 : Text { text: "Сохранённых серверов пока нет."; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
for server in root.bookmarks: HorizontalLayout {
|
||||
height: 48px; spacing: 8px;
|
||||
VerticalLayout {
|
||||
spacing: 2px; horizontal-stretch: 1;
|
||||
Text { text: server.name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); overflow: elide; }
|
||||
Text { text: server.address; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
|
||||
}
|
||||
ActionButton { text: "Войти"; quiet: true; clicked => { if !root.connecting { root.connect(server.address); } } }
|
||||
ActionButton { text: "×"; width: 28px; quiet: true; clicked => { root.remove-bookmark(server.address); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
Button { text: "+ Add Server"; clicked => { add-bookmark(address-input); } }
|
||||
}
|
||||
|
||||
Text { text: node-name; color: Theme.success; }
|
||||
Rectangle {
|
||||
width: 100px;
|
||||
height: 30px;
|
||||
background: Theme.danger;
|
||||
border-radius: 6px;
|
||||
visible: node-name != "";
|
||||
TouchArea { clicked => { disconnect(); } }
|
||||
Text { text: "Disconnect"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
Text { text: "Твой сервер. Твоё сообщество."; color: Theme.text-disabled; font-size: Math.max(11px, Theme.font-size * 0.75); horizontal-alignment: center; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
135
src/ui/slint/controls.slint
Normal file
135
src/ui/slint/controls.slint
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
import { Theme, ActionButton } from "theme.slint";
|
||||
|
||||
export component DeviceSelect inherits Rectangle {
|
||||
in property <[string]> model;
|
||||
in-out property <int> current-index;
|
||||
callback selected(string);
|
||||
height: 34px;
|
||||
background: Theme.bg-interactive;
|
||||
border-radius: 6px;
|
||||
border-width: 1px;
|
||||
border-color: keyboard.has-focus ? Theme.accent : Theme.border;
|
||||
accessible-role: combobox;
|
||||
HorizontalLayout {
|
||||
padding-left: 11px; padding-right: 11px;
|
||||
Text { text: root.model[root.current-index]; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.8125); vertical-alignment: center; overflow: elide; horizontal-stretch: 1; }
|
||||
Text { text: "⌄"; color: Theme.text-muted; width: 16px; vertical-alignment: center; }
|
||||
}
|
||||
TouchArea { clicked => { keyboard.focus(); popup.show(); } }
|
||||
keyboard := FocusScope {
|
||||
key-pressed(event) => {
|
||||
if event.text == " " || event.text == "\n" { popup.show(); return accept; }
|
||||
if event.text == Key.DownArrow || event.text == Key.UpArrow {
|
||||
root.current-index = Math.clamp(root.current-index + (event.text == Key.DownArrow ? 1 : -1), 0, root.model.length - 1);
|
||||
root.selected(root.model[root.current-index]);
|
||||
return accept;
|
||||
}
|
||||
return reject;
|
||||
}
|
||||
}
|
||||
popup := PopupWindow {
|
||||
x: 0px; y: root.height + 3px;
|
||||
width: root.width;
|
||||
height: Math.min(root.model.length * 36px + 12px, 264px);
|
||||
Rectangle {
|
||||
background: Theme.bg-surface; border-radius: 6px;
|
||||
border-width: 1px; border-color: Theme.border;
|
||||
Flickable {
|
||||
content-width: self.width;
|
||||
VerticalLayout {
|
||||
padding: 6px; spacing: 3px;
|
||||
for item[index] in root.model: ActionButton {
|
||||
text: item; active: index == root.current-index;
|
||||
clicked => { root.current-index = index; root.selected(item); popup.close(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component AudioSlider inherits Rectangle {
|
||||
in property <float> minimum: 0;
|
||||
in property <float> maximum: 100;
|
||||
in-out property <float> value;
|
||||
callback changed(float);
|
||||
height: 26px;
|
||||
border-width: keyboard.has-focus ? 1px : 0px;
|
||||
border-color: Theme.accent; border-radius: 5px;
|
||||
Rectangle { x: 8px; y: 11px; width: parent.width - 16px; height: 4px; background: Theme.bg-rail; border-radius: 2px; }
|
||||
Rectangle { x: 8px; y: 11px; width: (parent.width - 16px) * (root.value - root.minimum) / (root.maximum - root.minimum); height: 4px; background: Theme.accent; border-radius: 2px; }
|
||||
Rectangle { x: 1px + (parent.width - 16px) * (root.value - root.minimum) / (root.maximum - root.minimum); y: 5px; width: 16px; height: 16px; border-radius: 8px; background: Theme.text-primary; border-width: 3px; border-color: Theme.accent; }
|
||||
touch := TouchArea {
|
||||
pointer-event(event) => {
|
||||
if event.button == PointerEventButton.left && event.kind == PointerEventKind.down { keyboard.focus(); root.update-value(root.minimum + Math.clamp((self.mouse-x - 8px) / (root.width - 16px), 0, 1) * (root.maximum - root.minimum)); }
|
||||
}
|
||||
moved => { if self.pressed { root.update-value(root.minimum + Math.clamp((self.mouse-x - 8px) / (root.width - 16px), 0, 1) * (root.maximum - root.minimum)); } }
|
||||
}
|
||||
keyboard := FocusScope {
|
||||
key-pressed(event) => {
|
||||
if event.text == Key.LeftArrow || event.text == Key.RightArrow { root.update-value(root.value + (event.text == Key.RightArrow ? 1 : -1)); return accept; }
|
||||
return reject;
|
||||
}
|
||||
}
|
||||
function update-value(value: float) { root.value = Math.clamp(value, root.minimum, root.maximum); root.changed(root.value); }
|
||||
}
|
||||
|
||||
export component ThemeInput inherits Rectangle {
|
||||
in-out property <string> text;
|
||||
in property <string> placeholder-text;
|
||||
in property <InputType> input-type: InputType.text;
|
||||
in property <bool> read-only: false;
|
||||
callback accepted();
|
||||
callback edited(string);
|
||||
height: 38px;
|
||||
background: Theme.bg-interactive;
|
||||
border-radius: 6px;
|
||||
border-width: 1px;
|
||||
border-color: editor.has-focus ? Theme.accent : Theme.border;
|
||||
Text {
|
||||
x: 12px; y: 0px; width: parent.width - 24px; height: parent.height;
|
||||
visible: root.text == "" && !editor.has-focus;
|
||||
text: root.placeholder-text; color: Theme.text-muted;
|
||||
font-size: Math.max(12px, Theme.font-size - 2px); vertical-alignment: center; overflow: elide;
|
||||
}
|
||||
editor := TextInput {
|
||||
x: 12px; y: (parent.height - self.height) / 2;
|
||||
width: parent.width - 24px; height: self.preferred-height;
|
||||
text <=> root.text; input-type: root.input-type; read-only: root.read-only;
|
||||
single-line: true; color: Theme.text-primary;
|
||||
selection-background-color: Theme.selected; selection-foreground-color: Theme.text-primary;
|
||||
font-size: Math.max(12px, Theme.font-size - 2px);
|
||||
accepted => { root.accepted(); }
|
||||
edited => { root.edited(self.text); }
|
||||
}
|
||||
forward-focus: editor;
|
||||
}
|
||||
|
||||
export component ThemeEditor inherits Rectangle {
|
||||
in-out property <string> text;
|
||||
in property <bool> read-only: false;
|
||||
in property <bool> monospace: true;
|
||||
callback edited(string);
|
||||
min-height: 80px;
|
||||
preferred-height: 220px;
|
||||
background: Theme.bg-interactive;
|
||||
border-radius: 7px;
|
||||
border-width: 1px;
|
||||
border-color: editor.has-focus ? Theme.accent : Theme.border;
|
||||
Flickable {
|
||||
x: 12px; y: 10px;
|
||||
width: parent.width - 24px; height: parent.height - 20px;
|
||||
content-width: self.width;
|
||||
content-height: Math.max(self.height, editor.preferred-height);
|
||||
editor := TextInput {
|
||||
width: parent.width; height: Math.max(parent.height, self.preferred-height);
|
||||
text <=> root.text; read-only: root.read-only; single-line: false;
|
||||
color: Theme.text-primary; font-size: Math.max(12px, Theme.font-size - 3px);
|
||||
font-family: root.monospace ? "monospace" : "sans-serif";
|
||||
selection-background-color: Theme.selected; selection-foreground-color: Theme.text-primary;
|
||||
wrap: word-wrap;
|
||||
edited => { root.edited(self.text); }
|
||||
}
|
||||
}
|
||||
forward-focus: editor;
|
||||
}
|
||||
|
|
@ -1,121 +1,89 @@
|
|||
import { Theme } from "theme.slint";
|
||||
import { Theme, ActionButton } from "theme.slint";
|
||||
|
||||
export struct FriendItem {
|
||||
user_id: string,
|
||||
nickname: string,
|
||||
status: string,
|
||||
}
|
||||
export struct FriendItem { user_id: string, nickname: string, status: string }
|
||||
|
||||
export component FriendsPanel {
|
||||
export component FriendsPanel inherits Rectangle {
|
||||
in-out property <[FriendItem]> friends;
|
||||
in-out property <[FriendItem]> pending-requests;
|
||||
in-out property <[string]> blocked-users;
|
||||
in-out property <string> active-tab;
|
||||
in-out property <string> add-friend-input;
|
||||
|
||||
callback tab-changed(string);
|
||||
callback input-edited(string);
|
||||
callback add-friend(string);
|
||||
callback accept-friend(string);
|
||||
callback decline-friend(string);
|
||||
callback remove-friend(string);
|
||||
callback start-dm(string);
|
||||
|
||||
background: Theme.bg-base;
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
|
||||
Text {
|
||||
text: "Friends";
|
||||
color: Theme.text-primary;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
background: Theme.bg-interactive;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { active-tab = "online"; }
|
||||
}
|
||||
Text { text: "Online"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
background: Theme.bg-interactive;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { active-tab = "all"; }
|
||||
}
|
||||
Text { text: "All"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
background: Theme.bg-interactive;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { active-tab = "pending"; }
|
||||
}
|
||||
Text { text: "Pending"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
background: Theme.bg-interactive;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { active-tab = "blocked"; }
|
||||
}
|
||||
Text { text: "Blocked"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
|
||||
spacing: 0;
|
||||
Rectangle {
|
||||
height: 56px; border-width: 1px; border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
padding-left: 22px; padding-right: 16px; spacing: 10px;
|
||||
Text { text: "Друзья"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; }
|
||||
ActionButton { text: "В сети"; active: root.active-tab == "online"; quiet: true; clicked => { root.tab-changed("online"); } }
|
||||
ActionButton { text: "Все"; active: root.active-tab == "all"; quiet: true; clicked => { root.tab-changed("all"); } }
|
||||
ActionButton { text: "Запросы"; active: root.active-tab == "pending"; quiet: true; clicked => { root.tab-changed("pending"); } }
|
||||
ActionButton { text: "Блокировки"; active: root.active-tab == "blocked"; quiet: true; clicked => { root.tab-changed("blocked"); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
TextInput {
|
||||
text <=> add-friend-input;
|
||||
horizontal-stretch: 1;
|
||||
}
|
||||
Rectangle {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
background: Theme.accent;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => {
|
||||
add-friend(add-friend-input);
|
||||
add-friend-input = "";
|
||||
}
|
||||
}
|
||||
Text { text: "+"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
VerticalLayout {
|
||||
for f in friends: Rectangle {
|
||||
height: 48px;
|
||||
VerticalLayout {
|
||||
padding: 22px; spacing: 16px;
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
Rectangle {
|
||||
height: 38px; background: Theme.bg-interactive; border-radius: 7px;
|
||||
HorizontalLayout {
|
||||
padding: 8px;
|
||||
spacing: 8px;
|
||||
Text {
|
||||
text: f.nickname;
|
||||
color: Theme.text-primary;
|
||||
}
|
||||
Text {
|
||||
text: f.status;
|
||||
color: Theme.text-muted;
|
||||
}
|
||||
Rectangle {
|
||||
width: 40px;
|
||||
height: 28px;
|
||||
background: Theme.accent;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { start-dm(f.user_id); }
|
||||
padding: 10px;
|
||||
TextInput { text <=> root.add-friend-input; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); single-line: true; edited => { root.input-edited(self.text); } accepted => { root.add-friend(root.add-friend-input); } }
|
||||
}
|
||||
}
|
||||
ActionButton { text: "Добавить по ID"; height: 38px; clicked => { root.add-friend(root.add-friend-input); } }
|
||||
}
|
||||
Text { text: root.active-tab == "pending" ? "Входящие запросы" : root.active-tab == "blocked" ? "Заблокированные пользователи" : root.active-tab == "online" ? "Друзья в сети" : "Все друзья"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
Flickable {
|
||||
content-width: self.width;
|
||||
VerticalLayout {
|
||||
spacing: 4px;
|
||||
for friend in root.friends: Rectangle {
|
||||
visible: root.active-tab == "all" || (root.active-tab == "online" && friend.status != "offline" && friend.status != "OFFLINE");
|
||||
height: 58px; border-radius: 7px;
|
||||
background: row-touch.has-hover ? Theme.bg-elevated : transparent;
|
||||
row-touch := TouchArea { }
|
||||
HorizontalLayout {
|
||||
padding: 10px; spacing: 12px;
|
||||
Rectangle { width: 32px; height: 32px; background: Theme.avatar-bg; border-radius: 12px; Text { text: "@"; color: Theme.accent; horizontal-alignment: center; vertical-alignment: center; } }
|
||||
VerticalLayout {
|
||||
spacing: 2px; horizontal-stretch: 1;
|
||||
Text { text: friend.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); }
|
||||
Text { text: friend.status; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.6875); }
|
||||
}
|
||||
Text { text: "DM"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; }
|
||||
ActionButton { text: "Написать"; quiet: true; clicked => { root.start-dm(friend.user_id); } }
|
||||
ActionButton { text: "Удалить"; quiet: true; danger: true; clicked => { root.remove-friend(friend.user_id); } }
|
||||
}
|
||||
}
|
||||
for friend in root.pending-requests: Rectangle {
|
||||
visible: root.active-tab == "pending";
|
||||
height: 58px;
|
||||
HorizontalLayout {
|
||||
padding: 10px; spacing: 10px;
|
||||
Text { text: friend.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-stretch: 1; }
|
||||
ActionButton { text: "Принять"; clicked => { root.accept-friend(friend.user_id); } }
|
||||
ActionButton { text: "Отклонить"; danger: true; quiet: true; clicked => { root.decline-friend(friend.user_id); } }
|
||||
}
|
||||
}
|
||||
for user in root.blocked-users: Rectangle {
|
||||
visible: root.active-tab == "blocked";
|
||||
height: 40px;
|
||||
Text { text: user; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.8125); overflow: elide; }
|
||||
}
|
||||
if root.friends.length == 0 && (root.active-tab == "all" || root.active-tab == "online") : Text { text: "Список друзей пока пуст. Добавь друга по его ID."; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); wrap: word-wrap; }
|
||||
if root.pending-requests.length == 0 && root.active-tab == "pending" : Text { text: "Новых запросов нет."; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); }
|
||||
if root.blocked-users.length == 0 && root.active-tab == "blocked" : Text { text: "Список блокировок пуст."; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); }
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,21 +1,42 @@
|
|||
import { Theme } from "theme.slint";
|
||||
import { Sidebar, ChannelItem, GuildItem } from "sidebar.slint";
|
||||
export { UnlockWindow } from "unlock.slint";
|
||||
export { Theme } from "theme.slint";
|
||||
import { Theme, ActionButton } from "theme.slint";
|
||||
import { Sidebar, ChannelItem, GuildItem, DmItem } from "sidebar.slint";
|
||||
import { ChatPanel, MessageItem, MemberItem } from "chat.slint";
|
||||
import { FriendsPanel, FriendItem } from "friends.slint";
|
||||
import { VoicePanel, VoiceMemberItem } from "voice.slint";
|
||||
import { BookmarkItem, ConnectScreen } from "connect.slint";
|
||||
import { SettingsWindow } from "settings.slint";
|
||||
import { AvatarCropper } from "avatar-cropper.slint";
|
||||
|
||||
export component MainWindow inherits Window {
|
||||
in-out property <[ChannelItem]> channels;
|
||||
in-out property <[GuildItem]> guilds;
|
||||
in-out property <[string]> dm-conversations;
|
||||
in-out property <[DmItem]> dm-conversations;
|
||||
in-out property <string> username;
|
||||
in-out property <string> user-status;
|
||||
in-out property <string> active-channel-id;
|
||||
in-out property <int> active-guild-idx;
|
||||
in-out property <bool> show-dms;
|
||||
|
||||
in-out property <image> own-avatar;
|
||||
in-out property <bool> has-avatar;
|
||||
in-out property <bool> avatar-crop-open;
|
||||
in-out property <image> avatar-source;
|
||||
in-out property <float> avatar-source-width: 1;
|
||||
in-out property <float> avatar-source-height: 1;
|
||||
in-out property <float> avatar-zoom: 1;
|
||||
in-out property <float> avatar-offset-x;
|
||||
in-out property <float> avatar-offset-y;
|
||||
in-out property <string> avatar-error;
|
||||
private property <string> pending-delete-id;
|
||||
in-out property <string> active-dm-id;
|
||||
in-out property <bool> voice-connected;
|
||||
in-out property <bool> members-visible: true;
|
||||
in-out property <[string]> input-devices;
|
||||
in-out property <[string]> output-devices;
|
||||
in-out property <int> input-device-index;
|
||||
in-out property <int> output-device-index;
|
||||
in-out property <string> active-channel-name;
|
||||
in-out property <[MessageItem]> messages;
|
||||
in-out property <[MemberItem]> members;
|
||||
|
|
@ -56,6 +77,13 @@ export component MainWindow inherits Window {
|
|||
in-out property <float> voice-bitrate: 64.0;
|
||||
in-out property <int> vad-mode: 0;
|
||||
in-out property <float> volume: 100.0;
|
||||
in-out property <string> theme-mode: "dark";
|
||||
in-out property <string> theme-css;
|
||||
in-out property <string> theme-file-path;
|
||||
in-out property <float> text-size: 16;
|
||||
in-out property <string> theme-error;
|
||||
in-out property <string> theme-status;
|
||||
in-out property <bool> theme-preview;
|
||||
in-out property <string> active-tab: "audio";
|
||||
in-out property <bool> settings-open;
|
||||
|
||||
|
|
@ -75,6 +103,30 @@ export component MainWindow inherits Window {
|
|||
in-out property <string> import-pass-input;
|
||||
in-out property <string> import-error;
|
||||
|
||||
callback choose-avatar();
|
||||
callback remove-avatar();
|
||||
callback avatar-crop-moved(float, float);
|
||||
callback avatar-zoom-changed(float);
|
||||
callback confirm-avatar();
|
||||
callback cancel-avatar();
|
||||
callback theme-selected(string);
|
||||
callback text-size-changed(float);
|
||||
callback preview-theme(string);
|
||||
callback apply-theme(string);
|
||||
callback reset-theme();
|
||||
callback import-theme(string);
|
||||
callback export-theme(string);
|
||||
callback dismiss-status();
|
||||
callback ptt-held(bool);
|
||||
callback input-edited(string);
|
||||
callback address-edited(string);
|
||||
callback auto-reconnect-changed(bool);
|
||||
callback friends-tab-changed(string);
|
||||
callback friend-input-edited(string);
|
||||
callback open-settings();
|
||||
callback show-voice-view();
|
||||
callback show-friends-view();
|
||||
callback audio-settings-changed(int, int, float, int, float);
|
||||
callback channel-selected(string);
|
||||
callback guild-selected(int);
|
||||
callback dm-selected(string);
|
||||
|
|
@ -103,18 +155,25 @@ export component MainWindow inherits Window {
|
|||
callback export-keyfile(string, string);
|
||||
callback import-keyfile(string, string);
|
||||
|
||||
min-width: 900px;
|
||||
min-height: 560px;
|
||||
preferred-width: 1280px;
|
||||
preferred-height: 800px;
|
||||
min-width: 920px;
|
||||
min-height: 640px;
|
||||
title: "Vnox";
|
||||
icon: @image-url("assets/vnox-mark.svg");
|
||||
background: Theme.bg-base;
|
||||
|
||||
|
||||
if node-name == "" : ConnectScreen {
|
||||
bookmarks: root.bookmarks;
|
||||
address-input: root.address-input;
|
||||
address-input <=> root.address-input;
|
||||
status-text: root.status-text;
|
||||
connecting: root.connecting;
|
||||
auto-reconnect: root.auto-reconnect;
|
||||
auto-reconnect <=> root.auto-reconnect;
|
||||
node-name: root.node-name;
|
||||
open-settings => { root.open-settings(); }
|
||||
address-edited(text) => { root.address-edited(text); }
|
||||
auto-reconnect-changed(value) => { root.auto-reconnect-changed(value); }
|
||||
connect(address) => { root.connect(address); }
|
||||
disconnect => { root.disconnect(); }
|
||||
remove-bookmark(address) => { root.remove-bookmark(address); }
|
||||
|
|
@ -125,6 +184,20 @@ export component MainWindow inherits Window {
|
|||
channels: root.channels;
|
||||
guilds: root.guilds;
|
||||
dm-conversations: root.dm-conversations;
|
||||
node-name: root.node-name;
|
||||
active-dm-id: root.active-dm-id;
|
||||
voice-connected: root.voice-connected;
|
||||
voice-channel-name: root.voice-channel-name;
|
||||
mic-enabled: root.mic-enabled;
|
||||
deafened: root.deafened;
|
||||
open-settings => { root.open-settings(); }
|
||||
toggle-mic => { root.toggle-mic(); }
|
||||
toggle-deafen => { root.toggle-deafen(); }
|
||||
leave-voice => { root.leave-voice(); }
|
||||
show-voice => { root.show-voice-view(); }
|
||||
show-friends => { root.show-friends-view(); }
|
||||
own-avatar: root.own-avatar;
|
||||
has-avatar: root.has-avatar;
|
||||
username: root.username;
|
||||
user-status: root.user-status;
|
||||
active-channel-id: root.active-channel-id;
|
||||
|
|
@ -135,13 +208,27 @@ export component MainWindow inherits Window {
|
|||
dm-selected(id) => { root.dm-selected(id); }
|
||||
disconnect => { root.disconnect(); }
|
||||
}
|
||||
chat-panel := ChatPanel {
|
||||
visible: show-chat;
|
||||
active-channel-id: root.active-channel-id;
|
||||
VerticalLayout {
|
||||
spacing: 0;
|
||||
if root.status-text != "" : Rectangle {
|
||||
height: 42px; background: Theme.bg-elevated;
|
||||
HorizontalLayout {
|
||||
padding-left: 16px; padding-right: 10px; spacing: 12px;
|
||||
Text { text: root.status-text; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.75); wrap: word-wrap; vertical-alignment: center; horizontal-stretch: 1; }
|
||||
ActionButton { text: "×"; width: 28px; quiet: true; clicked => { root.dismiss-status(); } }
|
||||
}
|
||||
}
|
||||
if root.show-chat : ChatPanel {
|
||||
own-avatar: root.own-avatar;
|
||||
has-own-avatar: root.has-avatar;
|
||||
active-channel-id: root.is-dm ? "" : root.active-channel-id;
|
||||
active-channel-name: root.active-channel-name;
|
||||
messages: root.messages;
|
||||
members: root.members;
|
||||
input-text: root.input-text;
|
||||
input-text <=> root.input-text;
|
||||
members-visible: root.members-visible && root.width > 1100px;
|
||||
toggle-members => { root.members-visible = !root.members-visible; }
|
||||
input-edited(text) => { root.input-edited(text); }
|
||||
is-dm: root.is-dm;
|
||||
e2ee-enabled: root.e2ee-enabled;
|
||||
dm-partner-name: root.dm-partner-name;
|
||||
|
|
@ -153,63 +240,86 @@ export component MainWindow inherits Window {
|
|||
react(id, emoji) => { root.react(id, emoji); }
|
||||
reply-to-msg(id) => { root.reply-to-msg(id); }
|
||||
edit-msg(id) => { root.edit-msg(id); }
|
||||
delete-msg(id) => { root.delete-msg(id); }
|
||||
delete-msg(id) => { root.pending-delete-id = id; }
|
||||
cancel-reply => { root.cancel-reply(); }
|
||||
}
|
||||
friends-panel := FriendsPanel {
|
||||
visible: show-friends;
|
||||
if root.show-friends : FriendsPanel {
|
||||
friends: root.friends;
|
||||
pending-requests: root.pending-requests;
|
||||
blocked-users: root.blocked-users;
|
||||
active-tab: root.friends-active-tab;
|
||||
add-friend-input: root.add-friend-input;
|
||||
active-tab <=> root.friends-active-tab;
|
||||
add-friend-input <=> root.add-friend-input;
|
||||
tab-changed(tab) => { root.friends-tab-changed(tab); }
|
||||
input-edited(text) => { root.friend-input-edited(text); }
|
||||
add-friend(id) => { root.add-friend(id); }
|
||||
accept-friend(id) => { root.accept-friend(id); }
|
||||
decline-friend(id) => { root.decline-friend(id); }
|
||||
remove-friend(id) => { root.remove-friend(id); }
|
||||
start-dm(id) => { root.start-dm(id); }
|
||||
}
|
||||
voice-panel := VoicePanel {
|
||||
visible: show-voice;
|
||||
if root.show-voice : VoicePanel {
|
||||
members: root.voice-members;
|
||||
mic-enabled: root.mic-enabled;
|
||||
deafened: root.deafened;
|
||||
channel-name: root.voice-channel-name;
|
||||
activity-banner: root.activity-banner;
|
||||
push-to-talk: root.vad-mode == 0;
|
||||
ptt-held(held) => { root.ptt-held(held); }
|
||||
toggle-mic => { root.toggle-mic(); }
|
||||
toggle-deafen => { root.toggle-deafen(); }
|
||||
leave-voice => { root.leave-voice(); }
|
||||
}
|
||||
|
||||
if root.settings-open : Rectangle {
|
||||
background: #00000080;
|
||||
TouchArea { }
|
||||
SettingsWindow {
|
||||
y: (parent.height - 480px) / 2;
|
||||
x: (parent.width - 640px) / 2;
|
||||
}
|
||||
}
|
||||
if root.settings-open : SettingsWindow {
|
||||
own-avatar: root.own-avatar;
|
||||
has-avatar: root.has-avatar;
|
||||
avatar-error: root.avatar-error;
|
||||
choose-avatar => { root.choose-avatar(); }
|
||||
remove-avatar => { root.remove-avatar(); }
|
||||
theme-mode <=> root.theme-mode;
|
||||
theme-css <=> root.theme-css;
|
||||
theme-file-path <=> root.theme-file-path;
|
||||
text-size <=> root.text-size;
|
||||
theme-error: root.theme-error;
|
||||
theme-status: root.theme-status;
|
||||
theme-preview: root.theme-preview;
|
||||
theme-selected(mode) => { root.theme-selected(mode); }
|
||||
text-size-changed(size) => { root.text-size-changed(size); }
|
||||
preview-theme(css) => { root.preview-theme(css); }
|
||||
apply-theme(css) => { root.apply-theme(css); }
|
||||
reset-theme => { root.reset-theme(); }
|
||||
import-theme(path) => { root.import-theme(path); }
|
||||
export-theme(path) => { root.export-theme(path); }
|
||||
input-devices: root.input-devices;
|
||||
output-devices: root.output-devices;
|
||||
input-device-index <=> root.input-device-index;
|
||||
output-device-index <=> root.output-device-index;
|
||||
audio-changed => { root.audio-settings-changed(root.input-device-index, root.output-device-index, root.voice-bitrate, root.vad-mode, root.volume); }
|
||||
identity-pubkey: root.identity-pubkey;
|
||||
vault-enabled: root.vault-enabled;
|
||||
voice-input-device: root.voice-input-device;
|
||||
voice-output-device: root.voice-output-device;
|
||||
voice-bitrate: root.voice-bitrate;
|
||||
vad-mode: root.vad-mode;
|
||||
volume: root.volume;
|
||||
active-tab: root.active-tab;
|
||||
voice-bitrate <=> root.voice-bitrate;
|
||||
vad-mode <=> root.vad-mode;
|
||||
volume <=> root.volume;
|
||||
active-tab <=> root.active-tab;
|
||||
|
||||
passphrase-modal-open: root.passphrase-modal-open;
|
||||
passphrase-input: root.passphrase-input;
|
||||
passphrase-confirm: root.passphrase-confirm;
|
||||
passphrase-modal-open <=> root.passphrase-modal-open;
|
||||
passphrase-input <=> root.passphrase-input;
|
||||
passphrase-confirm <=> root.passphrase-confirm;
|
||||
passphrase-error: root.passphrase-error;
|
||||
|
||||
export-modal-open: root.export-modal-open;
|
||||
export-pass-input: root.export-pass-input;
|
||||
export-pass-confirm: root.export-pass-confirm;
|
||||
export-modal-open <=> root.export-modal-open;
|
||||
export-pass-input <=> root.export-pass-input;
|
||||
export-pass-confirm <=> root.export-pass-confirm;
|
||||
export-output: root.export-output;
|
||||
export-error: root.export-error;
|
||||
|
||||
import-modal-open: root.import-modal-open;
|
||||
import-keyfile-input: root.import-keyfile-input;
|
||||
import-pass-input: root.import-pass-input;
|
||||
import-modal-open <=> root.import-modal-open;
|
||||
import-keyfile-input <=> root.import-keyfile-input;
|
||||
import-pass-input <=> root.import-pass-input;
|
||||
import-error: root.import-error;
|
||||
|
||||
close => { root.close-settings(); }
|
||||
|
|
@ -218,6 +328,36 @@ export component MainWindow inherits Window {
|
|||
export-keyfile(pass, confirm) => { root.export-keyfile(pass, confirm); }
|
||||
import-keyfile(input, pass) => { root.import-keyfile(input, pass); }
|
||||
}
|
||||
|
||||
if root.pending-delete-id != "" : Rectangle {
|
||||
background: Theme.overlay;
|
||||
TouchArea { }
|
||||
Rectangle {
|
||||
width: 420px; height: 170px;
|
||||
x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2;
|
||||
background: Theme.bg-surface; border-radius: 10px;
|
||||
VerticalLayout {
|
||||
padding: 22px; spacing: 12px;
|
||||
Text { text: "Удалить сообщение?"; font-size: Math.max(11px, Theme.font-size * 1.1875); color: Theme.text-primary; }
|
||||
Text { text: "Это действие нельзя отменить."; font-size: Math.max(11px, Theme.font-size * 0.8125); color: Theme.text-muted; }
|
||||
HorizontalLayout {
|
||||
ActionButton { text: "Отмена"; clicked => { root.pending-delete-id = ""; } }
|
||||
ActionButton { text: "Удалить"; danger: true; clicked => { root.delete-msg(root.pending-delete-id); root.pending-delete-id = ""; } }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if root.avatar-crop-open : AvatarCropper {
|
||||
avatar-source: root.avatar-source;
|
||||
source-width: root.avatar-source-width;
|
||||
source-height: root.avatar-source-height;
|
||||
zoom <=> root.avatar-zoom;
|
||||
offset-x: root.avatar-offset-x;
|
||||
offset-y: root.avatar-offset-y;
|
||||
error: root.avatar-error;
|
||||
crop-moved(x,y) => { root.avatar-crop-moved(x,y); }
|
||||
zoom-changed(value) => { root.avatar-zoom-changed(value); }
|
||||
confirm => { root.confirm-avatar(); }
|
||||
cancel => { root.cancel-avatar(); }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,44 @@
|
|||
import { Theme } from "theme.slint";
|
||||
import { Button, LineEdit } from "std-widgets.slint";
|
||||
import { Theme, ActionButton, Symbol } from "theme.slint";
|
||||
import { AudioSettings } from "settings/audio.slint";
|
||||
import { AppearanceSettings } from "settings/appearance.slint";
|
||||
import { IdentitySettings } from "settings/identity.slint";
|
||||
|
||||
export component SettingsWindow {
|
||||
width: 640px;
|
||||
height: 480px;
|
||||
component SettingsNav inherits Rectangle {
|
||||
in property <string> label;
|
||||
in property <string> detail;
|
||||
in property <string> mark;
|
||||
in property <bool> active;
|
||||
callback clicked();
|
||||
height: 58px;
|
||||
border-radius: 7px;
|
||||
background: root.active ? Theme.selected : touch.has-hover ? Theme.bg-hover : transparent;
|
||||
border-width: keyboard.has-focus ? 1px : 0px;
|
||||
border-color: Theme.accent;
|
||||
accessible-role: button;
|
||||
accessible-label: root.label;
|
||||
HorizontalLayout {
|
||||
padding-left: 12px; padding-right: 12px; spacing: 11px;
|
||||
Text { text: root.mark; color: root.active ? Theme.text-primary : Theme.text-muted; font-size: Theme.font-size + 2px; width: 23px; vertical-alignment: center; }
|
||||
VerticalLayout {
|
||||
spacing: 2px; alignment: center;
|
||||
Text { text: root.label; color: Theme.text-primary; font-size: Math.max(Theme.font-size - 2px, 11px); font-weight: root.active ? 600 : 400; overflow: elide; }
|
||||
Text { text: root.detail; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 5px, 11px); overflow: elide; }
|
||||
}
|
||||
}
|
||||
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
|
||||
keyboard := FocusScope { key-pressed(event) => { if event.text == " " || event.text == "\n" { root.clicked(); return accept; } return reject; } }
|
||||
}
|
||||
|
||||
export component SettingsWindow inherits Rectangle {
|
||||
in property <image> own-avatar;
|
||||
in property <bool> has-avatar;
|
||||
in property <string> avatar-error;
|
||||
callback choose-avatar();
|
||||
callback remove-avatar();
|
||||
in property <[string]> input-devices;
|
||||
in property <[string]> output-devices;
|
||||
in-out property <int> input-device-index;
|
||||
in-out property <int> output-device-index;
|
||||
in-out property <string> identity-pubkey;
|
||||
in-out property <bool> vault-enabled;
|
||||
in-out property <string> voice-input-device;
|
||||
|
|
@ -12,180 +46,131 @@ export component SettingsWindow {
|
|||
in-out property <float> voice-bitrate;
|
||||
in-out property <int> vad-mode;
|
||||
in-out property <float> volume;
|
||||
in-out property <string> active-tab;
|
||||
|
||||
in-out property <string> active-tab: "audio";
|
||||
in-out property <bool> passphrase-modal-open;
|
||||
in-out property <string> passphrase-input;
|
||||
in-out property <string> passphrase-confirm;
|
||||
in-out property <string> passphrase-error;
|
||||
|
||||
in-out property <bool> export-modal-open;
|
||||
in-out property <string> export-pass-input;
|
||||
in-out property <string> export-pass-confirm;
|
||||
in-out property <string> export-output;
|
||||
in-out property <string> export-error;
|
||||
|
||||
in-out property <bool> import-modal-open;
|
||||
in-out property <string> import-keyfile-input;
|
||||
in-out property <string> import-pass-input;
|
||||
in-out property <string> import-error;
|
||||
|
||||
in-out property <string> theme-mode;
|
||||
in-out property <string> theme-css;
|
||||
in-out property <string> theme-file-path;
|
||||
in-out property <float> text-size;
|
||||
in property <string> theme-error;
|
||||
in property <string> theme-status;
|
||||
in property <bool> theme-preview;
|
||||
callback audio-changed();
|
||||
callback close();
|
||||
callback set-passphrase(string, string);
|
||||
callback remove-passphrase();
|
||||
callback export-keyfile(string, string);
|
||||
callback import-keyfile(string, string);
|
||||
|
||||
Rectangle {
|
||||
background: Theme.bg-base;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border-radius: 12px;
|
||||
border-width: 1px;
|
||||
border-color: Theme.bg-elevated;
|
||||
|
||||
callback theme-selected(string);
|
||||
callback text-size-changed(float);
|
||||
callback preview-theme(string);
|
||||
callback apply-theme(string);
|
||||
callback reset-theme();
|
||||
callback import-theme(string);
|
||||
callback export-theme(string);
|
||||
background: Theme.bg-base;
|
||||
changed active-tab => { settings-scroll.content-y = 0px; }
|
||||
HorizontalLayout {
|
||||
spacing: 0;
|
||||
Rectangle {
|
||||
width: 236px; background: Theme.bg-surface;
|
||||
VerticalLayout {
|
||||
padding-left: 16px; padding-right: 16px; padding-top: 32px; padding-bottom: 20px; spacing: 7px;
|
||||
Text { text: "Настройки"; color: Theme.text-primary; font-size: Theme.font-size + 6px; font-weight: 700; height: 46px; }
|
||||
SettingsNav { label: "Звук и микрофон"; detail: "Устройства и передача"; mark: "◖"; active: root.active-tab == "audio"; clicked => { root.active-tab = "audio"; } }
|
||||
SettingsNav { label: "Внешний вид"; detail: "Темы, цвета и текст"; mark: "Aa"; active: root.active-tab == "appearance"; clicked => { root.active-tab = "appearance"; } }
|
||||
SettingsNav { label: "Профиль и ключи"; detail: "Защита и резервная копия"; mark: "◇"; active: root.active-tab == "identity"; clicked => { root.active-tab = "identity"; } }
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Text { text: "VNOX"; color: Theme.text-secondary; font-size: Math.max(Theme.font-size - 3px, 11px); font-weight: 700; height: 30px; vertical-alignment: bottom; }
|
||||
Text { text: "Настройки этого устройства"; color: Theme.text-disabled; font-size: Math.max(Theme.font-size - 5px, 11px); }
|
||||
ActionButton { text: "Вернуться в приложение"; quiet: true; clicked => { root.close(); } }
|
||||
}
|
||||
}
|
||||
Rectangle { width: 1px; background: Theme.border; }
|
||||
VerticalLayout {
|
||||
padding: 0;
|
||||
spacing: 0;
|
||||
|
||||
Rectangle {
|
||||
height: 44px;
|
||||
background: Theme.bg-surface;
|
||||
border-radius: 12px;
|
||||
height: 114px;
|
||||
HorizontalLayout {
|
||||
padding: 8px;
|
||||
spacing: 4px;
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
background: active-tab == "audio" ? Theme.accent : Theme.bg-interactive;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea { clicked => { active-tab = "audio"; } }
|
||||
Text { text: "Audio"; color: Theme.text-primary; font-size: 13px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
background: active-tab == "network" ? Theme.accent : Theme.bg-interactive;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea { clicked => { active-tab = "network"; } }
|
||||
Text { text: "Network"; color: Theme.text-primary; font-size: 13px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
background: active-tab == "identity" ? Theme.accent : Theme.bg-interactive;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea { clicked => { active-tab = "identity"; } }
|
||||
Text { text: "Identity"; color: Theme.text-primary; font-size: 13px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
HorizontalLayout { horizontal-stretch: 1; }
|
||||
Rectangle {
|
||||
height: 28px;
|
||||
width: 28px;
|
||||
border-radius: Theme.radius;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea { clicked => { close(); } }
|
||||
Text { text: "✕"; color: Theme.text-muted; font-size: 14px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
padding-left: 34px; padding-right: 28px; padding-top: 29px; padding-bottom: 20px; spacing: 18px;
|
||||
VerticalLayout {
|
||||
spacing: 6px;
|
||||
Text { text: root.active-tab == "appearance" ? "Внешний вид" : root.active-tab == "identity" ? "Профиль и ключи" : "Звук и микрофон"; color: Theme.text-primary; font-size: Theme.font-size + 12px; font-weight: 700; }
|
||||
Text { text: root.active-tab == "appearance" ? "Сделай Vnox своим." : root.active-tab == "identity" ? "Твой профиль и его сохранность." : "Голос должен звучать так, как тебе удобно."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); }
|
||||
}
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: "×"; width: 34px; text-size: 21px; quiet: true; clicked => { root.close(); } }
|
||||
}
|
||||
}
|
||||
|
||||
if active-tab == "audio" : VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 12px;
|
||||
Text { text: "Voice Settings"; color: Theme.text-primary; font-size: 16px; font-weight: 600; }
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: "Input Device:"; color: Theme.text-secondary; }
|
||||
Text { text: voice-input-device; color: Theme.text-primary; }
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: "Output Device:"; color: Theme.text-secondary; }
|
||||
Text { text: voice-output-device; color: Theme.text-primary; }
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: "Bitrate:"; color: Theme.text-secondary; }
|
||||
Text { text: voice-bitrate; color: Theme.text-primary; }
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: "Mode:"; color: Theme.text-secondary; }
|
||||
Text { text: vad-mode == 0 ? "Push to Talk" : vad-mode == 1 ? "Voice Activity" : "Always On"; color: Theme.text-primary; }
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: "Volume:"; color: Theme.text-secondary; }
|
||||
Text { text: volume; color: Theme.text-primary; }
|
||||
}
|
||||
}
|
||||
|
||||
if active-tab == "network" : VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 12px;
|
||||
Text { text: "Network"; color: Theme.text-primary; font-size: 16px; font-weight: 600; }
|
||||
Text { text: "Connection settings will appear here."; color: Theme.text-muted; }
|
||||
}
|
||||
|
||||
if active-tab == "identity" : VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 12px;
|
||||
Text { text: "Identity"; color: Theme.text-primary; font-size: 16px; font-weight: 600; }
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: "Public Key:"; color: Theme.text-secondary; }
|
||||
Text { text: identity-pubkey; color: Theme.text-primary; font-family: "monospace"; }
|
||||
}
|
||||
Text { text: vault-enabled ? "Vault is encrypted" : "Vault is plaintext"; color: Theme.text-secondary; }
|
||||
|
||||
if !passphrase-modal-open && !export-modal-open && !import-modal-open : VerticalLayout {
|
||||
spacing: 8px;
|
||||
Rectangle { height: 28px; background: Theme.accent; border-radius: Theme.radius; TouchArea { clicked => { passphrase-modal-open = true; } } Text { text: vault-enabled ? "Change Passphrase" : "Set Passphrase"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; } }
|
||||
if vault-enabled : Rectangle { height: 28px; background: Theme.danger; border-radius: Theme.radius; TouchArea { clicked => { remove-passphrase(); } } Text { text: "Remove Passphrase"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; } }
|
||||
Rectangle { height: 28px; background: Theme.accent; border-radius: Theme.radius; TouchArea { clicked => { export-modal-open = true; } } Text { text: "Export Keyfile"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; } }
|
||||
Rectangle { height: 28px; background: Theme.accent; border-radius: Theme.radius; TouchArea { clicked => { import-modal-open = true; } } Text { text: "Import Keyfile"; color: Theme.text-primary; horizontal-alignment: center; vertical-alignment: center; } }
|
||||
}
|
||||
|
||||
if passphrase-modal-open : VerticalLayout {
|
||||
spacing: 8px;
|
||||
Rectangle { height: 1px; background: Theme.bg-elevated; }
|
||||
Text { text: vault-enabled ? "Change Passphrase" : "Set Passphrase"; color: Theme.text-primary; font-weight: 600; }
|
||||
LineEdit { text <=> passphrase-input; placeholder-text: "New passphrase"; }
|
||||
LineEdit { text <=> passphrase-confirm; placeholder-text: "Confirm passphrase"; }
|
||||
if passphrase-error != "" : Text { text: passphrase-error; color: Theme.danger; font-size: 12px; }
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Button { text: "Cancel"; clicked => { passphrase-modal-open = false; } }
|
||||
Button { text: "Save"; clicked => { set-passphrase(passphrase-input, passphrase-confirm); } }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
settings-scroll := Flickable {
|
||||
content-width: self.width;
|
||||
VerticalLayout {
|
||||
padding-left: 34px; padding-right: 34px; padding-top: 28px; padding-bottom: 16px; spacing: 0;
|
||||
if root.active-tab == "audio" || (root.active-tab != "appearance" && root.active-tab != "identity") : AudioSettings {
|
||||
input-devices: root.input-devices;
|
||||
output-devices: root.output-devices;
|
||||
input-device-index <=> root.input-device-index;
|
||||
output-device-index <=> root.output-device-index;
|
||||
voice-bitrate <=> root.voice-bitrate;
|
||||
vad-mode <=> root.vad-mode;
|
||||
volume <=> root.volume;
|
||||
audio-changed => { root.audio-changed(); }
|
||||
}
|
||||
}
|
||||
|
||||
if export-modal-open : VerticalLayout {
|
||||
spacing: 8px;
|
||||
Rectangle { height: 1px; background: Theme.bg-elevated; }
|
||||
Text { text: "Export Keyfile"; color: Theme.text-primary; font-weight: 600; }
|
||||
LineEdit { text <=> export-pass-input; placeholder-text: "Optional passphrase"; }
|
||||
LineEdit { text <=> export-pass-confirm; placeholder-text: "Confirm passphrase"; }
|
||||
if export-error != "" : Text { text: export-error; color: Theme.danger; font-size: 12px; }
|
||||
if export-output != "" : Text { text: export-output; color: Theme.text-muted; font-size: 11px; }
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Button { text: "Cancel"; clicked => { export-modal-open = false; } }
|
||||
Button { text: "Generate"; clicked => { export-keyfile(export-pass-input, export-pass-confirm); } }
|
||||
if root.active-tab == "appearance" : AppearanceSettings {
|
||||
theme-mode <=> root.theme-mode;
|
||||
theme-css <=> root.theme-css;
|
||||
theme-file-path <=> root.theme-file-path;
|
||||
text-size <=> root.text-size;
|
||||
theme-error: root.theme-error;
|
||||
theme-status: root.theme-status;
|
||||
theme-preview: root.theme-preview;
|
||||
theme-selected(mode) => { root.theme-selected(mode); }
|
||||
text-size-changed(size) => { root.text-size-changed(size); }
|
||||
preview-theme(css) => { root.preview-theme(css); }
|
||||
apply-theme(css) => { root.apply-theme(css); }
|
||||
reset-theme => { root.reset-theme(); }
|
||||
import-theme(path) => { root.import-theme(path); }
|
||||
export-theme(path) => { root.export-theme(path); }
|
||||
}
|
||||
}
|
||||
|
||||
if import-modal-open : VerticalLayout {
|
||||
spacing: 8px;
|
||||
Rectangle { height: 1px; background: Theme.bg-elevated; }
|
||||
Text { text: "Import Keyfile"; color: Theme.text-primary; font-weight: 600; }
|
||||
Text { text: "Paste your keyfile JSON below:"; color: Theme.text-secondary; font-size: 12px; }
|
||||
TextInput { text <=> import-keyfile-input; height: 80px; }
|
||||
LineEdit { text <=> import-pass-input; placeholder-text: "Passphrase (if encrypted)"; }
|
||||
if import-error != "" : Text { text: import-error; color: Theme.danger; font-size: 12px; }
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Button { text: "Cancel"; clicked => { import-modal-open = false; } }
|
||||
Button { text: "Import & Replace"; clicked => { import-keyfile(import-keyfile-input, import-pass-input); } }
|
||||
if root.active-tab == "identity" : IdentitySettings {
|
||||
own-avatar: root.own-avatar;
|
||||
has-avatar: root.has-avatar;
|
||||
avatar-error: root.avatar-error;
|
||||
choose-avatar => { root.choose-avatar(); }
|
||||
remove-avatar => { root.remove-avatar(); }
|
||||
identity-pubkey: root.identity-pubkey;
|
||||
vault-enabled: root.vault-enabled;
|
||||
passphrase-modal-open <=> root.passphrase-modal-open;
|
||||
passphrase-input <=> root.passphrase-input;
|
||||
passphrase-confirm <=> root.passphrase-confirm;
|
||||
passphrase-error: root.passphrase-error;
|
||||
export-modal-open <=> root.export-modal-open;
|
||||
export-pass-input <=> root.export-pass-input;
|
||||
export-pass-confirm <=> root.export-pass-confirm;
|
||||
export-output: root.export-output;
|
||||
export-error: root.export-error;
|
||||
import-modal-open <=> root.import-modal-open;
|
||||
import-keyfile-input <=> root.import-keyfile-input;
|
||||
import-pass-input <=> root.import-pass-input;
|
||||
import-error: root.import-error;
|
||||
set-passphrase(pass, confirm) => { root.set-passphrase(pass, confirm); }
|
||||
remove-passphrase => { root.remove-passphrase(); }
|
||||
export-keyfile(pass, confirm) => { root.export-keyfile(pass, confirm); }
|
||||
import-keyfile(input, pass) => { root.import-keyfile(input, pass); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
110
src/ui/slint/settings/appearance.slint
Normal file
110
src/ui/slint/settings/appearance.slint
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
import { Theme, ActionButton } from "../theme.slint";
|
||||
import { AudioSlider, ThemeInput, ThemeEditor } from "../controls.slint";
|
||||
|
||||
component ThemeChoice inherits Rectangle {
|
||||
in property <string> label;
|
||||
in property <bool> selected;
|
||||
in property <color> preview-background;
|
||||
in property <color> preview-sidebar;
|
||||
in property <color> preview-ink;
|
||||
callback clicked();
|
||||
height: 142px;
|
||||
border-radius: 9px;
|
||||
border-width: keyboard.has-focus || root.selected ? 2px : 1px;
|
||||
border-color: root.selected || keyboard.has-focus ? Theme.accent : Theme.border;
|
||||
background: pointer.has-hover ? Theme.bg-hover : Theme.bg-surface;
|
||||
accessible-role: button;
|
||||
accessible-label: root.label;
|
||||
VerticalLayout {
|
||||
padding: 8px; spacing: 10px;
|
||||
Rectangle {
|
||||
height: 86px; background: root.preview-background; border-radius: 5px; clip: true;
|
||||
Rectangle { width: 23%; height: 100%; background: root.preview-sidebar; }
|
||||
Rectangle { x: parent.width * 0.29; y: 15px; width: 41%; height: 6px; background: root.preview-ink; opacity: 0.8; border-radius: 2px; }
|
||||
Rectangle { x: parent.width * 0.29; y: 29px; width: 59%; height: 4px; background: root.preview-ink; opacity: 0.28; border-radius: 2px; }
|
||||
Rectangle { x: parent.width * 0.29; y: 40px; width: 45%; height: 4px; background: root.preview-ink; opacity: 0.28; border-radius: 2px; }
|
||||
Rectangle { x: parent.width * 0.29; y: 61px; width: 60%; height: 13px; background: root.preview-sidebar; border-radius: 3px; }
|
||||
}
|
||||
HorizontalLayout {
|
||||
Text { text: root.label; color: Theme.text-primary; font-size: Math.max(Theme.font-size - 3px, 11px); font-weight: 500; overflow: elide; horizontal-stretch: 1; }
|
||||
Text { text: root.selected ? "✓" : ""; color: Theme.accent; width: 16px; font-size: Math.max(Theme.font-size - 2px, 11px); }
|
||||
}
|
||||
}
|
||||
pointer := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
|
||||
keyboard := FocusScope { key-pressed(event) => { if event.text == " " || event.text == "\n" { root.clicked(); return accept; } return reject; } }
|
||||
}
|
||||
|
||||
export component AppearanceSettings inherits Rectangle {
|
||||
in-out property <string> theme-mode;
|
||||
in-out property <string> theme-css;
|
||||
in-out property <string> theme-file-path;
|
||||
in-out property <float> text-size;
|
||||
in property <string> theme-error;
|
||||
in property <string> theme-status;
|
||||
in property <bool> theme-preview;
|
||||
callback theme-selected(string);
|
||||
callback text-size-changed(float);
|
||||
callback preview-theme(string);
|
||||
callback apply-theme(string);
|
||||
callback reset-theme();
|
||||
callback import-theme(string);
|
||||
callback export-theme(string);
|
||||
VerticalLayout {
|
||||
spacing: 0; alignment: start;
|
||||
Text { text: "Тема приложения"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; }
|
||||
Text { text: "Один выбор для чата, комнат и настроек. Можно изменить в любой момент."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 20px; }
|
||||
HorizontalLayout {
|
||||
spacing: 12px;
|
||||
ThemeChoice { label: "Светлая"; selected: root.theme-mode == "light"; preview-background: #f5f4f2; preview-sidebar: #e6e4e0; preview-ink: #353330; clicked => { root.theme-selected("light"); } }
|
||||
ThemeChoice { label: "Тёмная"; selected: root.theme-mode == "dark"; preview-background: #272729; preview-sidebar: #202022; preview-ink: #e9e7e4; clicked => { root.theme-selected("dark"); } }
|
||||
ThemeChoice { label: "Мега-тёмная"; selected: root.theme-mode == "black"; preview-background: #080808; preview-sidebar: #131313; preview-ink: #dedbd5; clicked => { root.theme-selected("black"); } }
|
||||
ThemeChoice { label: "Своя тема"; selected: root.theme-mode == "custom"; preview-background: Theme.bg-base; preview-sidebar: Theme.bg-surface; preview-ink: Theme.accent; clicked => { root.theme-selected("custom"); } }
|
||||
}
|
||||
Rectangle { height: 29px; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 24px; }
|
||||
HorizontalLayout {
|
||||
Text { text: "Размер текста"; color: Theme.text-primary; font-size: Theme.font-size - 1px; font-weight: 600; horizontal-stretch: 1; }
|
||||
Text { text: Math.round(root.text-size) + " px"; color: Theme.text-secondary; font-size: Math.max(Theme.font-size - 2px, 11px); horizontal-alignment: right; }
|
||||
}
|
||||
Rectangle { height: 9px; }
|
||||
AudioSlider { minimum: 12; maximum: 22; value <=> root.text-size; changed(value) => { root.text-size-changed(value); } }
|
||||
Text { text: "Меняет масштаб текста во всём приложении."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 29px; }
|
||||
if root.theme-mode == "custom" : VerticalLayout {
|
||||
spacing: 12px; alignment: start;
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 8px; }
|
||||
HorizontalLayout {
|
||||
Text { text: "Редактор темы"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; horizontal-stretch: 1; }
|
||||
if root.theme-preview : Text { text: "Предпросмотр"; color: Theme.accent; font-size: Math.max(Theme.font-size - 3px, 11px); }
|
||||
}
|
||||
Text { text: "CSS-переменные в блоке :root меняют цвета и размер текста. Обычные CSS-селекторы, стили размещения и внешние ресурсы не поддерживаются."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
ThemeEditor { text <=> root.theme-css; height: 220px; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Предпросмотр"; clicked => { root.preview-theme(root.theme-css); } }
|
||||
ActionButton { text: "Применить"; active: true; clicked => { root.apply-theme(root.theme-css); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: "Сбросить"; quiet: true; clicked => { root.reset-theme(); } }
|
||||
}
|
||||
Text { text: "Основные переменные: --vnox-bg, --vnox-surface, --vnox-text, --vnox-accent, --vnox-font-size. Полный список описан в документации тем."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 4px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 8px; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 8px; }
|
||||
Text { text: "Файл темы"; color: Theme.text-primary; font-size: Theme.font-size - 1px; font-weight: 600; }
|
||||
Text { text: "Введи локальный путь к .css, чтобы импортировать тему или сохранить её в файл."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
ThemeInput { text <=> root.theme-file-path; placeholder-text: "Например: /home/user/themes/my-vnox.css"; accepted => { root.import-theme(root.theme-file-path); } }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Импортировать"; clicked => { root.import-theme(root.theme-file-path); } }
|
||||
ActionButton { text: "Экспортировать"; clicked => { root.export-theme(root.theme-file-path); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
if root.theme-error != "" : Text { text: root.theme-error; color: Theme.danger; font-size: Math.max(Theme.font-size - 2px, 11px); wrap: word-wrap; }
|
||||
if root.theme-status != "" : Text { text: root.theme-status; color: Theme.success; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 26px; }
|
||||
}
|
||||
}
|
||||
71
src/ui/slint/settings/audio.slint
Normal file
71
src/ui/slint/settings/audio.slint
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
import { Theme } from "../theme.slint";
|
||||
import { DeviceSelect, AudioSlider } from "../controls.slint";
|
||||
|
||||
export component AudioSettings inherits Rectangle {
|
||||
in property <[string]> input-devices;
|
||||
in property <[string]> output-devices;
|
||||
in-out property <int> input-device-index;
|
||||
in-out property <int> output-device-index;
|
||||
in-out property <float> voice-bitrate;
|
||||
in-out property <int> vad-mode;
|
||||
in-out property <float> volume;
|
||||
callback audio-changed();
|
||||
VerticalLayout {
|
||||
spacing: 0;
|
||||
alignment: start;
|
||||
Text { text: "Устройства"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; }
|
||||
Text { text: "Выбери, откуда брать голос и куда выводить звук."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 24px; }
|
||||
Text { text: "Микрофон"; color: Theme.text-primary; font-size: Math.max(Theme.font-size - 2px, 11px); }
|
||||
Rectangle { height: 9px; }
|
||||
DeviceSelect {
|
||||
model: root.input-devices;
|
||||
current-index <=> root.input-device-index;
|
||||
selected(value) => { root.audio-changed(); }
|
||||
}
|
||||
Rectangle { height: 19px; }
|
||||
Text { text: "Наушники или колонки"; color: Theme.text-primary; font-size: Math.max(Theme.font-size - 2px, 11px); }
|
||||
Rectangle { height: 9px; }
|
||||
DeviceSelect {
|
||||
model: root.output-devices;
|
||||
current-index <=> root.output-device-index;
|
||||
selected(value) => { root.audio-changed(); }
|
||||
}
|
||||
Rectangle { height: 29px; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 26px; }
|
||||
HorizontalLayout {
|
||||
spacing: 20px;
|
||||
Text { text: "Громкость"; color: Theme.text-primary; font-size: Theme.font-size - 1px; font-weight: 600; horizontal-stretch: 1; }
|
||||
Text { text: Math.round(root.volume) + "%"; color: Theme.text-secondary; font-size: Math.max(Theme.font-size - 2px, 11px); horizontal-alignment: right; }
|
||||
}
|
||||
Text { text: "Общий уровень воспроизведения голосовых комнат."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 10px; }
|
||||
AudioSlider { minimum: 0; maximum: 100; value <=> root.volume; changed(value) => { root.audio-changed(); } }
|
||||
Rectangle { height: 25px; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 26px; }
|
||||
Text { text: "Передача голоса"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; }
|
||||
Text { text: "Определи, когда тебя слышат остальные."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 18px; }
|
||||
DeviceSelect {
|
||||
model: ["Нажми и говори", "Активация голосом", "Открытый микрофон"];
|
||||
current-index <=> root.vad-mode;
|
||||
selected(value) => { root.audio-changed(); }
|
||||
}
|
||||
Rectangle { height: 10px; }
|
||||
Text {
|
||||
text: root.vad-mode == 0 ? "Удерживай кнопку разговора в голосовой комнате. Отпусти — микрофон перестанет передавать звук." : root.vad-mode == 1 ? "Микрофон передаёт звук, когда обнаружен голос." : "Звук передаётся постоянно, пока микрофон включён.";
|
||||
color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap;
|
||||
}
|
||||
Rectangle { height: 24px; }
|
||||
HorizontalLayout {
|
||||
Text { text: "Качество голоса"; color: Theme.text-primary; font-size: Theme.font-size - 1px; font-weight: 600; horizontal-stretch: 1; }
|
||||
Text { text: Math.round(root.voice-bitrate) + " кбит/с"; color: Theme.text-secondary; font-size: Math.max(Theme.font-size - 2px, 11px); horizontal-alignment: right; }
|
||||
}
|
||||
Rectangle { height: 9px; }
|
||||
AudioSlider { minimum: 8; maximum: 128; value <=> root.voice-bitrate; changed(value) => { root.audio-changed(); } }
|
||||
Text { text: "Меньше трафика"; color: Theme.text-disabled; font-size: Math.max(Theme.font-size - 4px, 11px); }
|
||||
Rectangle { height: 26px; }
|
||||
}
|
||||
}
|
||||
147
src/ui/slint/settings/identity.slint
Normal file
147
src/ui/slint/settings/identity.slint
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
import { AvatarView } from "../avatar-view.slint";
|
||||
import { Theme, ActionButton } from "../theme.slint";
|
||||
import { ThemeInput, ThemeEditor } from "../controls.slint";
|
||||
|
||||
export component IdentitySettings inherits Rectangle {
|
||||
in property <image> own-avatar;
|
||||
in property <bool> has-avatar;
|
||||
in property <string> avatar-error;
|
||||
callback choose-avatar();
|
||||
callback remove-avatar();
|
||||
in-out property <string> identity-pubkey;
|
||||
in-out property <bool> vault-enabled;
|
||||
in-out property <bool> passphrase-modal-open;
|
||||
in-out property <string> passphrase-input;
|
||||
in-out property <string> passphrase-confirm;
|
||||
in-out property <string> passphrase-error;
|
||||
in-out property <bool> export-modal-open;
|
||||
in-out property <string> export-pass-input;
|
||||
in-out property <string> export-pass-confirm;
|
||||
in-out property <string> export-output;
|
||||
in-out property <string> export-error;
|
||||
in-out property <bool> import-modal-open;
|
||||
in-out property <string> import-keyfile-input;
|
||||
in-out property <string> import-pass-input;
|
||||
in-out property <string> import-error;
|
||||
private property <bool> confirm-remove;
|
||||
callback set-passphrase(string, string);
|
||||
callback remove-passphrase();
|
||||
callback export-keyfile(string, string);
|
||||
callback import-keyfile(string, string);
|
||||
VerticalLayout {
|
||||
spacing: 0; alignment: start;
|
||||
Text { text: "Фото профиля"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; }
|
||||
Text { text: "Выбери изображение и обрежь его под аватар."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 18px; }
|
||||
HorizontalLayout {
|
||||
spacing: 20px;
|
||||
AvatarView { width: 82px; height: 82px; source: root.own-avatar; has-source: root.has-avatar; initials: "Фото"; mask: Theme.bg-base; }
|
||||
VerticalLayout {
|
||||
spacing: 9px; alignment: center;
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: root.has-avatar ? "Изменить фото" : "Выбрать фото"; clicked => { root.choose-avatar(); } }
|
||||
if root.has-avatar : ActionButton { text: "Удалить"; quiet: true; danger: true; clicked => { root.remove-avatar(); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
Text { text: "Пока хранится только на этом устройстве."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 4px, 11px); wrap: word-wrap; }
|
||||
}
|
||||
}
|
||||
Rectangle { height: 26px; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 24px; }
|
||||
Text { text: "Твой ключ"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; }
|
||||
Text { text: "Открытый ключ определяет твой профиль. Им можно поделиться; секретный ключ остаётся на устройстве."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 16px; }
|
||||
ThemeEditor { text: root.identity-pubkey; read-only: true; height: 78px; }
|
||||
if root.avatar-error != "" : Text { text: root.avatar-error; color: Theme.danger; font-size: Math.max(11px, Theme.font-size - 3px); wrap: word-wrap; }
|
||||
Rectangle { height: 28px; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 24px; }
|
||||
HorizontalLayout {
|
||||
Text { text: "Защита на устройстве"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; horizontal-stretch: 1; }
|
||||
Text { text: root.vault-enabled ? "● Защищено паролем" : "Без пароля"; color: root.vault-enabled ? Theme.success : Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); vertical-alignment: center; }
|
||||
}
|
||||
Rectangle { height: 6px; }
|
||||
Text { text: root.vault-enabled ? "При запуске Vnox потребуется пароль для доступа к ключам." : "Добавь пароль, чтобы зашифровать сохранённый секретный ключ."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 15px; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton {
|
||||
text: root.vault-enabled ? "Изменить пароль" : "Добавить пароль";
|
||||
clicked => { root.passphrase-modal-open = !root.passphrase-modal-open; root.export-modal-open = false; root.import-modal-open = false; }
|
||||
}
|
||||
if root.vault-enabled : ActionButton { text: "Убрать пароль"; danger: true; quiet: true; clicked => { root.confirm-remove = true; } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
if root.confirm-remove : VerticalLayout {
|
||||
spacing: 10px; alignment: start;
|
||||
Text { text: "Ключ будет сохранён без шифрования. Убрать пароль?"; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Отмена"; quiet: true; clicked => { root.confirm-remove = false; } }
|
||||
ActionButton { text: "Убрать пароль"; danger: true; clicked => { root.remove-passphrase(); root.confirm-remove = false; } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
if root.passphrase-modal-open : VerticalLayout {
|
||||
spacing: 10px; alignment: start;
|
||||
Rectangle { height: 8px; }
|
||||
ThemeInput { input-type: InputType.password; text <=> root.passphrase-input; placeholder-text: "Новый пароль · минимум 8 символов"; }
|
||||
ThemeInput { input-type: InputType.password; text <=> root.passphrase-confirm; placeholder-text: "Повтори пароль"; accepted => { root.set-passphrase(root.passphrase-input, root.passphrase-confirm); } }
|
||||
if root.passphrase-error != "" : Text { text: root.passphrase-error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Сохранить пароль"; active: true; clicked => { root.set-passphrase(root.passphrase-input, root.passphrase-confirm); } }
|
||||
ActionButton { text: "Свернуть"; quiet: true; clicked => { root.passphrase-modal-open = false; } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
Rectangle { height: 28px; }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
Rectangle { height: 24px; }
|
||||
Text { text: "Резервная копия"; color: Theme.text-primary; font-size: Theme.font-size + 2px; font-weight: 600; }
|
||||
Text { text: "Сохрани ключи в безопасном месте, чтобы восстановить профиль на другом устройстве."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
Rectangle { height: 15px; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Экспортировать ключи"; clicked => { root.export-modal-open = !root.export-modal-open; root.passphrase-modal-open = false; root.import-modal-open = false; } }
|
||||
ActionButton { text: "Импортировать"; quiet: true; clicked => { root.import-modal-open = !root.import-modal-open; root.passphrase-modal-open = false; root.export-modal-open = false; } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
if root.export-modal-open : VerticalLayout {
|
||||
spacing: 10px; alignment: start;
|
||||
Rectangle { height: 8px; }
|
||||
Text { text: "Пароль резервной копии можно оставить пустым. Такая копия содержит секретный ключ без защиты."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
ThemeInput { input-type: InputType.password; text <=> root.export-pass-input; placeholder-text: "Пароль копии · необязательно"; }
|
||||
ThemeInput { input-type: InputType.password; text <=> root.export-pass-confirm; placeholder-text: "Повтори пароль копии"; }
|
||||
if root.export-error != "" : Text { text: root.export-error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Создать копию"; active: true; clicked => { root.export-keyfile(root.export-pass-input, root.export-pass-confirm); } }
|
||||
ActionButton { text: "Свернуть"; quiet: true; clicked => { root.export-modal-open = false; } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
if root.export-output != "" : VerticalLayout {
|
||||
spacing: 8px;
|
||||
Text { text: "Скопируй содержимое в файл и сохрани отдельно от устройства."; color: Theme.text-muted; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
ThemeEditor { text: root.export-output; read-only: true; height: 180px; }
|
||||
}
|
||||
}
|
||||
if root.import-modal-open : VerticalLayout {
|
||||
spacing: 10px; alignment: start;
|
||||
Rectangle { height: 8px; }
|
||||
Text { text: "Импорт заменит сохранённый профиль. Сначала сделай резервную копию текущих ключей."; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
ThemeEditor { text <=> root.import-keyfile-input; height: 150px; }
|
||||
ThemeInput { input-type: InputType.password; text <=> root.import-pass-input; placeholder-text: "Пароль резервной копии, если он задан"; }
|
||||
if root.import-error != "" : Text { text: root.import-error; color: Theme.danger; font-size: Math.max(Theme.font-size - 3px, 11px); wrap: word-wrap; }
|
||||
HorizontalLayout {
|
||||
spacing: 9px;
|
||||
ActionButton { text: "Импортировать и заменить"; danger: true; clicked => { root.import-keyfile(root.import-keyfile-input, root.import-pass-input); } }
|
||||
ActionButton { text: "Свернуть"; quiet: true; clicked => { root.import-modal-open = false; } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
Rectangle { height: 28px; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,243 +1,160 @@
|
|||
import { Theme } from "theme.slint";
|
||||
import { AvatarView } from "avatar-view.slint";
|
||||
import { Theme, ActionButton } from "theme.slint";
|
||||
|
||||
export struct ChannelItem {
|
||||
channel_id: string,
|
||||
name: string,
|
||||
kind: string,
|
||||
}
|
||||
export struct ChannelItem { channel_id: string, name: string, kind: string }
|
||||
export struct GuildItem { guild_id: string, name: string, short_name: string, selected: bool }
|
||||
export struct DmItem { dm_id: string, name: string, unread: int }
|
||||
|
||||
export struct GuildItem {
|
||||
guild_id: string,
|
||||
name: string,
|
||||
short_name: string,
|
||||
selected: bool,
|
||||
}
|
||||
|
||||
component GuildBar {
|
||||
in-out property <[GuildItem]> guilds;
|
||||
in-out property <int> active-guild-idx;
|
||||
|
||||
callback guild-selected(int);
|
||||
|
||||
width: 56px;
|
||||
height: 100%;
|
||||
|
||||
Rectangle {
|
||||
background: #111118;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
|
||||
VerticalLayout {
|
||||
padding: 8px;
|
||||
spacing: 4px;
|
||||
alignment: start;
|
||||
|
||||
Rectangle {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: active-guild-idx == -1 ? 12px : 20px;
|
||||
background: active-guild-idx == -1 ? Theme.accent : Theme.bg-surface;
|
||||
TouchArea {
|
||||
clicked => { guild-selected(-1); }
|
||||
}
|
||||
Text {
|
||||
text: "@";
|
||||
color: Theme.text-primary;
|
||||
font-size: 18px;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
height: 2px;
|
||||
width: 32px;
|
||||
background: Theme.bg-elevated;
|
||||
border-radius: 1px;
|
||||
x: 12px;
|
||||
}
|
||||
|
||||
for g[idx] in guilds: Rectangle {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
border-radius: g.selected ? 12px : 20px;
|
||||
background: g.selected ? Theme.accent : Theme.bg-elevated;
|
||||
TouchArea {
|
||||
clicked => { guild-selected(idx); }
|
||||
}
|
||||
Text {
|
||||
text: g.short_name;
|
||||
color: Theme.text-primary;
|
||||
font-size: 14px;
|
||||
font-weight: 700;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
component NavRow inherits Rectangle {
|
||||
in property <string> label;
|
||||
in property <string> symbol: "#";
|
||||
in property <bool> selected;
|
||||
in property <int> unread;
|
||||
callback clicked();
|
||||
height: root.visible ? 36px : 0px;
|
||||
border-radius: 6px;
|
||||
background: selected ? Theme.selected : touch.has-hover ? Theme.bg-hover : transparent;
|
||||
border-width: keyboard.has-focus ? 1px : 0px;
|
||||
border-color: Theme.accent;
|
||||
accessible-role: button;
|
||||
accessible-label: label;
|
||||
HorizontalLayout {
|
||||
padding-left: 10px; padding-right: 10px; spacing: 10px;
|
||||
Text { text: root.symbol; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 1.125); width: 20px; }
|
||||
Text { text: root.label; color: root.selected || root.unread > 0 ? Theme.text-primary : Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-stretch: 1; overflow: elide; }
|
||||
if root.unread > 0 : Text { text: root.unread; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
}
|
||||
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
|
||||
keyboard := FocusScope {
|
||||
key-pressed(event) => {
|
||||
if event.text == " " || event.text == "\n" { root.clicked(); return accept; }
|
||||
return reject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component ChannelList {
|
||||
in-out property <[ChannelItem]> channels;
|
||||
in-out property <string> active-channel-id;
|
||||
in-out property <string> section-title;
|
||||
|
||||
callback channel-selected(string);
|
||||
|
||||
VerticalLayout {
|
||||
Rectangle {
|
||||
height: 48px;
|
||||
background: Theme.bg-surface;
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
Text { text: section-title; color: Theme.text-primary; font-size: 15px; font-weight: 600; }
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
VerticalLayout {
|
||||
for item in channels: Rectangle {
|
||||
height: 36px;
|
||||
background: item.channel_id == active-channel-id ? Theme.bg-elevated : Theme.bg-base;
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
spacing: 6px;
|
||||
Text {
|
||||
text: item.kind == "voice" ? "🔊 " : "# ";
|
||||
color: Theme.text-secondary;
|
||||
font-size: 14px;
|
||||
}
|
||||
Text {
|
||||
text: item.name;
|
||||
color: item.channel_id == active-channel-id ? Theme.text-primary : Theme.text-secondary;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
TouchArea {
|
||||
clicked => { channel-selected(item.channel_id); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
component DmList {
|
||||
in-out property <[string]> dm-conversations;
|
||||
|
||||
callback dm-selected(string);
|
||||
|
||||
VerticalLayout {
|
||||
Rectangle {
|
||||
height: 48px;
|
||||
background: Theme.bg-surface;
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
Text { text: "Direct Messages"; color: Theme.text-primary; font-size: 15px; font-weight: 600; }
|
||||
}
|
||||
}
|
||||
|
||||
Flickable {
|
||||
VerticalLayout {
|
||||
for dm in dm-conversations: Rectangle {
|
||||
height: 36px;
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
spacing: 6px;
|
||||
Text { text: "@"; color: Theme.text-secondary; font-size: 14px; }
|
||||
Text { text: dm; color: Theme.text-secondary; font-size: 14px; }
|
||||
}
|
||||
TouchArea {
|
||||
clicked => { dm-selected(dm); }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export component Sidebar {
|
||||
export component Sidebar inherits Rectangle {
|
||||
in-out property <[GuildItem]> guilds;
|
||||
in-out property <[ChannelItem]> channels;
|
||||
in-out property <[string]> dm-conversations;
|
||||
in-out property <[DmItem]> dm-conversations;
|
||||
in property <image> own-avatar;
|
||||
in property <bool> has-avatar;
|
||||
in-out property <string> username;
|
||||
in-out property <string> user-status;
|
||||
in-out property <string> active-channel-id;
|
||||
in-out property <string> active-dm-id;
|
||||
in-out property <int> active-guild-idx;
|
||||
in-out property <bool> show-dms;
|
||||
|
||||
in-out property <bool> voice-connected;
|
||||
in-out property <string> voice-channel-name;
|
||||
in-out property <bool> mic-enabled;
|
||||
in-out property <bool> deafened;
|
||||
in-out property <string> node-name;
|
||||
callback channel-selected(string);
|
||||
callback guild-selected(int);
|
||||
callback dm-selected(string);
|
||||
callback disconnect();
|
||||
|
||||
width: 296px;
|
||||
height: 100%;
|
||||
|
||||
callback open-settings();
|
||||
callback toggle-mic();
|
||||
callback toggle-deafen();
|
||||
callback leave-voice();
|
||||
callback show-voice();
|
||||
callback show-friends();
|
||||
width: 332px;
|
||||
background: Theme.bg-surface;
|
||||
HorizontalLayout {
|
||||
spacing: 0;
|
||||
|
||||
GuildBar {
|
||||
guilds: root.guilds;
|
||||
active-guild-idx: root.active-guild-idx;
|
||||
guild-selected(idx) => { root.guild-selected(idx); }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
width: 240px;
|
||||
height: 100%;
|
||||
background: Theme.bg-base;
|
||||
|
||||
width: 64px;
|
||||
background: Theme.bg-rail;
|
||||
VerticalLayout {
|
||||
padding: 9px; spacing: 11px;
|
||||
ActionButton { text: "Личные сообщения"; icon: "home"; height: 44px; text-size: 20px; active: root.show-dms; clicked => { root.show-friends(); } }
|
||||
Rectangle { height: 1px; background: Theme.border; }
|
||||
ActionButton { text: "V"; height: 44px; text-size: 19px; active: !root.show-dms && root.active-guild-idx < 0; clicked => { root.guild-selected(-1); } }
|
||||
for guild[index] in root.guilds: ActionButton {
|
||||
height: 44px;
|
||||
text: guild.short_name;
|
||||
active: guild.selected && !root.show-dms;
|
||||
clicked => { root.guild-selected(index); }
|
||||
}
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
ActionButton { text: "Настройки"; icon: "settings"; quiet: true; text-size: 19px; clicked => { root.open-settings(); } }
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
horizontal-stretch: 1;
|
||||
VerticalLayout {
|
||||
spacing: 0;
|
||||
|
||||
if root.show-dms : DmList {
|
||||
dm-conversations: root.dm-conversations;
|
||||
dm-selected(id) => { root.dm-selected(id); }
|
||||
}
|
||||
if !root.show-dms : ChannelList {
|
||||
channels: root.channels;
|
||||
active-channel-id: root.active-channel-id;
|
||||
section-title: root.active-guild-idx >= 0 && root.active-guild-idx < root.guilds.length ? root.guilds[root.active-guild-idx].name : "Channels";
|
||||
channel-selected(id) => { root.channel-selected(id); }
|
||||
}
|
||||
|
||||
Rectangle {
|
||||
height: 52px;
|
||||
background: Theme.bg-surface;
|
||||
height: 56px;
|
||||
border-width: 1px; border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
spacing: 8px;
|
||||
Rectangle {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
border-radius: 16px;
|
||||
background: Theme.bg-elevated;
|
||||
padding-left: 17px; padding-right: 10px; spacing: 8px;
|
||||
Text { text: root.show-dms ? "Личные сообщения" : root.active-guild-idx >= 0 && root.active-guild-idx < root.guilds.length ? root.guilds[root.active-guild-idx].name : root.node-name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; overflow: elide; horizontal-stretch: 1; vertical-alignment: center; }
|
||||
ActionButton { text: "Отключиться"; icon: "power"; width: 30px; quiet: true; clicked => { root.disconnect(); } }
|
||||
}
|
||||
}
|
||||
Flickable {
|
||||
content-width: self.width;
|
||||
VerticalLayout {
|
||||
padding: 10px; spacing: 3px;
|
||||
if root.show-dms : NavRow { label: "Друзья"; symbol: "@"; clicked => { root.show-friends(); } }
|
||||
if root.show-dms : Text { text: "Личные сообщения"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 32px; vertical-alignment: bottom; }
|
||||
if root.show-dms && root.dm-conversations.length == 0 : Text { text: "Открой профиль друга, чтобы написать ему."; wrap: word-wrap; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
for dm in root.dm-conversations: NavRow {
|
||||
visible: root.show-dms;
|
||||
label: dm.name; symbol: "@"; unread: dm.unread;
|
||||
selected: root.active-dm-id == dm.dm_id;
|
||||
clicked => { root.dm-selected(dm.dm_id); }
|
||||
}
|
||||
VerticalLayout {
|
||||
spacing: 2px;
|
||||
Text { text: root.username; color: Theme.text-primary; font-size: 14px; font-weight: 600; }
|
||||
Text { text: root.user-status; color: Theme.text-muted; font-size: 11px; }
|
||||
if !root.show-dms : Text { text: "Текстовые каналы"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 32px; vertical-alignment: bottom; }
|
||||
for ch in root.channels: NavRow {
|
||||
visible: !root.show-dms && ch.kind != "voice";
|
||||
label: ch.name;
|
||||
selected: root.active-channel-id == ch.channel_id;
|
||||
clicked => { root.channel-selected(ch.channel_id); }
|
||||
}
|
||||
if !root.show-dms : Text { text: "Голосовые комнаты"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); height: 40px; vertical-alignment: bottom; }
|
||||
for ch in root.channels: NavRow {
|
||||
visible: !root.show-dms && ch.kind == "voice";
|
||||
label: ch.name; symbol: "◖";
|
||||
selected: root.voice-connected && root.voice-channel-name == ch.name;
|
||||
clicked => { root.channel-selected(ch.channel_id); }
|
||||
}
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
}
|
||||
}
|
||||
if root.voice-connected : Rectangle {
|
||||
height: 88px;
|
||||
background: Theme.voice-bg;
|
||||
border-radius: 8px;
|
||||
border-width: 1px; border-color: Theme.border;
|
||||
VerticalLayout {
|
||||
padding: 10px; spacing: 5px;
|
||||
Text { text: "● Голос подключён"; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); font-weight: 600; }
|
||||
Text { text: root.voice-channel-name; color: Theme.text-secondary; font-size: Math.max(11px, Theme.font-size * 0.6875); overflow: elide; }
|
||||
HorizontalLayout {
|
||||
horizontal-stretch: 1;
|
||||
spacing: 6px;
|
||||
ActionButton { text: "Открыть"; clicked => { root.show-voice(); } }
|
||||
ActionButton { text: "Выйти"; danger: true; clicked => { root.leave-voice(); } }
|
||||
}
|
||||
Rectangle {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
border-radius: 6px;
|
||||
background: Theme.bg-interactive;
|
||||
TouchArea {
|
||||
clicked => { root.disconnect(); }
|
||||
}
|
||||
Text { text: "⏻"; color: Theme.text-muted; font-size: 14px; horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
height: 66px;
|
||||
background: Theme.bg-elevated;
|
||||
HorizontalLayout {
|
||||
padding: 9px; spacing: 5px;
|
||||
AvatarView { width: 30px; height: 30px; source: root.own-avatar; has-source: root.has-avatar; initials: "●"; mask: Theme.bg-elevated; }
|
||||
VerticalLayout {
|
||||
spacing: 1px; horizontal-stretch: 1;
|
||||
Text { text: root.username; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.8125); font-weight: 600; overflow: elide; }
|
||||
Text { text: root.user-status; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.625); overflow: elide; }
|
||||
}
|
||||
ActionButton { text: root.mic-enabled ? "Выключить микрофон" : "Включить микрофон"; icon: "mic"; width: 30px; danger: !root.mic-enabled; quiet: true; clicked => { root.toggle-mic(); } }
|
||||
ActionButton { text: root.deafened ? "Включить звук" : "Выключить звук"; icon: "headphones"; width: 30px; danger: root.deafened; quiet: true; clicked => { root.toggle-deafen(); } }
|
||||
ActionButton { text: "Настройки"; icon: "settings"; width: 30px; quiet: true; clicked => { root.open-settings(); } }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,70 @@
|
|||
export global Theme {
|
||||
in-out property <color> bg-base: #181825;
|
||||
in-out property <color> bg-surface: #1e1e2e;
|
||||
in-out property <color> bg-hover: #2a2a3e;
|
||||
in-out property <color> bg-elevated: #2a2a3e;
|
||||
in-out property <color> bg-interactive: #313244;
|
||||
in-out property <color> accent: #E67E22;
|
||||
in-out property <color> text-primary: #cdd6f4;
|
||||
in-out property <color> text-secondary: #a0a4b8;
|
||||
in-out property <color> text-muted: #6c7086;
|
||||
in-out property <color> text-disabled: #45475a;
|
||||
in-out property <color> danger: #f38ba8;
|
||||
in-out property <color> success: #a6e3a1;
|
||||
in-out property <length> radius: 8px;
|
||||
in-out property <color> bg-base: #272729;
|
||||
in-out property <color> bg-surface: #202022;
|
||||
in-out property <color> bg-rail: #151516;
|
||||
in-out property <color> bg-hover: #38383c;
|
||||
in-out property <color> bg-elevated: #303033;
|
||||
in-out property <color> bg-interactive: #343336;
|
||||
in-out property <color> selected: #3a393c;
|
||||
in-out property <color> border: #ffffff12;
|
||||
in-out property <color> accent: #d5b58a;
|
||||
in-out property <color> text-primary: #e9e7e4;
|
||||
in-out property <color> text-secondary: #b8b4b1;
|
||||
in-out property <color> text-muted: #aaa29b;
|
||||
in-out property <color> text-disabled: #85817f;
|
||||
in-out property <color> danger: #e58b85;
|
||||
in-out property <color> success: #a8c1a4;
|
||||
in-out property <length> font-size: 16px;
|
||||
out property <float> scale: font-size / 16px;
|
||||
in-out property <color> on-accent: #29221b;
|
||||
in-out property <color> avatar-bg: #49433d;
|
||||
in-out property <color> voice-bg: #282c28;
|
||||
in-out property <color> overlay: #00000080;
|
||||
in-out property <length> radius: 7px;
|
||||
}
|
||||
|
||||
export component Symbol inherits Rectangle {
|
||||
in property <string> kind;
|
||||
in property <color> ink: Theme.text-secondary;
|
||||
if kind == "mic" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M9 11V5 A3 3 0 0 1 15 5 V11 A3 3 0 0 1 9 11 M5 10V12 A7 7 0 0 0 19 12 V10 M12 19V22 M8 22H16"; }
|
||||
if kind == "headphones" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M3 14V11 A9 9 0 0 1 21 11 V14 M3 13H7V21H3Z M17 13H21V21H17Z"; }
|
||||
if kind == "settings" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M9 3L8 6L5 7L3 10L5 12L4 15L7 17L10 16L12 18L15 16V13L17 11L16 8L13 7L12 3Z M14 11 A3 3 0 1 1 8 11 A3 3 0 1 1 14 11"; }
|
||||
if kind == "power" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M12 2V12 M6 5 A9 9 0 1 0 18 5"; }
|
||||
if kind == "home" : Path { width: parent.width; height: parent.height; viewbox-width: 24; viewbox-height: 24; fill: transparent; stroke: root.ink; stroke-width: 1.7px; commands: "M2 10L12 2L22 10V22H2Z M9 22V13H15V22"; }
|
||||
}
|
||||
|
||||
export component ActionButton inherits Rectangle {
|
||||
in property <string> text;
|
||||
in property <string> icon;
|
||||
in property <bool> active: false;
|
||||
in property <bool> danger: false;
|
||||
in property <bool> quiet: false;
|
||||
in property <length> text-size: 13px;
|
||||
callback clicked();
|
||||
min-width: 30px;
|
||||
preferred-width: icon == "" ? label.preferred-width + 22px : 32px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
background: active ? Theme.selected : touch.has-hover ? Theme.bg-hover : quiet ? transparent : Theme.bg-interactive;
|
||||
border-width: keyboard.has-focus ? 1px : 0px;
|
||||
border-color: Theme.accent;
|
||||
accessible-role: button;
|
||||
accessible-label: text;
|
||||
Symbol { visible: root.icon != ""; kind: root.icon; ink: root.danger ? Theme.danger : Theme.text-secondary; width: 18px; height: 18px; x: (parent.width - self.width) / 2; y: (parent.height - self.height) / 2; }
|
||||
label := Text {
|
||||
visible: root.icon == "";
|
||||
text: root.text;
|
||||
color: root.danger ? Theme.danger : root.active ? Theme.text-primary : Theme.text-secondary;
|
||||
font-size: Math.max(11px, root.text-size * Theme.scale);
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
overflow: elide;
|
||||
}
|
||||
touch := TouchArea { clicked => { keyboard.focus(); root.clicked(); } }
|
||||
keyboard := FocusScope {
|
||||
key-pressed(event) => {
|
||||
if event.text == " " || event.text == "\n" { root.clicked(); return accept; }
|
||||
return reject;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
25
src/ui/slint/unlock.slint
Normal file
25
src/ui/slint/unlock.slint
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
import { Theme, ActionButton } from "theme.slint";
|
||||
import { ThemeInput } from "controls.slint";
|
||||
|
||||
export component UnlockWindow inherits Window {
|
||||
title: "Vnox — разблокировка";
|
||||
icon: @image-url("assets/vnox-mark.svg");
|
||||
preferred-width: 480px;
|
||||
preferred-height: 300px;
|
||||
background: Theme.bg-base;
|
||||
in-out property <string> error;
|
||||
callback unlock(string);
|
||||
|
||||
VerticalLayout {
|
||||
padding: 30px; spacing: 14px; alignment: start;
|
||||
Text { text: "Разблокировать профиль"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.375); font-weight: 600; }
|
||||
Text { text: "Ключи на этом устройстве защищены паролем."; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125); wrap: word-wrap; }
|
||||
password := ThemeInput {
|
||||
input-type: InputType.password;
|
||||
placeholder-text: "Пароль профиля";
|
||||
accepted => { root.unlock(self.text); }
|
||||
}
|
||||
if root.error != "" : Text { text: root.error; color: Theme.danger; font-size: Math.max(11px, Theme.font-size * 0.75); wrap: word-wrap; }
|
||||
ActionButton { text: "Разблокировать"; clicked => { root.unlock(password.text); } }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,98 +1,83 @@
|
|||
import { Theme } from "theme.slint";
|
||||
import { Theme, ActionButton } from "theme.slint";
|
||||
|
||||
export struct VoiceMemberItem {
|
||||
user_id: string,
|
||||
nickname: string,
|
||||
speaking: bool,
|
||||
}
|
||||
export struct VoiceMemberItem { user_id: string, nickname: string, speaking: bool, avatar_text: string }
|
||||
|
||||
export component VoicePanel {
|
||||
export component VoicePanel inherits Rectangle {
|
||||
in-out property <[VoiceMemberItem]> members;
|
||||
in-out property <bool> mic-enabled;
|
||||
in-out property <bool> deafened;
|
||||
in-out property <string> channel-name;
|
||||
in-out property <string> activity-banner;
|
||||
|
||||
in-out property <bool> push-to-talk;
|
||||
callback ptt-held(bool);
|
||||
callback toggle-mic();
|
||||
callback toggle-deafen();
|
||||
callback leave-voice();
|
||||
|
||||
background: Theme.bg-base;
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
|
||||
Text {
|
||||
text: "🔊 " + channel-name;
|
||||
color: Theme.text-primary;
|
||||
spacing: 0;
|
||||
Rectangle {
|
||||
height: 56px; border-width: 1px; border-color: Theme.border;
|
||||
HorizontalLayout {
|
||||
padding-left: 22px; spacing: 12px;
|
||||
Text { text: "◖"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 1.4375); width: 20px; vertical-alignment: center; }
|
||||
Text { text: root.channel-name; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0); font-weight: 600; vertical-alignment: center; }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
Text {
|
||||
text: activity-banner;
|
||||
color: Theme.text-muted;
|
||||
}
|
||||
Flickable {
|
||||
VerticalLayout {
|
||||
for m in members: Rectangle {
|
||||
height: 48px;
|
||||
HorizontalLayout {
|
||||
padding: 8px;
|
||||
spacing: 8px;
|
||||
Rectangle {
|
||||
width: 12px;
|
||||
height: 12px;
|
||||
border-radius: 6px;
|
||||
background: m.speaking ? Theme.success : Theme.text-muted;
|
||||
}
|
||||
Text {
|
||||
text: m.nickname;
|
||||
color: Theme.text-primary;
|
||||
VerticalLayout {
|
||||
padding: 24px; spacing: 16px;
|
||||
Text { text: root.members.length + " участников"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.8125); }
|
||||
Flickable {
|
||||
content-width: self.width;
|
||||
VerticalLayout {
|
||||
spacing: 12px;
|
||||
for member in root.members: Rectangle {
|
||||
height: 120px; border-radius: 12px;
|
||||
background: Theme.bg-interactive;
|
||||
border-width: member.speaking ? 2px : 1px;
|
||||
border-color: member.speaking ? Theme.success : Theme.border;
|
||||
HorizontalLayout {
|
||||
padding: 24px; spacing: 18px;
|
||||
Rectangle {
|
||||
width: 58px; height: 58px; border-radius: 20px; background: Theme.avatar-bg;
|
||||
Text { text: member.avatar_text; color: Theme.accent; font-size: Math.max(11px, Theme.font-size * 1.625); horizontal-alignment: center; vertical-alignment: center; }
|
||||
}
|
||||
VerticalLayout {
|
||||
spacing: 5px;
|
||||
Text { text: member.nickname; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 1.0625); }
|
||||
Text { text: member.speaking ? "Говорит" : "В голосовой комнате"; color: member.speaking ? Theme.success : Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.75); }
|
||||
}
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
if root.members.length == 0 : Text { text: "Подключение к голосовой комнате…"; color: Theme.text-muted; font-size: Math.max(11px, Theme.font-size * 0.875); }
|
||||
Rectangle { vertical-stretch: 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
HorizontalLayout {
|
||||
spacing: 8px;
|
||||
Rectangle {
|
||||
height: 32px;
|
||||
background: Theme.accent;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { toggle-mic(); }
|
||||
if root.push-to-talk : Rectangle {
|
||||
height: 46px; background: ptt-area.pressed ? Theme.voice-bg : Theme.bg-interactive;
|
||||
border-radius: 8px; border-width: ptt-focus.has-focus ? 1px : 0px; border-color: Theme.accent;
|
||||
accessible-role: button; accessible-label: "Удерживать для разговора";
|
||||
Text { text: ptt-area.pressed ? "Микрофон передаёт звук" : "Удерживай здесь, чтобы говорить"; color: Theme.text-primary; font-size: Math.max(11px, Theme.font-size * 0.875); horizontal-alignment: center; vertical-alignment: center; }
|
||||
ptt-area := TouchArea {
|
||||
clicked => { ptt-focus.focus(); }
|
||||
changed pressed => { root.ptt-held(self.pressed); }
|
||||
}
|
||||
Text {
|
||||
text: mic-enabled ? "Mute" : "Unmute";
|
||||
color: Theme.text-primary;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
ptt-focus := FocusScope {
|
||||
key-pressed(event) => { if event.text == " " { root.ptt-held(true); return accept; } return reject; }
|
||||
key-released(event) => { if event.text == " " { root.ptt-held(false); return accept; } return reject; }
|
||||
changed has-focus => { if !self.has-focus { root.ptt-held(false); } }
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
height: 32px;
|
||||
background: Theme.accent;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { toggle-deafen(); }
|
||||
}
|
||||
Text {
|
||||
text: deafened ? "Undeafen" : "Deafen";
|
||||
color: Theme.text-primary;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
}
|
||||
Rectangle {
|
||||
height: 32px;
|
||||
background: Theme.danger;
|
||||
border-radius: Theme.radius;
|
||||
TouchArea {
|
||||
clicked => { leave-voice(); }
|
||||
}
|
||||
Text {
|
||||
text: "Leave";
|
||||
color: Theme.text-primary;
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
Text { text: root.activity-banner; color: Theme.success; font-size: Math.max(11px, Theme.font-size * 0.8125); height: 22px; }
|
||||
HorizontalLayout {
|
||||
spacing: 10px;
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
ActionButton { text: root.mic-enabled ? "Выключить микрофон" : "Включить микрофон"; danger: !root.mic-enabled; clicked => { root.toggle-mic(); } }
|
||||
ActionButton { text: root.deafened ? "Включить звук" : "Выключить звук"; danger: root.deafened; clicked => { root.toggle-deafen(); } }
|
||||
ActionButton { text: "Покинуть комнату"; danger: true; clicked => { root.leave-voice(); } }
|
||||
Rectangle { horizontal-stretch: 1; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue