mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 17:03:19 +00:00
Replace 'edit source window' with popup
This commit is contained in:
parent
129b30b9e7
commit
854152b395
13 changed files with 101 additions and 163 deletions
63
src/components/editSourceModal.slint
Normal file
63
src/components/editSourceModal.slint
Normal file
|
@ -0,0 +1,63 @@
|
|||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { Palette } from "@selenite";
|
||||
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
|
||||
|
||||
export component EditSourceModal inherits Rectangle {
|
||||
private property <int> source-id-to-edit: -1;
|
||||
private property <string> name: "";
|
||||
private property <string> path: "";
|
||||
|
||||
init() => {
|
||||
if (self.absolute-position.x < 500px) {
|
||||
self.x += 500px - self.absolute-position.x;
|
||||
}
|
||||
}
|
||||
|
||||
public function edit(source-id: int) {
|
||||
source-id-to-edit = source-id;
|
||||
self.name = AppWindowModels.get-source-name-from-id(source-id);
|
||||
self.path = AppWindowModels.get-source-path-from-id(source-id);
|
||||
popup.show();
|
||||
}
|
||||
|
||||
popup := PopupWindow {
|
||||
close-policy: close-on-click-outside;
|
||||
background := Rectangle {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background: Palette.background1;
|
||||
border-color: Palette.popup-border;
|
||||
border-width: 1px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
nameInput := VTextInput {
|
||||
label: "Name";
|
||||
text <=> root.name;
|
||||
}
|
||||
pathInput := VTextInput {
|
||||
label: "Path";
|
||||
text <=> root.path;
|
||||
}
|
||||
VButton {
|
||||
text: "Save";
|
||||
clicked => {
|
||||
AppWindowActions.edit-source(source-id-to-edit, name, path);
|
||||
popup.close();
|
||||
}
|
||||
}
|
||||
VButton {
|
||||
text: "Delete";
|
||||
background-color: Palette.red;
|
||||
double-clicked => {
|
||||
//root.delete-source(root.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue