mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 01:33:19 +00:00
Switch from Qt6 to Slint
This commit is contained in:
parent
f8be14bcf8
commit
63bf267a22
107 changed files with 27532 additions and 2896 deletions
101
ui/windows/EventWindow.slint
Normal file
101
ui/windows/EventWindow.slint
Normal file
|
@ -0,0 +1,101 @@
|
|||
import { Date, Time, ComboBox } from "std-widgets.slint";
|
||||
import { VTimePicker, VDatePicker, VButton, VTextInput, VText, Palette } from "@vynui";
|
||||
import { Backend } from "../Backend.slint";
|
||||
|
||||
export struct NewEventParams {
|
||||
sourceId: int,
|
||||
title: string,
|
||||
date: Date,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
}
|
||||
|
||||
export struct SaveEventParams {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
date: Date,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
}
|
||||
|
||||
export component EventWindow inherits Window {
|
||||
title: "Mirai - " + (eventId == -1 ? "New event" : "Edit event");
|
||||
min-width: 100px;
|
||||
max-width: 1920px;
|
||||
preferred-width: 512px;
|
||||
min-height: 100px;
|
||||
max-height: 4000px;
|
||||
default-font-size: 16px;
|
||||
background: Palette.background;
|
||||
|
||||
in-out property<int> sourceId <=> resourceInput.current-index;
|
||||
in-out property<int> eventId: -1;
|
||||
in-out property<Date> taskDate <=> taskDateInput.date;
|
||||
in-out property<string> taskTitle <=> taskTitleInput.text;
|
||||
in-out property<Time> startsAt <=> eventStartTimeInput.time;
|
||||
in-out property<Time> endsAt <=> eventEndTimeInput.time;
|
||||
|
||||
callback create(NewEventParams);
|
||||
callback save(SaveEventParams);
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
VText {
|
||||
text: eventId == -1 ? "New event" : "Edit event";
|
||||
}
|
||||
|
||||
resourceInput := ComboBox {
|
||||
model: Backend.resources;
|
||||
enabled: eventId == -1;
|
||||
}
|
||||
|
||||
taskTitleInput := VTextInput {
|
||||
label: "Title";
|
||||
wrap: word-wrap;
|
||||
}
|
||||
|
||||
taskDateInput := VDatePicker {
|
||||
label: "Date";
|
||||
}
|
||||
|
||||
HorizontalLayout {
|
||||
spacing: 4px;
|
||||
eventStartTimeInput := VTimePicker {
|
||||
label: "Starts at";
|
||||
}
|
||||
|
||||
eventEndTimeInput := VTimePicker {
|
||||
label: "Ends at";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
VButton {
|
||||
text: eventId == -1 ? "Create" : "Save";
|
||||
clicked => {
|
||||
if (eventId == -1) {
|
||||
create({
|
||||
sourceId: sourceId,
|
||||
title: taskTitle,
|
||||
date: taskDate,
|
||||
startsAt: startsAt,
|
||||
endsAt: endsAt,
|
||||
});
|
||||
} else {
|
||||
save({
|
||||
sourceId: sourceId,
|
||||
id: eventId,
|
||||
title: taskTitle,
|
||||
date: taskDate,
|
||||
startsAt: startsAt,
|
||||
endsAt: endsAt,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { Backend }
|
85
ui/windows/TaskEdit.slint
Normal file
85
ui/windows/TaskEdit.slint
Normal file
|
@ -0,0 +1,85 @@
|
|||
import { Date, ComboBox } from "std-widgets.slint";
|
||||
import { VTextInput, VButton, VDatePicker, VText, Palette } from "@vynui";
|
||||
import { Backend } from "../Backend.slint";
|
||||
import { Palette } from "../../lib/slint-vynui/Palette.slint";
|
||||
|
||||
export struct NewTaskData {
|
||||
sourceId: int,
|
||||
eventId: int,
|
||||
title: string,
|
||||
date: Date
|
||||
}
|
||||
|
||||
export struct SaveTaskData {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
date: Date,
|
||||
}
|
||||
|
||||
export component TaskEdit inherits Window {
|
||||
title: "Mirai - " + (taskId == -1 ? "New task" : "Edit task");
|
||||
min-width: 100px;
|
||||
max-width: 1920px;
|
||||
preferred-width: 512px;
|
||||
min-height: 100px;
|
||||
max-height: 4000px;
|
||||
default-font-size: 16px;
|
||||
background: Palette.background;
|
||||
|
||||
in-out property<int> taskId: -1;
|
||||
in-out property<int> eventId: -1;
|
||||
in-out property<Date> taskDate <=> taskDateInput.date;
|
||||
in-out property<string> taskTitle <=> taskTitleInput.text;
|
||||
in-out property<int> taskResourceIndex <=> resourceInput.current-index;
|
||||
|
||||
callback create(NewTaskData);
|
||||
callback save(SaveTaskData);
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
VText {
|
||||
text: taskId == -1 ? "New task" : "Edit task";
|
||||
}
|
||||
|
||||
resourceInput := ComboBox {
|
||||
model: Backend.resources;
|
||||
enabled: taskId == -1 && eventId == -1;
|
||||
}
|
||||
|
||||
taskTitleInput := VTextInput {
|
||||
label: "Content";
|
||||
wrap: word-wrap;
|
||||
accepted => { button.clicked() }
|
||||
}
|
||||
|
||||
taskDateInput := VDatePicker {
|
||||
label: "Date";
|
||||
enabled: eventId == -1;
|
||||
}
|
||||
|
||||
button := VButton {
|
||||
text: taskId == -1 ? "Create" : "Save";
|
||||
clicked => {
|
||||
if (taskId == -1) {
|
||||
create({
|
||||
sourceId: taskResourceIndex,
|
||||
eventId: eventId,
|
||||
title: taskTitle,
|
||||
date: taskDate,
|
||||
});
|
||||
} else {
|
||||
save({
|
||||
sourceId: taskResourceIndex,
|
||||
id: taskId,
|
||||
title: taskTitle,
|
||||
date: taskDate,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { Backend }
|
Loading…
Add table
Add a link
Reference in a new issue