From 2aa039e5fc91c5e8f0ad01102903b34306edcbfe Mon Sep 17 00:00:00 2001 From: Vyn Date: Wed, 9 Oct 2024 17:07:17 +0200 Subject: [PATCH] Add new 'Add task/event' bar directly in the main view --- .../mirai-core/include/mirai-core/TasksView.h | 1 + external/mirai-core/src/TasksView.cpp | 10 ++ external/slint-vynui/ActionButton.slint | 49 ++++++++++ external/slint-vynui/BurgerIcon.slint | 9 ++ external/slint-vynui/Button.slint | 18 +++- external/slint-vynui/LabeledComponent.slint | 50 ++++++++-- external/slint-vynui/Slider.slint | 34 +++++++ external/slint-vynui/TextInput.slint | 24 ++++- external/slint-vynui/ToggleButton.slint | 3 +- external/slint-vynui/index.slint | 6 +- src/UiState.cpp | 63 ++++++++---- src/UiState.h | 2 +- ui/Backend.slint | 43 +++++++++ ui/EventGroup.slint | 2 + ui/MainView.slint | 95 ++++++++++++++++++- ui/SideBar.slint | 12 ++- ui/windows/EventWindow.slint | 13 ++- ui/windows/TaskWindow.slint | 16 ++-- 18 files changed, 399 insertions(+), 51 deletions(-) create mode 100644 external/slint-vynui/ActionButton.slint create mode 100644 external/slint-vynui/BurgerIcon.slint create mode 100644 external/slint-vynui/Slider.slint diff --git a/external/mirai-core/include/mirai-core/TasksView.h b/external/mirai-core/include/mirai-core/TasksView.h index 8cb57d1..f96d151 100644 --- a/external/mirai-core/include/mirai-core/TasksView.h +++ b/external/mirai-core/include/mirai-core/TasksView.h @@ -44,6 +44,7 @@ class TasksView void removeFilters(); const Tags &getActiveTagsFilter(); const std::vector &getActiveFilesFilter(); + bool isSourceFilterActive(const std::string &sourceName); void hideCompletedTasks(bool hide); bool shouldHideCompletedTasks() const; diff --git a/external/mirai-core/src/TasksView.cpp b/external/mirai-core/src/TasksView.cpp index 063db6e..56c6111 100644 --- a/external/mirai-core/src/TasksView.cpp +++ b/external/mirai-core/src/TasksView.cpp @@ -177,6 +177,7 @@ void TasksView::removeSourceFilter(const std::string &fileName) void TasksView::removeFilters() { tagsFilter.clear(); + resourcesFilter.clear(); update(); } @@ -190,6 +191,15 @@ const std::vector &TasksView::getActiveFilesFilter() return resourcesFilter; } +bool TasksView::isSourceFilterActive(const std::string &sourceName) +{ + if (std::ranges::find(getActiveFilesFilter(), sourceName) == getActiveFilesFilter().end()) { + return false; + } + + return true; +} + void TasksView::hideCompletedTasks(bool hide) { shouldHideCompletedTasks_ = hide; diff --git a/external/slint-vynui/ActionButton.slint b/external/slint-vynui/ActionButton.slint new file mode 100644 index 0000000..924e48c --- /dev/null +++ b/external/slint-vynui/ActionButton.slint @@ -0,0 +1,49 @@ +import { Palette } from "Palette.slint"; +import { VText } from "Text.slint"; + +export component VActionButton inherits Rectangle { + + in property icon-source; + in property icon-colorize: Palette.foreground; + in property icon-size: 1rem; + in property icon-svg; + in property enabled <=> ta.enabled; + callback clicked; + + private property active: false; + + background: enabled ? Palette.control-background : Palette.control-background.darker(0.2); + border-radius: 4px; + + ta := TouchArea { + mouse-cursor: pointer; + clicked => { + active = !active; + root.clicked(); + } + } + + HorizontalLayout { + alignment: center; + spacing: 8px; + padding: 8px; + if root.icon-svg != "" : VerticalLayout { + alignment: center; + Path { + padding: 8px; + commands: root.icon-svg; + stroke: icon-colorize; + stroke-width: 2px; + width: icon-size; + height: icon-size; + fill: icon-colorize; + } + } + if root.icon-source.width != 0 : Image { + padding: 8px; + source: icon-source; + colorize: icon-colorize; + width: icon-size; + } + } +} diff --git a/external/slint-vynui/BurgerIcon.slint b/external/slint-vynui/BurgerIcon.slint new file mode 100644 index 0000000..23393dd --- /dev/null +++ b/external/slint-vynui/BurgerIcon.slint @@ -0,0 +1,9 @@ +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/Button.slint b/external/slint-vynui/Button.slint index 31ec156..1610c8d 100644 --- a/external/slint-vynui/Button.slint +++ b/external/slint-vynui/Button.slint @@ -5,9 +5,11 @@ export component VButton inherits Rectangle { in property text; in property text-color: Palette.foreground; + in property text-size: 1rem; in property icon-source; - in property icon-colorize; + in property icon-colorize: Palette.foreground; in property icon-size: 1rem; + in property icon-svg; in property enabled <=> ta.enabled; callback clicked; @@ -27,9 +29,20 @@ export component VButton inherits Rectangle { HorizontalLayout { alignment: center; spacing: 8px; - padding: 8px; + padding: 16px; padding-top: 4px; padding-bottom: 4px; + if root.icon-svg != "" : VerticalLayout { + alignment: center; + Path { + padding: 8px; + commands: root.icon-svg; + stroke: icon-colorize; + stroke-width: 2px; + width: icon-size; + height: icon-size; + } + } if root.icon-source.width != 0 : Image { padding: 8px; source: icon-source; @@ -39,6 +52,7 @@ export component VButton inherits Rectangle { if root.text != "" : VerticalLayout { VText { text: root.text; + font-size: root.text-size; color: root.text-color; horizontal-alignment: center; } diff --git a/external/slint-vynui/LabeledComponent.slint b/external/slint-vynui/LabeledComponent.slint index fe4e213..f112ca0 100644 --- a/external/slint-vynui/LabeledComponent.slint +++ b/external/slint-vynui/LabeledComponent.slint @@ -2,21 +2,59 @@ import { Palette } from "Palette.slint"; import { VText } from "Text.slint"; export component VLabeledComponent { - in property label <=> labelComponent.text; + in property label; + in property label-size: 1rem; + in property label-alignment: TextHorizontalAlignment.left; in property enabled: true; + in property no-background: false; + + function calc-background() -> brush { + if (no-background == true) { + return Palette.control-background.transparentize(1); + } + if (enabled == false) { + return Palette.control-background.darker(0.2); + } + return Palette.control-background; + } VerticalLayout { - labelComponent := VText { - - } + if root.label != "" : VerticalLayout { + padding-left: 4px; + padding-right: 4px; + VText { + text: root.label; + font-size: label-size; + horizontal-alignment: root.label-alignment; + } + } Rectangle { - background: enabled ? Palette.control-background : Palette.control-background.darker(0.2); + background: calc-background(); border-radius: 4px; VerticalLayout { - padding: 4px; @children } } } } + +export component CommonComponentBackground { + in property enabled: true; + in property no-background: false; + + function calc-background() -> brush { + if (no-background == true) { + return Palette.control-background.transparentize(1); + } + if (enabled == false) { + return Palette.control-background.darker(0.2); + } + return Palette.control-background; + } + + Rectangle { + background: calc-background(); + @children + } +} diff --git a/external/slint-vynui/Slider.slint b/external/slint-vynui/Slider.slint new file mode 100644 index 0000000..f4a4a61 --- /dev/null +++ b/external/slint-vynui/Slider.slint @@ -0,0 +1,34 @@ +import { VLabeledComponent } from "LabeledComponent.slint"; +import { Palette } from "Palette.slint"; +import { Slider } from "std-widgets.slint"; +import { VText } from "Text.slint"; + +export component VSlider inherits VLabeledComponent { + in property show-value; + in-out property value; + + init => { + sliderComponent.value = root.value; + } + + pure callback format-value(float) -> string; + format-value(value) => { + return "\{value}"; + } + + callback released <=> sliderComponent.released; + in property minimum <=> sliderComponent.minimum; + in property maximum <=> sliderComponent.maximum; + + VerticalLayout { + spacing: 8px; + VText { + horizontal-alignment: center; + text: format-value(sliderComponent.value); + color: Palette.foreground-hint; + } + sliderComponent := Slider { + + } + } +} diff --git a/external/slint-vynui/TextInput.slint b/external/slint-vynui/TextInput.slint index d3327c4..4f67c12 100644 --- a/external/slint-vynui/TextInput.slint +++ b/external/slint-vynui/TextInput.slint @@ -1,13 +1,31 @@ import { VLabeledComponent } from "LabeledComponent.slint"; import { Palette } from "Palette.slint"; +import { VText } from "Text.slint"; export component VTextInput inherits VLabeledComponent { in-out property text <=> textInputComponent.text; + out property has-focus <=> textInputComponent.has-focus; + in-out property placeholder <=> textInputComponent.accessible-placeholder-text; in-out property wrap <=> textInputComponent.wrap; callback accepted(); - textInputComponent := TextInput { - color: Palette.foreground; - accepted => { root.accepted() } + VerticalLayout { + padding: 4px; + padding-left: 8px; + padding-right: 8px; + textInputComponent := TextInput { + color: Palette.foreground; + accepted => { root.accepted() } + HorizontalLayout { + alignment: start; + VText { + visible: textInputComponent.text == ""; + color: Palette.foreground-hint; + text: root.placeholder; + } + } + + } } + } diff --git a/external/slint-vynui/ToggleButton.slint b/external/slint-vynui/ToggleButton.slint index e69f9b9..57da3a8 100644 --- a/external/slint-vynui/ToggleButton.slint +++ b/external/slint-vynui/ToggleButton.slint @@ -6,9 +6,9 @@ export component ToggleButton inherits Rectangle { in property text <=> text-component.text; in property text-color <=> text-component.color; in property text-alignment <=> text-component.horizontal-alignment; + in property active: false; callback clicked; - private property active: false; background: root.active ? Palette.control-background : ta.has-hover ? Palette.control-background.transparentize(0.5) @@ -18,7 +18,6 @@ export component ToggleButton inherits Rectangle { ta := TouchArea { mouse-cursor: pointer; clicked => { - active = !active; root.clicked(); } } diff --git a/external/slint-vynui/index.slint b/external/slint-vynui/index.slint index 9432683..1fa9f0c 100644 --- a/external/slint-vynui/index.slint +++ b/external/slint-vynui/index.slint @@ -1,11 +1,15 @@ export { Palette } from "Palette.slint"; export { VButton } from "Button.slint"; +export { VActionButton } from "ActionButton.slint"; export { VText } from "Text.slint"; export { VCheckBox } from "CheckBox.slint"; export { VDatePicker } from "DatePicker.slint"; export { VTimePicker } from "TimePicker.slint"; -export { VLabeledComponent } from "LabeledComponent.slint"; +export { VLabeledComponent, CommonComponentBackground } from "LabeledComponent.slint"; export { VPopupIconMenu } from "PopupIconMenu.slint"; export { VTag } from "Tag.slint"; export { VTextInput } from "TextInput.slint"; +export { VSlider } from "Slider.slint"; export { ToggleButton } from "ToggleButton.slint"; + +export { BurgerIcon } from "BurgerIcon.slint"; diff --git a/src/UiState.cpp b/src/UiState.cpp index d4c0052..a6b6670 100644 --- a/src/UiState.cpp +++ b/src/UiState.cpp @@ -34,14 +34,22 @@ UiState::UiState(mirai::Mirai *miraiInstance) : miraiInstance_(miraiInstance), view_(miraiInstance) { - sources_ = std::make_shared>(); + sources_ = std::make_shared>(); days_ = std::make_shared>(); unscheduledTasks_ = std::make_shared>(); tags_ = std::make_shared>(); + auto sourcesNames = std::make_shared>( + sources_, + [&](const Source &a) { + return a.name; + } + ); - taskWindow_->global().set_sources(sources_); + mainWindow_->global().set_sources(sourcesNames); + taskWindow_->global().set_sources_selected(sources_); + taskWindow_->global().set_sources(sourcesNames); taskWindow_->global().set_tags(tags_); - eventWindow_->global().set_sources(sources_); + eventWindow_->global().set_sources_selected(sources_); eventWindow_->global().set_tags(tags_); view_.update(); @@ -76,7 +84,7 @@ std::optional stringToDate(const std::string &dateStr) void UiState::setupTaskWindowCallbacks() { - taskWindow_->on_save([&](SaveTaskData newTaskData) { + mainWindow_->global().on_saveTask([&](SaveTaskData newTaskData) { auto source = miraiInstance_->getSourceById(newTaskData.sourceId); assert(source); auto task = source->getTaskById(newTaskData.id); @@ -103,7 +111,7 @@ void UiState::setupTaskWindowCallbacks() taskWindow_->hide(); }); - taskWindow_->on_create([&](NewTaskData newTaskData) { + mainWindow_->global().on_createTask([&](NewTaskData newTaskData) { const Date &date = newTaskData.date; const std::string dateStr = SlintDateToStdString(date); auto source = miraiInstance_->getSourceById(newTaskData.sourceId); @@ -152,7 +160,7 @@ void UiState::setupEventWindowCallbacks() assert(source); auto event = source->getEventById(eventId); assert(event); - eventWindow_->global().set_sources(sources_); + eventWindow_->global().set_sources_selected(sources_); eventWindow_->global().set_tags(tags_); eventWindow_->set_sourceId(sourceId); @@ -177,7 +185,7 @@ void UiState::setupEventWindowCallbacks() reloadTasks(); }); - eventWindow_->on_create([&](NewEventParams newEventParams) { + mainWindow_->global().on_createEvent([&](NewEventParams newEventParams) { const Date &date = newEventParams.date; const std::string dateStr = SlintDateToStdString(date); auto source = miraiInstance_->getSourceById(newEventParams.sourceId); @@ -195,7 +203,7 @@ void UiState::setupEventWindowCallbacks() eventWindow_->hide(); }); - eventWindow_->on_save([&](SaveEventParams newEventParams) { + mainWindow_->global().on_saveEvent([&](SaveEventParams newEventParams) { const Date &date = newEventParams.date; const std::string dateStr = SlintDateToStdString(date); auto source = miraiInstance_->getSourceById(newEventParams.sourceId); @@ -239,15 +247,28 @@ void UiState::setupCallbacks() }); mainWindow_->global().on_source_clicked([&](int index) { - const auto &source = miraiInstance_->getSourceById(index); - const auto &sourceName = source->getName(); - if (std::ranges::find(view_.getActiveFilesFilter(), sourceName) == - view_.getActiveFilesFilter().end()) { - view_.addSourceFilter(sourceName); + // index with value -1 is equal to no selection, aka "All" + if (index == -1) { + view_.removeFilters(); } else { - view_.removeSourceFilter(sourceName); + view_.removeFilters(); + const auto &source = miraiInstance_->getSourceById(index); + const auto &sourceName = source->getName(); + view_.addSourceFilter(sourceName); + /* + // Old behavior, I keep it here for now + const auto &source = miraiInstance_->getSourceById(index); + const auto &sourceName = source->getName(); + if (std::ranges::find(view_.getActiveFilesFilter(), sourceName) == + view_.getActiveFilesFilter().end()) { + view_.addSourceFilter(sourceName); + } else { + view_.removeSourceFilter(sourceName); + } + */ } view_.update(); + reloadSources(); reloadTasks(); }); @@ -294,7 +315,7 @@ void UiState::setupCallbacks() }); mainWindow_->global().on_open_new_task_form([&](OpenNewTaskFormParams params) { - taskWindow_->global().set_sources(sources_); + taskWindow_->global().set_sources_selected(sources_); taskWindow_->global().set_tags(tags_); auto todayDate = std::chrono::year_month_day{ @@ -329,7 +350,7 @@ void UiState::setupCallbacks() reloadTasks(); }); - mainWindow_->global().set_sources(sources_); + mainWindow_->global().set_sources_selected(sources_); mainWindow_->global().set_tags(tags_); mainWindow_->global().set_visible_tasks(days_); @@ -450,9 +471,17 @@ void UiState::reloadTasks() void UiState::reloadSources() { sources_->clear(); + bool noSourceSelected = true; for (const auto &source : miraiInstance_->getSources()) { - sources_->push_back(slint::SharedString(source->getName())); + bool isSourceSelected = view_.isSourceFilterActive(source->getName()); + sources_->push_back( + {.name = slint::SharedString(source->getName()), .selected = isSourceSelected} + ); + if (isSourceSelected) { + noSourceSelected = false; + } } + mainWindow_->global().set_no_source_selected(noSourceSelected); } void UiState::reloadTags() diff --git a/src/UiState.h b/src/UiState.h index 9a35684..c0cab71 100644 --- a/src/UiState.h +++ b/src/UiState.h @@ -29,7 +29,7 @@ class UiState void setupEventWindowCallbacks(); void setupUtilsCallbacks(); - std::shared_ptr> sources_; + std::shared_ptr> sources_; std::shared_ptr> tags_; std::shared_ptr> days_; std::shared_ptr> unscheduledTasks_; diff --git a/ui/Backend.slint b/ui/Backend.slint index bb9513f..821821d 100644 --- a/ui/Backend.slint +++ b/ui/Backend.slint @@ -1,6 +1,42 @@ import { Date, Time } from "std-widgets.slint"; +export struct NewTaskData { + sourceId: int, + eventId: int, + title: string, + scheduled: bool, + date: Date +} +export struct SaveTaskData { + sourceId: int, + id: int, + title: string, + scheduled: bool, + date: Date, +} + +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 struct Source { + name: string, + selected: bool +} export struct TaskData { sourceId: int, @@ -36,7 +72,9 @@ struct OpenNewTaskFormParams { } export global Backend { + in-out property<[Source]> sources-selected; 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<[TaskData]> unscheduled-tasks; @@ -53,5 +91,10 @@ export global Backend { callback delete_task_clicked(int, int); callback delete_event_clicked(int, int); + callback createTask(NewTaskData); + callback saveTask(SaveTaskData); + callback createEvent(NewEventParams); + callback saveEvent(SaveEventParams); + pure callback formatDate(Date) -> string; } diff --git a/ui/EventGroup.slint b/ui/EventGroup.slint index e431737..60d31cd 100644 --- a/ui/EventGroup.slint +++ b/ui/EventGroup.slint @@ -63,6 +63,8 @@ export component EventGroup { VText { text: Utils.timeToString(event.endsAt); color: Palette.accent; + font-size: 0.8rem; + horizontal-alignment: center; } } VerticalLayout { diff --git a/ui/MainView.slint b/ui/MainView.slint index 9f7691a..40c8ef8 100644 --- a/ui/MainView.slint +++ b/ui/MainView.slint @@ -1,9 +1,10 @@ import { Backend, TaskData } from "Backend.slint"; -import { Button, VerticalBox, CheckBox, ScrollView } from "std-widgets.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, VCheckBox, VButton, VTag, VText, Palette } from "@vynui"; +import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Palette } from "@vynui"; +import { NewTaskData, SaveTaskData } from "Backend.slint"; export component MainView inherits Rectangle { @@ -37,6 +38,7 @@ export component MainView inherits Rectangle { icon-source: @image-url("./images/add.png"); icon-colorize: Colors.greenyellow; } + VButton { text: "New event"; clicked => { Backend.open_new_event_form() } @@ -58,6 +60,95 @@ export component MainView inherits Rectangle { background: Palette.background.brighter(0.2); height: 1px; } + + Rectangle { + border-color: newTaskTitleInput.text != "" ? Palette.card-background : transparent; + border-width: newTaskTitleInput.text != "" ? 4px : 0px; + border-radius: newTaskTitleInput.text != "" ? 8px : 0px; + animate border-color, border-width { + duration: 500ms; + } + VerticalLayout { + in-out property task-or-event: 1; + spacing: 8px; + padding: newTaskTitleInput.text != "" ? 16px : 0px; + animate padding { + duration: 250ms; + } + Rectangle { + min-height: 0px; + max-height: newTaskTitleInput.text != "" ? 512px : 0px; + opacity: newTaskTitleInput.text != "" ? 1 : 0; + clip: true; + animate max-height, opacity { + duration: 500ms; + } + + HorizontalLayout { + alignment: start; + spacing: 8px; + VerticalLayout { + alignment: end; + VButton { + text: task-or-event == 1 ? "Task" : "Event"; + clicked => { task-or-event = task-or-event == 1 ? 0 : 1 } + } + } + VText { text: "for"; vertical-alignment: bottom;} + VerticalLayout { + alignment: end; + sourceInput := ComboBox { + model: Backend.sources; + } + } + VText { text: "on"; vertical-alignment: bottom;} + taskDateInput := VDatePicker { + label: "Date"; + enabled: true; + } + HorizontalLayout { + visible: task-or-event == 0; + HorizontalLayout { + spacing: 4px; + VText { text: "between"; vertical-alignment: bottom; } + eventStartTimeInput := VTimePicker { + label: "Starts at"; + } + VText { text: "and"; vertical-alignment: bottom; } + eventEndTimeInput := VTimePicker { + label: "Ends at"; + } + } + } + + } + } + newTaskTitleInput := VTextInput { + placeholder: "Add task"; + accepted => { + if (task-or-event == 1) { + Backend.createTask({ + sourceId: sourceInput.current-index, + eventId: -1, + title: newTaskTitleInput.text, + scheduled: taskDateInput.date.year != 0, + date: taskDateInput.date + }) + } else { + Backend.createEvent({ + sourceId: sourceInput.current-index, + title: newTaskTitleInput.text, + date: taskDateInput.date, + startsAt: eventStartTimeInput.time, + endsAt: eventEndTimeInput.time, + }); + } + newTaskTitleInput.text = ""; + } + } + } + } + Flickable { horizontal-stretch: 1; VerticalLayout { diff --git a/ui/SideBar.slint b/ui/SideBar.slint index 97408ac..4c0a59f 100644 --- a/ui/SideBar.slint +++ b/ui/SideBar.slint @@ -3,6 +3,7 @@ import { ToggleButton, VText, Palette } from "@vynui"; export component SideBar inherits Rectangle { background: Palette.pane; + VerticalLayout { alignment: start; padding: 16px; @@ -13,9 +14,16 @@ export component SideBar inherits Rectangle { } VerticalLayout { spacing: 4px; - for item[index] in Backend.sources: ToggleButton { - text: item; + ToggleButton { + text: "All"; text-alignment: left; + active: Backend.no-source-selected; + 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) } } } diff --git a/ui/windows/EventWindow.slint b/ui/windows/EventWindow.slint index 4772527..1b42a32 100644 --- a/ui/windows/EventWindow.slint +++ b/ui/windows/EventWindow.slint @@ -2,7 +2,7 @@ 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 { +struct NewEventParams { sourceId: int, title: string, date: Date, @@ -10,7 +10,7 @@ export struct NewEventParams { endsAt: Time } -export struct SaveEventParams { +struct SaveEventParams { sourceId: int, id: int, title: string, @@ -51,15 +51,15 @@ export component EventWindow inherits Window { enabled: eventId == -1; } + taskDateInput := VDatePicker { + label: "Date"; + } + taskTitleInput := VTextInput { label: "Title"; wrap: word-wrap; } - taskDateInput := VDatePicker { - label: "Date"; - } - HorizontalLayout { spacing: 4px; eventStartTimeInput := VTimePicker { @@ -71,7 +71,6 @@ export component EventWindow inherits Window { } } - VButton { text: eventId == -1 ? "Create" : "Save"; clicked => { diff --git a/ui/windows/TaskWindow.slint b/ui/windows/TaskWindow.slint index e96d44a..7f20312 100644 --- a/ui/windows/TaskWindow.slint +++ b/ui/windows/TaskWindow.slint @@ -2,7 +2,7 @@ import { Date, ComboBox } from "std-widgets.slint"; import { VTextInput, VButton, VDatePicker, VText, VCheckBox, Palette } from "@vynui"; import { Backend } from "../Backend.slint"; -export struct NewTaskData { +struct NewTaskData { sourceId: int, eventId: int, title: string, @@ -10,7 +10,7 @@ export struct NewTaskData { date: Date } -export struct SaveTaskData { +struct SaveTaskData { sourceId: int, id: int, title: string, @@ -50,12 +50,6 @@ export component TaskWindow inherits Window { enabled: taskId == -1 && eventId == -1; } - taskTitleInput := VTextInput { - label: "Content"; - wrap: word-wrap; - accepted => { button.clicked() } - } - scheduledInput := VCheckBox { text: "Scheduled"; } @@ -65,6 +59,12 @@ export component TaskWindow inherits Window { enabled: eventId == -1 && scheduledInput.checked; } + taskTitleInput := VTextInput { + label: "Content"; + wrap: word-wrap; + accepted => { button.clicked() } + } + button := VButton { text: taskId == -1 ? "Create" : "Save"; clicked => {