mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 08:53:20 +00:00
Move Models and Actions slint definitions in the shared directory
This commit is contained in:
parent
f2f472a595
commit
72b004b7b0
15 changed files with 58 additions and 66 deletions
|
@ -150,7 +150,6 @@ export component Calendar inherits Rectangle {
|
|||
ta := TouchArea {
|
||||
pointer-event(e) => {
|
||||
if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) {
|
||||
debug(ta.mouse-x, " ", ta.mouse-y);
|
||||
eventActionsPopup.show(ta.mouse-x, ta.mouse-y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
|
||||
import { AppModels } from "../shared/Models.slint";
|
||||
import { Date, Time, Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VActionButton, VTag, VText, Svg, VTextInput, Palette } from "@selenite";
|
||||
|
||||
|
@ -16,7 +16,7 @@ export component CreateTaskOrEvent inherits Rectangle {
|
|||
|
||||
function accepted() {
|
||||
root.create-task({
|
||||
sourceId: AppWindowModels.get-source-id-from-name(sourceInput.current-value),
|
||||
sourceId: AppModels.get-source-id-from-name(sourceInput.current-value),
|
||||
title: newTaskTitleInput.text,
|
||||
date: taskDateInput.date
|
||||
});
|
||||
|
@ -39,7 +39,7 @@ export component CreateTaskOrEvent inherits Rectangle {
|
|||
newTaskTitleInput := VTextInput {
|
||||
placeholder: "Enter new task";
|
||||
started-writting() => {
|
||||
sourceInput.current-index = AppWindowModels.default-source-index;
|
||||
sourceInput.current-index = AppModels.default-source-index;
|
||||
}
|
||||
accepted => { accepted() }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Event } from "../windows/AppWindow/Models.slint";
|
||||
import { Event } from "../shared/Models.slint";
|
||||
import { ScrollView } from "std-widgets.slint";
|
||||
import { VCheckBox, VTextInput, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Palette } from "@selenite";
|
||||
import { TaskLine } from "./TaskLine.slint";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Palette } from "@selenite";
|
||||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton, VText, VDatePicker } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { AppActions } from "../shared/Actions.slint";
|
||||
import { Modal } from "../../external/selenite/components/Modal.slint";
|
||||
import { VTimePicker } from "../../external/selenite/components/TimePicker.slint";
|
||||
|
||||
|
@ -30,7 +30,7 @@ export component AddEventModal inherits Modal {
|
|||
VButton {
|
||||
text: "Create";
|
||||
clicked => {
|
||||
AppWindowActions.create-event({
|
||||
AppActions.create-event({
|
||||
title: titleInput.text,
|
||||
date: dateInput.date,
|
||||
startsAt: startTimeInput.time,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Palette } from "@selenite";
|
||||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { AppModels } from "../shared/Models.slint";
|
||||
import { AppActions } from "../shared/Actions.slint";
|
||||
import { Modal } from "../../external/selenite/components/Modal.slint";
|
||||
|
||||
export component AddSourceModal inherits Modal {
|
||||
|
@ -28,7 +28,7 @@ export component AddSourceModal inherits Modal {
|
|||
VButton {
|
||||
text: "Add";
|
||||
clicked => {
|
||||
AppWindowActions.add-source(name, path);
|
||||
AppActions.add-source(name, path);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Palette } from "@selenite";
|
||||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { AppModels } from "../shared/Models.slint";
|
||||
import { AppActions } from "../shared/Actions.slint";
|
||||
import { Modal } from "../../external/selenite/components/Modal.slint";
|
||||
|
||||
export component EditSourceModal inherits Modal {
|
||||
|
@ -12,8 +12,8 @@ export component EditSourceModal inherits Modal {
|
|||
|
||||
public function edit(source-id: int) {
|
||||
source-id-to-edit = source-id;
|
||||
root.name = AppWindowModels.get-source-name-from-id(source-id);
|
||||
root.path = AppWindowModels.get-source-path-from-id(source-id);
|
||||
root.name = AppModels.get-source-name-from-id(source-id);
|
||||
root.path = AppModels.get-source-path-from-id(source-id);
|
||||
root.show();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ export component EditSourceModal inherits Modal {
|
|||
VButton {
|
||||
text: "Save";
|
||||
clicked => {
|
||||
AppWindowActions.edit-source(source-id-to-edit, name, path);
|
||||
AppActions.edit-source(source-id-to-edit, name, path);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Date, Time } from "std-widgets.slint";
|
||||
import { CalendarDay } from "../../components/Calendar.slint";
|
||||
import { CalendarDay } from "../components/Calendar.slint";
|
||||
|
||||
export struct NewTaskData {
|
||||
sourceId: int,
|
||||
|
@ -29,21 +29,15 @@ export struct CreateEventParams {
|
|||
endsAt: Time
|
||||
}
|
||||
|
||||
export global AppWindowActions {
|
||||
export global AppActions {
|
||||
callback task-clicked(int, int);
|
||||
callback source-clicked(int);
|
||||
callback add-source(name: string, path: string);
|
||||
callback edit-source(sourceId: int, name: string, path: string);
|
||||
|
||||
callback open-new-task-form(OpenNewTaskFormParams);
|
||||
callback open-edit-task-form(int, int);
|
||||
callback open-new-event-form();
|
||||
callback open-edit-event-form(int, int);
|
||||
callback toggle-show-completed-tasks();
|
||||
callback delete-task-clicked(int, int);
|
||||
|
||||
callback open-add-event-window();
|
||||
|
||||
callback create-task(NewTaskData);
|
||||
callback save-task(SaveTaskData);
|
||||
callback create-event(CreateEventParams);
|
|
@ -1,5 +1,5 @@
|
|||
import { Date, Time } from "std-widgets.slint";
|
||||
import { CalendarDay } from "../../components/Calendar.slint";
|
||||
import { CalendarDay } from "../components/Calendar.slint";
|
||||
|
||||
export struct Source {
|
||||
id: int,
|
||||
|
@ -37,7 +37,7 @@ export struct Day {
|
|||
relativeDaysDiff: int
|
||||
}
|
||||
|
||||
export global AppWindowModels {
|
||||
export global AppModels {
|
||||
in-out property<[Source]> sources-selected;
|
||||
in-out property<int> default-source-index;
|
||||
in-out property<[string]> sources;
|
|
@ -1,7 +1,7 @@
|
|||
import { AppWindowModels } from "windows/AppWindow/Models.slint";
|
||||
import { AppWindowActions } from "windows/AppWindow/Actions.slint";
|
||||
import { AppModels } from "shared/Models.slint";
|
||||
import { AppActions } from "shared/Actions.slint";
|
||||
import { AppWindow } from "windows/AppWindow/AppWindow.slint";
|
||||
import { Utils } from "shared/Utils.slint";
|
||||
import { Palette } from "@selenite";
|
||||
|
||||
export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions }
|
||||
export { Utils, Palette, AppWindow, AppModels, AppActions }
|
||||
|
|
|
@ -228,7 +228,6 @@ void AppWindow::setupCallbacks()
|
|||
});
|
||||
|
||||
actions().on_create_event([&](ui::CreateEventParams newEventParams) {
|
||||
std::println("okkk");
|
||||
const ui::Date &date = newEventParams.date;
|
||||
const std::string dateStr = SlintDateToStdString(date);
|
||||
const auto sourceId = models().get_default_source_index();
|
||||
|
@ -416,12 +415,12 @@ void AppWindow::run()
|
|||
mainWindow_->run();
|
||||
}
|
||||
|
||||
const ui::AppWindowModels &AppWindow::models()
|
||||
const ui::AppModels &AppWindow::models()
|
||||
{
|
||||
return mainWindow_->global<ui::AppWindowModels>();
|
||||
return mainWindow_->global<ui::AppModels>();
|
||||
}
|
||||
|
||||
const ui::AppWindowActions &AppWindow::actions()
|
||||
const ui::AppActions &AppWindow::actions()
|
||||
{
|
||||
return mainWindow_->global<ui::AppWindowActions>();
|
||||
return mainWindow_->global<ui::AppActions>();
|
||||
}
|
||||
|
|
|
@ -25,8 +25,8 @@ class AppWindow
|
|||
|
||||
private:
|
||||
void setupCallbacks();
|
||||
const ui::AppWindowModels &models();
|
||||
const ui::AppWindowActions &actions();
|
||||
const ui::AppModels &models();
|
||||
const ui::AppActions &actions();
|
||||
|
||||
std::shared_ptr<slint::VectorModel<ui::Source>> sources_;
|
||||
std::shared_ptr<slint::VectorModel<ui::Day>> days_;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AppWindowModels } from "Models.slint";
|
||||
import { AppModels } from "../../shared/Models.slint";
|
||||
import { Button, VerticalBox, CheckBox } from "std-widgets.slint";
|
||||
import { MainView } from "views/TasksView.slint";
|
||||
import { Palette } from "@selenite";
|
||||
|
@ -6,7 +6,7 @@ import { CalendarView } from "views/CalendarView.slint";
|
|||
import { VButton } from "../../../external/selenite/components/Button.slint";
|
||||
import { ToggleButton } from "../../../external/selenite/components/index.slint";
|
||||
import { VTextInput } from "../../../external/selenite/components/TextInput.slint";
|
||||
import { AppWindowActions } from "Actions.slint";
|
||||
import { AppActions } from "../../shared/Actions.slint";
|
||||
import { SideBar } from "views/SideBar.slint";
|
||||
|
||||
export component AppWindow inherits Window {
|
||||
|
@ -69,4 +69,4 @@ export component AppWindow inherits Window {
|
|||
}
|
||||
}
|
||||
|
||||
export { AppWindowModels, Palette } // Export to make it visible to the C++ backend
|
||||
export { AppModels, Palette } // Export to make it visible to the C++ backend
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AppWindowModels, TaskData } from "../Models.slint";
|
||||
import { AppWindowActions, NewTaskData, SaveTaskData } from "../Actions.slint";
|
||||
import { AppModels, TaskData } from "../../../shared/Models.slint";
|
||||
import { AppActions, NewTaskData, SaveTaskData } from "../../../shared/Actions.slint";
|
||||
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { TaskLine } from "../../../components/TaskLine.slint";
|
||||
import { EventGroup } from "../../../components/EventGroup.slint";
|
||||
|
@ -39,9 +39,9 @@ export component CalendarView inherits Rectangle {
|
|||
}
|
||||
Calendar {
|
||||
delete-event-request(source-id, event-id) => {
|
||||
AppWindowActions.delete-event(source-id, event-id)
|
||||
AppActions.delete-event(source-id, event-id)
|
||||
}
|
||||
days: AppWindowModels.calendar;
|
||||
days: AppModels.calendar;
|
||||
current-date: Utils.current-date;
|
||||
current-time: Utils.current-time;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AppWindowModels, TaskData } from "../Models.slint";
|
||||
import { AppWindowActions } from "../Actions.slint";
|
||||
import { AppModels, TaskData } from "../../../shared/Models.slint";
|
||||
import { AppActions } from "../../../shared/Actions.slint";
|
||||
import { VButton, ToggleButton, VActionButton, VText, Svg, Palette } from "@selenite";
|
||||
import { EditSourceModal } from "../../../modals/EditSourceModal.slint";
|
||||
import { AddSourceModal } from "../../../modals/AddSourceModal.slint";
|
||||
|
@ -46,16 +46,16 @@ export component SideBar inherits Rectangle {
|
|||
ToggleButton {
|
||||
text: "All";
|
||||
text-alignment: left;
|
||||
active: AppWindowModels.no-source-selected;
|
||||
clicked => { AppWindowActions.source-clicked(-1) }
|
||||
active: AppModels.no-source-selected;
|
||||
clicked => { AppActions.source-clicked(-1) }
|
||||
|
||||
|
||||
}
|
||||
for item[index] in AppWindowModels.sources-selected: ToggleButton {
|
||||
for item[index] in AppModels.sources-selected: ToggleButton {
|
||||
text: item.name;
|
||||
text-alignment: left;
|
||||
active: item.selected;
|
||||
clicked => { AppWindowActions.source-clicked(item.id) }
|
||||
clicked => { AppActions.source-clicked(item.id) }
|
||||
VActionButton {
|
||||
visible: parent.active;
|
||||
icon-svg: Svg.cog;
|
||||
|
@ -70,7 +70,7 @@ export component SideBar inherits Rectangle {
|
|||
icon-svg: Svg.cog;
|
||||
text: "Settings";
|
||||
background: transparent;
|
||||
clicked => { AppWindowModels.open-settings-window() }
|
||||
clicked => { AppModels.open-settings-window() }
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AppWindowModels, TaskData } from "../Models.slint";
|
||||
import { AppWindowActions, NewTaskData, SaveTaskData } from "../Actions.slint";
|
||||
import { AppModels, TaskData } from "../../../shared/Models.slint";
|
||||
import { AppActions, NewTaskData, SaveTaskData } from "../../../shared/Actions.slint";
|
||||
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { TaskLine } from "../../../components/TaskLine.slint";
|
||||
import { EventGroup } from "../../../components/EventGroup.slint";
|
||||
|
@ -23,7 +23,7 @@ export component MainView inherits Rectangle {
|
|||
VButton {
|
||||
text: "Show/Hide completed tasks";
|
||||
clicked => {
|
||||
AppWindowActions.toggle-show-completed-tasks();
|
||||
AppActions.toggle-show-completed-tasks();
|
||||
completed-tasks-visible = !completed-tasks-visible;
|
||||
}
|
||||
icon-svg: completed-tasks-visible ? icon-visible : icon-not-visible;
|
||||
|
@ -37,9 +37,9 @@ export component MainView inherits Rectangle {
|
|||
}
|
||||
|
||||
CreateTaskOrEvent {
|
||||
sources: AppWindowModels.sources;
|
||||
sources: AppModels.sources;
|
||||
create-task(data) => {
|
||||
AppWindowActions.create-task({
|
||||
AppActions.create-task({
|
||||
sourceId: data.sourceId,
|
||||
eventId: -1,
|
||||
title: data.title,
|
||||
|
@ -54,12 +54,12 @@ export component MainView inherits Rectangle {
|
|||
horizontal-stretch: 1;
|
||||
VerticalLayout {
|
||||
alignment: start;
|
||||
if AppWindowModels.days.length == 0 && AppWindowModels.unscheduled-tasks.length == 0 : VText {
|
||||
if AppModels.days.length == 0 && AppModels.unscheduled-tasks.length == 0 : VText {
|
||||
text: "There is no task to show";
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
for day[dayIndex] in AppWindowModels.days: VerticalLayout {
|
||||
for day[dayIndex] in AppModels.days: VerticalLayout {
|
||||
spacing: day.tasks.length > 0 ? 16px : 0px;
|
||||
padding-bottom: 32px;
|
||||
|
||||
|
@ -92,19 +92,19 @@ export component MainView inherits Rectangle {
|
|||
padding-bottom: 8px;
|
||||
TaskLine {
|
||||
title: task.title;
|
||||
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||
source-name: AppModels.get-source-name-from-id(task.sourceId);
|
||||
scheduled: task.date.year != 0;
|
||||
date: day.date;
|
||||
checked: task.checked;
|
||||
allow-edit-date: true;
|
||||
delete => {
|
||||
AppWindowActions.delete-task-clicked(task.sourceId, task.id)
|
||||
AppActions.delete-task-clicked(task.sourceId, task.id)
|
||||
}
|
||||
toggle-check => {
|
||||
AppWindowActions.task-clicked(task.sourceId, task.id);
|
||||
AppActions.task-clicked(task.sourceId, task.id);
|
||||
}
|
||||
edited(data) => {
|
||||
AppWindowActions.save-task({
|
||||
AppActions.save-task({
|
||||
id: task.id,
|
||||
sourceId: task.sourceId,
|
||||
title: data.title,
|
||||
|
@ -117,7 +117,7 @@ export component MainView inherits Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
if AppWindowModels.unscheduled-tasks.length > 0 : VerticalLayout {
|
||||
if AppModels.unscheduled-tasks.length > 0 : VerticalLayout {
|
||||
Rectangle {
|
||||
//background: Palette.card-background;
|
||||
border-radius: 8px;
|
||||
|
@ -130,22 +130,22 @@ export component MainView inherits Rectangle {
|
|||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
for task[taskIndex] in AppWindowModels.unscheduled-tasks: VerticalLayout {
|
||||
for task[taskIndex] in AppModels.unscheduled-tasks: VerticalLayout {
|
||||
padding-top: taskIndex == 0 ? 16px : 0px;
|
||||
padding-bottom: 8px;
|
||||
TaskLine {
|
||||
title: task.title;
|
||||
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||
source-name: AppModels.get-source-name-from-id(task.sourceId);
|
||||
checked: task.checked;
|
||||
allow-edit-date: true;
|
||||
delete => {
|
||||
AppWindowActions.delete-task-clicked(task.sourceId, task.id)
|
||||
AppActions.delete-task-clicked(task.sourceId, task.id)
|
||||
}
|
||||
toggle-check => {
|
||||
AppWindowActions.task-clicked(task.sourceId, task.id);
|
||||
AppActions.task-clicked(task.sourceId, task.id);
|
||||
}
|
||||
edited(data) => {
|
||||
AppWindowActions.save-task({
|
||||
AppActions.save-task({
|
||||
id: task.id,
|
||||
sourceId: task.sourceId,
|
||||
title: data.title,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue