Skip to content

Commit

Permalink
[+] add v2t panel
Browse files Browse the repository at this point in the history
  • Loading branch information
heng30 committed Jan 18, 2024
1 parent c63614e commit 880664e
Show file tree
Hide file tree
Showing 9 changed files with 113 additions and 22 deletions.
4 changes: 2 additions & 2 deletions vtbox/src/config/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ impl Default for UI {
Self {
font_size: 18,
font_family: "SourceHanSerifCN".to_string(),
win_width: 600,
win_height: 800,
win_width: 800,
win_height: 600,
language: "cn".to_string(),
}
}
Expand Down
2 changes: 1 addition & 1 deletion vtbox/src/logic/about.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use slint::ComponentHandle;
pub fn init(ui: &AppWindow) {
let mut about = ui.global::<Store>().get_about_dialog();
about.title = slint::format!(
"BitBox {}",
"vtbox {}",
if VERSION.is_empty() {
"v0.0.1"
} else {
Expand Down
1 change: 1 addition & 0 deletions vtbox/ui/images/start-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions vtbox/ui/logic.slint
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,7 @@ export global Logic {
callback setting-ok(SettingDialogConfig);

callback switch-model-type(int); // argument: model-type-index
callback open-audio-file-dialog() -> string; // return: filepath
callback start-v2t(string, string); // argument: model-name, audio-filepath
}

6 changes: 1 addition & 5 deletions vtbox/ui/panel/bodyer/model.slint
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Theme } from "../../theme.slint";
import { Store } from "../../store.slint";
import { Logic } from "../../logic.slint";
import { IconBtn } from "../../base/icon-btn.slint";
import { Divider } from "../../base/divider.slint";
import { Label } from "../../base/label.slint";

export component Model inherits Rectangle {
Expand All @@ -30,7 +29,7 @@ export component Model inherits Rectangle {
}

HorizontalLayout {
spacing: Theme.spacing;
spacing: Theme.spacing * 2;

IconBtn {
width: Theme.icon-size * 1.33;
Expand Down Expand Up @@ -80,7 +79,6 @@ export component Model inherits Rectangle {
property <[percent]> label-width: [50%, 20%, 30%];
property <string> selected-uuid;

spacing: Theme.spacing;
padding: Theme.padding / 2;

header := Rectangle {
Expand Down Expand Up @@ -125,8 +123,6 @@ export component Model inherits Rectangle {
text: data.status;
}
}


}

touch := TouchArea {
Expand Down
11 changes: 7 additions & 4 deletions vtbox/ui/panel/bodyer/t2v.slint
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ import { Theme } from "../../theme.slint";
import { Store } from "../../store.slint";
import { Logic } from "../../logic.slint";
import { IconBtn } from "../../base/icon-btn.slint";
import { Divider } from "../../base/divider.slint";
import { Label } from "../../base/label.slint";

export component T2V inherits Rectangle {
background: blue;
VerticalLayout {
spacing: Theme.spacing;
Label {
text: "Coming soon...";
}

// VerticalLayout {
// spacing: Theme.spacing;
// }
}
76 changes: 75 additions & 1 deletion vtbox/ui/panel/bodyer/v2t.slint
Original file line number Diff line number Diff line change
@@ -1,12 +1,86 @@
import { LineEdit, ComboBox, TextEdit } from "std-widgets.slint";
import { Theme } from "../../theme.slint";
import { Store } from "../../store.slint";
import { Logic } from "../../logic.slint";
import { IconBtn } from "../../base/icon-btn.slint";
import { Divider } from "../../base/divider.slint";
import { Label } from "../../base/label.slint";

export component V2T inherits Rectangle {
background: green;
property <string> audio-filepath;

VerticalLayout {
spacing: Theme.spacing;

HorizontalLayout {
spacing: Theme.spacing * 2;

model-name-combox := ComboBox {
model: Store.v2t-models;
current-value: self.model[0];
current-index: 0;
}

HorizontalLayout {
spacing: Theme.spacing;

audio-name-lineedit := LineEdit {
placeholder-text: Store.translator.filename;
read-only: true;
enabled: false;
}

IconBtn {
width: Theme.icon-size * 1.33;
icon-width: Theme.icon-size * 1;
icon: @image-url("../../images/file-open.svg");
tip-pos: "left";
tip-text: Store.translator.tip-open;
clicked => {
root.audio-filepath = Logic.open-audio-file-dialog();
// TODO: get the basename
audio-name-lineedit.text = root.audio-filepath;
}
}
}

HorizontalLayout {
spacing: Theme.spacing * 2;

IconBtn {
width: Theme.icon-size * 1.33;
icon-width: Theme.icon-size * 1;
icon: @image-url("../../images/copy.svg");
tip-pos: "left";
tip-text: Store.translator.tip-copy;
clicked => {
Logic.copy-to-clipboard(te.text);
}
}

IconBtn {
width: Theme.icon-size * 1.33;
icon-width: Theme.icon-size * 1;
icon: @image-url("../../images/start-fill.svg");
tip-pos: "left";
tip-text: Store.translator.tip-start;
clicked => {
Store.v2t-text = "";
Logic.start-v2t(model-name-combox.current-value, root.audio-filepath);
}
}
}
}

Rectangle {
border-width: Theme.border-width;
border-color: Theme.dark-border-color;
te := TextEdit {
width: 100%;
height: 100%;
read-only: true;
text: Store.v2t-text;
}
}
}
}
23 changes: 14 additions & 9 deletions vtbox/ui/store.slint
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,16 @@ export struct AboutDialog {
}

export global Store {
in-out property<string> current-panel: "model";
in-out property<string> current-panel: "v2t";

in-out property <string> v2t-text;
in-out property <[string]> v2t-models: [
"ggml-tiny.bin",
"ggml-base.bin",
"ggml-small.bin",
"ggml-medium.bin",
"ggml-large.bin",
];

in-out property<[ModelItem]> model-datas: [
{
Expand Down Expand Up @@ -97,16 +106,12 @@ export global Store {
show: false,
text-cn:
"配置和数据:\n"
+ " 1. 配置保存在~/.config/bitbox目录下。\n"
+ " 2. 数据保存在~/.local/share/bitbox目录下。\n"
+ "\n注意事项:\n"
+ " 1. 使用 blockstream API 进行交易广播,获取UTXO等链上信息。\n",
+ " 1. 配置保存在~/.config/vtbox目录下。\n"
+ " 2. 数据保存在~/.local/share/vtbox目录下。\n",

text-en:
"Configuration and data:\n"
+ "  1. Configuration is stored in the ~/.config/bitbox directory.\n"
+ "  2. Data is stored in the ~/.local/share/bitbox directory.\n"
+ "\nNote:\n"
+ " 1. Use blockstream API to broadcast transation, fetch UTXO and other on chain information.\n",
+ "  1. Configuration is stored in the ~/.config/vtbox directory.\n"
+ "  2. Data is stored in the ~/.local/share/vtbox directory.\n",
};
}
10 changes: 10 additions & 0 deletions vtbox/ui/translator.slint
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export struct Translation {
input-password: string,
please-login: string,
flushing: string,
filename: string,

name-label: string,
status-label: string,
Expand All @@ -42,6 +43,7 @@ export struct Translation {
customer: string,

model-type: string,
model-name: string,
model-header-name: string,
model-header-size: string,
model-header-status: string,
Expand Down Expand Up @@ -165,6 +167,9 @@ export struct Translation {
tip-flush: string,
tip-zoom-out: string,
tip-zoom-in: string,

tip-start: string,
tip-open: string,
}

export global Translator {
Expand Down Expand Up @@ -192,6 +197,7 @@ export global Translator {
input-password: is-cn ? "请输入密码" : "Please input password",
please-login: is-cn ? "请登陆" : "Please login",
flushing: is-cn ? "正在刷新..." : "Flush...",
filename: is-cn ? "文件名" : "Filename",

name-label: is-cn ? "昵称:" : "Name:",
status-label: is-cn ? "状态:" : "Status:",
Expand All @@ -213,6 +219,7 @@ export global Translator {
customer: is-cn ? "自定义" : "customer",

model-type: is-cn ? "模型类型" : "Model type",
model-name: is-cn ? "模型" : "Model",
model-header-name: is-cn ? "名称" : "Name",
model-header-size: is-cn ? "大小" : "Size",
model-header-status: is-cn ? "状态" : "Status",
Expand Down Expand Up @@ -336,6 +343,9 @@ export global Translator {
tip-flush: is-cn ? "刷新" : "Flush",
tip-zoom-out: is-cn ? "缩小" : "Zoom Out",
tip-zoom-in: is-cn ? "放大" : "Zoom In",

tip-start: is-cn ? "开始" : "Start",
tip-open: is-cn ? "打开" : "Open",
};
}
}

0 comments on commit 880664e

Please sign in to comment.