diff --git a/external/slint-vynui/BurgerIcon.slint b/external/slint-vynui/BurgerIcon.slint deleted file mode 100644 index 23393dd..0000000 --- a/external/slint-vynui/BurgerIcon.slint +++ /dev/null @@ -1,9 +0,0 @@ -import { Palette } from "./Palette.slint"; - -export component BurgerIcon inherits Path { - width: 32px; - height: 32px; - commands: "M3 6h18M3 12h18M3 18h18"; - stroke: Palette.foreground; - stroke-width: 2px; -} diff --git a/external/slint-vynui/DatePicker.slint b/external/slint-vynui/DatePicker.slint index f6c5d00..0a6a10a 100644 --- a/external/slint-vynui/DatePicker.slint +++ b/external/slint-vynui/DatePicker.slint @@ -2,6 +2,7 @@ import { Button, DatePickerPopup, Date, Palette } from "std-widgets.slint"; import { VLabeledComponent } from "LabeledComponent.slint"; import { VActionButton } from "ActionButton.slint"; import { VButton } from "Button.slint"; +import { Svg } from "Svg.slint"; export component VDatePicker inherits VLabeledComponent { in-out property date; @@ -34,7 +35,7 @@ export component VDatePicker inherits VLabeledComponent { clicked => { taskDateInput.show() } } VActionButton { - icon-svg: "M18 28A12 12 0 1 0 6 16v6.2l-3.6-3.6L1 20l6 6l6-6l-1.4-1.4L8 22.2V16a10 10 0 1 1 10 10Z"; + icon-svg: Svg.reset; icon-svg-stroke-width: 1px; enabled: root.enabled; clicked => { resetDate() } diff --git a/external/slint-vynui/Svg.slint b/external/slint-vynui/Svg.slint new file mode 100644 index 0000000..7d216de --- /dev/null +++ b/external/slint-vynui/Svg.slint @@ -0,0 +1,12 @@ +export global Svg { + out property burger: "M3 6h18M3 12h18M3 18h18"; + out property play: "M240 128a15.74 15.74 0 0 1-7.6 13.51L88.32 229.65a16 16 0 0 1-16.2.3A15.86 15.86 0 0 1 64 216.13V39.87a15.86 15.86 0 0 1 8.12-13.82a16 16 0 0 1 16.2.3l144.08 88.14A15.74 15.74 0 0 1 240 128"; + out property pause: "M216 48v160a16 16 0 0 1-16 16h-40a16 16 0 0 1-16-16V48a16 16 0 0 1 16-16h40a16 16 0 0 1 16 16M96 32H56a16 16 0 0 0-16 16v160a16 16 0 0 0 16 16h40a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16"; + out property reset: "M18 28A12 12 0 1 0 6 16v6.2l-3.6-3.6L1 20l6 6l6-6l-1.4-1.4L8 22.2V16a10 10 0 1 1 10 10Z"; + out property trash: "M19 4h-3.5l-1-1h-5l-1 1H5v2h14M6 19a2 2 0 0 0 2 2h8a2 2 0 0 0 2-2V7H6z"; + out property plus: "M11 13H5v-2h6V5h2v6h6v2h-6v6h-2z"; + out property pen: "M3 17.46v3.04c0 .28.22.5.5.5h3.04c.13 0 .26-.05.35-.15L17.81 9.94l-3.75-3.75L3.15 17.1q-.15.15-.15.36M20.71 7.04a.996.996 0 0 0 0-1.41l-2.34-2.34a.996.996 0 0 0-1.41 0l-1.83 1.83l3.75 3.75z"; + out property visible: "M2.933 3.491C4.056 2.681 5.456 2 7 2s2.944.682 4.067 1.491c1.128.812 2.02 1.784 2.56 2.437l.005.005c.241.3.368.681.368 1.067s-.127.766-.368 1.067l-.005.005c-.54.653-1.432 1.625-2.56 2.437C9.944 11.32 8.544 12 7 12s-2.944-.682-4.067-1.49C1.805 9.696.913 8.724.373 8.071l-.005-.005A1.7 1.7 0 0 1 0 7c0-.386.127-.766.368-1.067l.005-.005c.54-.653 1.432-1.625 2.56-2.437M7 9.25a2.25 2.25 0 1 0 0-4.5a2.25 2.25 0 0 0 0 4.5"; + out property not-visible: "M.264 1.324a.75.75 0 0 1 1.06-1.06l2.629 2.628C4.86 2.393 5.893 2.04 7 2.04c1.532 0 2.92.677 4.035 1.48c1.118.805 2.003 1.769 2.539 2.417l.004.005c.24.298.366.675.366 1.058s-.126.76-.366 1.058l-.004.006a14.5 14.5 0 0 1-2.249 2.2l2.411 2.412a.75.75 0 0 1-1.06 1.06zm8.753 6.633a2.232 2.232 0 0 0-2.974-2.974zm-8.59-2.02c.319-.387.762-.885 1.305-1.395l7.104 7.104A5.7 5.7 0 0 1 7 11.96c-1.532 0-2.92-.676-4.035-1.479C1.847 9.675.962 8.711.426 8.064l-.004-.006A1.7 1.7 0 0 1 .056 7c0-.383.126-.76.366-1.058l.004-.005Z"; + +} diff --git a/external/slint-vynui/index.slint b/external/slint-vynui/index.slint index 1fa9f0c..fb7e304 100644 --- a/external/slint-vynui/index.slint +++ b/external/slint-vynui/index.slint @@ -12,4 +12,4 @@ export { VTextInput } from "TextInput.slint"; export { VSlider } from "Slider.slint"; export { ToggleButton } from "ToggleButton.slint"; -export { BurgerIcon } from "BurgerIcon.slint"; +export { Svg } from "Svg.slint"; diff --git a/src/UiState.cpp b/src/UiState.cpp index 984f564..641484c 100644 --- a/src/UiState.cpp +++ b/src/UiState.cpp @@ -79,7 +79,7 @@ std::optional stringToDate(const std::string &dateStr) void UiState::setupUtilsCallbacks() { - mainWindow_->global().on_formatDate([&](const Date &date) { + mainWindow_->global().on_format_date([&](const Date &date) { std::chrono::year_month_day chronoDate{ std::chrono::year(date.year), std::chrono::month(date.month), @@ -116,18 +116,6 @@ void UiState::setupCallbacks() reloadTasks(); }); - /*mainWindow_->global().on_tag_clicked([&](int index) {*/ - /*const std::string &tag = miraiInstance_->getTags().at(index);*/ - /*if (std::ranges::find(view_.getActiveTagsFilter(), tag) ==*/ - /*view_.getActiveTagsFilter().end()) {*/ - /*view_.addTagFilter(tag);*/ - /*} else {*/ - /*view_.removeTagFilter(tag);*/ - /*}*/ - /*view_.update();*/ - /*reloadTasks();*/ - /*});*/ - mainWindow_->global().on_delete_task_clicked([&](int sourceId, int taskId) { auto source = miraiInstance_->getSourceById(sourceId); assert(source); @@ -147,9 +135,9 @@ void UiState::setupCallbacks() mainWindow_->global().set_sources_selected(sources_); mainWindow_->global().set_tags(tags_); - mainWindow_->global().set_visible_tasks(days_); + mainWindow_->global().set_days(days_); - mainWindow_->global().on_saveTask([&](SaveTaskData newTaskData) { + mainWindow_->global().on_save_task([&](SaveTaskData newTaskData) { auto source = miraiInstance_->getSourceById(newTaskData.sourceId); assert(source); auto task = source->getTaskById(newTaskData.id); @@ -167,7 +155,7 @@ void UiState::setupCallbacks() reloadTasks(); }); - mainWindow_->global().on_createTask([&](NewTaskData newTaskData) { + mainWindow_->global().on_create_task([&](NewTaskData newTaskData) { std::optional date = std::nullopt; if (newTaskData.date.year != 0) { date = SlintDateToMiraiDate(newTaskData.date); @@ -201,7 +189,7 @@ void UiState::setupCallbacks() reloadTasks(); }); - mainWindow_->global().on_createEvent([&](NewEventParams newEventParams) { + mainWindow_->global().on_create_event([&](NewEventParams newEventParams) { const Date &date = newEventParams.date; const std::string dateStr = SlintDateToStdString(date); auto source = miraiInstance_->getSourceById(newEventParams.sourceId); @@ -217,7 +205,7 @@ void UiState::setupCallbacks() reloadTasks(); }); - mainWindow_->global().on_saveEvent([&](SaveEventParams newEventParams) { + mainWindow_->global().on_save_event([&](SaveEventParams newEventParams) { const Date &date = newEventParams.date; const std::string dateStr = SlintDateToStdString(date); auto source = miraiInstance_->getSourceById(newEventParams.sourceId); @@ -311,7 +299,7 @@ void UiState::reloadTasks() } } days_ = slintDays; - mainWindow_->global().set_visible_tasks(days_); + mainWindow_->global().set_days(days_); auto unscheduledTasksView = view_.getUnscheduledTasks(); unscheduledTasks_->clear(); diff --git a/ui/Backend.slint b/ui/Backend.slint index fa7a279..b727134 100644 --- a/ui/Backend.slint +++ b/ui/Backend.slint @@ -77,25 +77,25 @@ export global Backend { in-out property<[string]> sources; in-out property no-source-selected; in-out property<[string]> tags; - in-out property<[Day]> visible_tasks; + in-out property<[Day]> days; in-out property<[TaskData]> unscheduled-tasks; - callback task_clicked(int, int); - callback source_clicked(int); - callback tag_clicked(int); + callback task-clicked(int, int); + callback source-clicked(int); + callback tag-clicked(int); - 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 delete_event_clicked(int, int); + 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 delete-event-clicked(int, int); - callback createTask(NewTaskData); - callback saveTask(SaveTaskData); - callback createEvent(NewEventParams); - callback saveEvent(SaveEventParams); + callback create-task(NewTaskData); + callback save-task(SaveTaskData); + callback create-event(NewEventParams); + callback save-event(SaveEventParams); - pure callback formatDate(Date) -> string; + pure callback format-date(Date) -> string; } diff --git a/ui/MainView.slint b/ui/MainView.slint index 86185fe..5e1c810 100644 --- a/ui/MainView.slint +++ b/ui/MainView.slint @@ -1,26 +1,18 @@ import { Backend, TaskData } from "Backend.slint"; import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint"; -import { SideBar } from "SideBar.slint"; -import { TaskLine } from "TaskLine.slint"; -import { EventGroup } from "EventGroup.slint"; -import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Palette } from "@vynui"; +import { TaskLine } from "./components/TaskLine.slint"; +import { EventGroup } from "./components/EventGroup.slint"; +import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@vynui"; import { NewTaskData, SaveTaskData } from "Backend.slint"; import { CreateTaskOrEvent } from "components/CreateTaskOrEvent.slint"; export component MainView inherits Rectangle { background: Palette.background; - private property icon-visible: @image-url("./images/visible.png"); - private property icon-not-visible: @image-url("./images/not-visible.png"); + private property icon-visible: Svg.visible; + private property icon-not-visible: Svg.not-visible; private property completed-tasks-visible: false; - pure function formatZeroPadding(number: int) -> string { - if (number < 10) { - return "0\{number}"; - } - return number; - } - VerticalLayout { horizontal-stretch: 1; padding: 16px; @@ -33,10 +25,10 @@ export component MainView inherits Rectangle { VButton { text: "Show/Hide completed tasks"; clicked => { - Backend.toggle_show_completed_tasks(); + Backend.toggle-show-completed-tasks(); completed-tasks-visible = !completed-tasks-visible; } - icon-source: completed-tasks-visible ? icon-visible : icon-not-visible; + icon-svg: completed-tasks-visible ? icon-visible : icon-not-visible; icon-colorize: Palette.control-foreground; } } @@ -55,12 +47,12 @@ export component MainView inherits Rectangle { VerticalLayout { alignment: start; spacing: 16px; - if Backend.visible_tasks.length == 0 && Backend.unscheduled-tasks.length == 0 : VText { + if Backend.days.length == 0 && Backend.unscheduled-tasks.length == 0 : VText { text: "There is no task to show"; horizontal-alignment: center; vertical-alignment: center; } - for day[dayIndex] in Backend.visible_tasks: VerticalLayout { + for day[dayIndex] in Backend.days: VerticalLayout { Rectangle { background: Palette.card-background; border-radius: 8px; @@ -69,7 +61,7 @@ export component MainView inherits Rectangle { HorizontalLayout { alignment: start; VText { - text: Backend.formatDate(day.date); + text: Backend.format-date(day.date); color: day.isLate ? Palette.orange : Palette.foreground; font-size: 1.2rem; } diff --git a/ui/Utils.slint b/ui/Utils.slint index f6a514e..4800524 100644 --- a/ui/Utils.slint +++ b/ui/Utils.slint @@ -1,14 +1,14 @@ import { Time } from "std-widgets.slint"; export global Utils { - pure function formatZeroPadding(number: int) -> string { + pure function format-zero-padding(number: int) -> string { if (number < 10) { return "0\{number}"; } return number; } - public pure function timeToString(time: Time) -> string { - return "\{formatZeroPadding(time.hour)}h\{formatZeroPadding(time.minute)}"; + public pure function time-to-string(time: Time) -> string { + return "\{format-zero-padding(time.hour)}h\{format-zero-padding(time.minute)}"; } } diff --git a/ui/appwindow.slint b/ui/appwindow.slint index 658417b..bfaa45a 100644 --- a/ui/appwindow.slint +++ b/ui/appwindow.slint @@ -1,9 +1,7 @@ import { Backend } from "Backend.slint"; import { Button, VerticalBox, CheckBox, Palette } from "std-widgets.slint"; -import { SideBar } from "SideBar.slint"; +import { SideBar } from "./components/SideBar.slint"; import { MainView } from "MainView.slint"; -import { TaskWindow } from "windows/TaskWindow.slint"; -import { EventWindow } from "windows/EventWindow.slint"; export component AppWindow inherits Window { @@ -23,4 +21,4 @@ export component AppWindow inherits Window { } -export { Backend, TaskWindow, EventWindow } // Export to make it visible to the C++ backend +export { Backend } // Export to make it visible to the C++ backend diff --git a/ui/components/CreateTaskOrEvent.slint b/ui/components/CreateTaskOrEvent.slint index d1f4032..879ba1a 100644 --- a/ui/components/CreateTaskOrEvent.slint +++ b/ui/components/CreateTaskOrEvent.slint @@ -26,7 +26,7 @@ export component CreateTaskOrEvent inherits Rectangle { } accepted => { if (task-or-event == 1) { - Backend.createTask({ + Backend.create-task({ sourceId: sourceInput.current-index, eventId: -1, title: newTaskTitleInput.text, @@ -34,7 +34,7 @@ export component CreateTaskOrEvent inherits Rectangle { date: taskDateInput.date }) } else { - Backend.createEvent({ + Backend.create-event({ sourceId: sourceInput.current-index, title: newTaskTitleInput.text, date: taskDateInput.date, diff --git a/ui/EventGroup.slint b/ui/components/EventGroup.slint similarity index 66% rename from ui/EventGroup.slint rename to ui/components/EventGroup.slint index 60d31cd..657df89 100644 --- a/ui/EventGroup.slint +++ b/ui/components/EventGroup.slint @@ -1,38 +1,37 @@ -import { Backend, TaskData, Event } from "Backend.slint"; +import { Backend, TaskData, Event } from "../Backend.slint"; import { ScrollView } from "std-widgets.slint"; -import { SideBar } from "SideBar.slint"; -import { VCheckBox, VButton, VTag, VPopupIconMenu, VText, Palette } from "@vynui"; -import { TaskLine } from "TaskLine.slint"; -import { Utils } from "Utils.slint"; +import { VCheckBox, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Palette } from "@vynui"; +import { TaskLine } from "./TaskLine.slint"; +import { Utils } from "../Utils.slint"; export component EventGroup { in property event; eventPopup := VPopupIconMenu { - VButton { - icon-source: @image-url("./images/add.png"); + VActionButton { + icon-svg: Svg.plus; icon-colorize: Colors.greenyellow; icon-size: 1.5rem; border-radius: 0; - clicked => { Backend.open_new_task_form({ + clicked => { Backend.open-new-task-form({ eventSourceId: event.sourceId, eventId: event.id, })} } - VButton { - icon-source: @image-url("./images/edit.png"); + VActionButton { + icon-svg: Svg.pen; icon-colorize: Colors.grey; icon-size: 1.5rem; border-radius: 0; - clicked => { Backend.open_edit_event_form(event.sourceId, event.id) } + clicked => { Backend.open-edit-event-form(event.sourceId, event.id) } } - VButton { - icon-source: @image-url("./images/delete.png"); + VActionButton { + icon-svg: Svg.trash; icon-colorize: Colors.pink; icon-size: 1.5rem; border-radius: 0; - clicked => { Backend.delete_event_clicked(event.sourceId, event.id) } + clicked => { Backend.delete-event-clicked(event.sourceId, event.id) } } } @@ -48,7 +47,7 @@ export component EventGroup { VerticalLayout { spacing: 4px; VText { - text: Utils.timeToString(event.startsAt); + text: Utils.time-to-string(event.startsAt); color: Palette.accent; } HorizontalLayout { @@ -61,7 +60,7 @@ export component EventGroup { } } VText { - text: Utils.timeToString(event.endsAt); + text: Utils.time-to-string(event.endsAt); color: Palette.accent; font-size: 0.8rem; horizontal-alignment: center; diff --git a/ui/SideBar.slint b/ui/components/SideBar.slint similarity index 59% rename from ui/SideBar.slint rename to ui/components/SideBar.slint index 4c0a59f..3f8f980 100644 --- a/ui/SideBar.slint +++ b/ui/components/SideBar.slint @@ -1,4 +1,4 @@ -import { Backend } from "Backend.slint"; +import { Backend } from "../Backend.slint"; import { ToggleButton, VText, Palette } from "@vynui"; export component SideBar inherits Rectangle { @@ -18,26 +18,14 @@ export component SideBar inherits Rectangle { text: "All"; text-alignment: left; active: Backend.no-source-selected; - clicked => { Backend.source_clicked(-1) } + clicked => { Backend.source-clicked(-1) } } for item[index] in Backend.sources-selected: ToggleButton { text: item.name; text-alignment: left; active: item.selected; - clicked => { Backend.source_clicked(index) } + clicked => { Backend.source-clicked(index) } } } - /*VText { - text: "Tags"; - font-size: 1.5rem; - } - VerticalLayout { - spacing: 4px; - for item[index] in Backend.tags: ToggleButton { - text: item; - text-alignment: left; - clicked => { Backend.tag_clicked(index) } - } - }*/ } } diff --git a/ui/TaskLine.slint b/ui/components/TaskLine.slint similarity index 77% rename from ui/TaskLine.slint rename to ui/components/TaskLine.slint index 3e188ae..58c0a4a 100644 --- a/ui/TaskLine.slint +++ b/ui/components/TaskLine.slint @@ -1,7 +1,7 @@ -import { Backend, TaskData } from "Backend.slint"; +import { Backend, TaskData } from "../Backend.slint"; import { ToggleButton } from "@vynui"; -import { VPopupIconMenu, VTag, VButton, VCheckBox, Palette } from "@vynui"; -import { TaskEdit } from "components/TaskEdit.slint"; +import { VPopupIconMenu, VTag, VButton, VActionButton, VCheckBox, Svg, Palette } from "@vynui"; +import { TaskEdit } from "./TaskEdit.slint"; import { Date } from "std-widgets.slint"; export component TaskLine inherits VerticalLayout { @@ -22,7 +22,7 @@ export component TaskLine inherits VerticalLayout { taskEdit := TaskEdit { accepted(task) => { - Backend.saveTask({ + Backend.save-task({ id: task.id, sourceId: task.sourceId, title: task.title, @@ -35,8 +35,8 @@ export component TaskLine inherits VerticalLayout { if !taskEdit.should-show : Rectangle { popup := VPopupIconMenu { - VButton { - icon-source: @image-url("./images/edit.png"); + VActionButton { + icon-svg: Svg.pen; icon-colorize: Colors.grey; icon-size: 1.5rem; border-radius: 0; @@ -51,13 +51,13 @@ export component TaskLine inherits VerticalLayout { } } - VButton { - icon-source: @image-url("./images/delete.png"); + VActionButton { + icon-svg: Svg.trash; icon-colorize: Colors.pink; icon-size: 1.5rem; border-radius: 0; clicked => { - Backend.delete_task_clicked(source-index, task-index) + Backend.delete-task-clicked(source-index, task-index) } } } @@ -65,7 +65,7 @@ export component TaskLine inherits VerticalLayout { ta := TouchArea { clicked => { checkbox.checked = !checkbox.checked; - Backend.task_clicked(source-index, task-index); + Backend.task-clicked(source-index, task-index); } pointer-event(e) => { if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) { @@ -84,7 +84,7 @@ export component TaskLine inherits VerticalLayout { text: task.title; checked: task.checked; toggled => { - Backend.task_clicked(source-index, task-index) + Backend.task-clicked(source-index, task-index) } } for tag[tag-index] in task.tags: VTag { diff --git a/ui/images/add.png b/ui/images/add.png deleted file mode 100644 index 7fece2f..0000000 Binary files a/ui/images/add.png and /dev/null differ diff --git a/ui/images/calendar.png b/ui/images/calendar.png deleted file mode 100644 index 3e2f37d..0000000 Binary files a/ui/images/calendar.png and /dev/null differ diff --git a/ui/images/delete.png b/ui/images/delete.png deleted file mode 100644 index fd50d08..0000000 Binary files a/ui/images/delete.png and /dev/null differ diff --git a/ui/images/edit.png b/ui/images/edit.png deleted file mode 100644 index 64588ef..0000000 Binary files a/ui/images/edit.png and /dev/null differ diff --git a/ui/images/not-visible.png b/ui/images/not-visible.png deleted file mode 100644 index 02386ad..0000000 Binary files a/ui/images/not-visible.png and /dev/null differ diff --git a/ui/images/settings.png b/ui/images/settings.png deleted file mode 100644 index ead5906..0000000 Binary files a/ui/images/settings.png and /dev/null differ diff --git a/ui/images/task.png b/ui/images/task.png deleted file mode 100644 index 59ef13c..0000000 Binary files a/ui/images/task.png and /dev/null differ diff --git a/ui/images/visible.png b/ui/images/visible.png deleted file mode 100644 index a5190e3..0000000 Binary files a/ui/images/visible.png and /dev/null differ diff --git a/ui/windows/EventWindow.slint b/ui/windows/EventWindow.slint deleted file mode 100644 index 1b42a32..0000000 --- a/ui/windows/EventWindow.slint +++ /dev/null @@ -1,100 +0,0 @@ -import { Date, Time, ComboBox } from "std-widgets.slint"; -import { VTimePicker, VDatePicker, VButton, VTextInput, VText, Palette } from "@vynui"; -import { Backend } from "../Backend.slint"; - -struct NewEventParams { - sourceId: int, - title: string, - date: Date, - startsAt: Time, - endsAt: Time -} - -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 sourceId <=> sourceInput.current-index; - in-out property eventId: -1; - in-out property taskDate <=> taskDateInput.date; - in-out property taskTitle <=> taskTitleInput.text; - in-out property