mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
Add source's name next to each task
This commit is contained in:
parent
e2cd994026
commit
a03e71890c
4 changed files with 20 additions and 2 deletions
|
@ -1,5 +1,5 @@
|
||||||
import { ToggleButton } from "@selenite";
|
import { ToggleButton } from "@selenite";
|
||||||
import { VPopupIconMenu, VTag, VButton, VActionButton, VCheckBox, Svg, Palette } from "@selenite";
|
import { VPopupIconMenu, VTag, VText, VButton, VActionButton, VCheckBox, Svg, Palette } from "@selenite";
|
||||||
import { TaskEdit } from "./TaskEdit.slint";
|
import { TaskEdit } from "./TaskEdit.slint";
|
||||||
import { Date } from "std-widgets.slint";
|
import { Date } from "std-widgets.slint";
|
||||||
|
|
||||||
|
@ -12,6 +12,8 @@ export struct TaskLineEditData {
|
||||||
|
|
||||||
export component TaskLine inherits VerticalLayout {
|
export component TaskLine inherits VerticalLayout {
|
||||||
in property<string> title;
|
in property<string> title;
|
||||||
|
in property<string> source-name;
|
||||||
|
in property<bool> hide-source-name;
|
||||||
in property<bool> scheduled;
|
in property<bool> scheduled;
|
||||||
in property<Date> date;
|
in property<Date> date;
|
||||||
in property<bool> checked;
|
in property<bool> checked;
|
||||||
|
@ -82,12 +84,16 @@ export component TaskLine inherits VerticalLayout {
|
||||||
alignment: start;
|
alignment: start;
|
||||||
spacing: 8px;
|
spacing: 8px;
|
||||||
checkbox := VCheckBox {
|
checkbox := VCheckBox {
|
||||||
text: root.title;
|
text: "\{root.title}";
|
||||||
checked: root.checked;
|
checked: root.checked;
|
||||||
toggled => {
|
toggled => {
|
||||||
root.toggle-check()
|
root.toggle-check()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if !hide-source-name : source-name := VTag {
|
||||||
|
text-color: Palette.accent;
|
||||||
|
text: "\{root.source-name}";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,6 +98,13 @@ void AppWindow::setupCallbacks()
|
||||||
assert(source);
|
assert(source);
|
||||||
return source->id;
|
return source->id;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
models().on_get_source_name_from_id([&](int sourceId) {
|
||||||
|
auto source = miraiInstance_->getSourceById(sourceId);
|
||||||
|
assert(source);
|
||||||
|
return slint::SharedString(source->name());
|
||||||
|
});
|
||||||
|
|
||||||
miraiInstance_->onSourceAdded([&](mirai::Source *source) {
|
miraiInstance_->onSourceAdded([&](mirai::Source *source) {
|
||||||
refreshModels();
|
refreshModels();
|
||||||
});
|
});
|
||||||
|
@ -338,6 +345,8 @@ void AppWindow::reloadTasks()
|
||||||
unscheduledTasks_->clear();
|
unscheduledTasks_->clear();
|
||||||
for (int taskIndex = 0; taskIndex < unscheduledTasksView.size(); ++taskIndex) {
|
for (int taskIndex = 0; taskIndex < unscheduledTasksView.size(); ++taskIndex) {
|
||||||
auto &task = unscheduledTasksView.at(taskIndex);
|
auto &task = unscheduledTasksView.at(taskIndex);
|
||||||
|
const auto &source = miraiInstance_->getSourceById(task.sourceId());
|
||||||
|
std::println("request name for source id {} : {}", task.sourceId(), source->name());
|
||||||
unscheduledTasks_->push_back({
|
unscheduledTasks_->push_back({
|
||||||
.sourceId = task.sourceId(),
|
.sourceId = task.sourceId(),
|
||||||
.eventId = -1,
|
.eventId = -1,
|
||||||
|
|
|
@ -47,4 +47,5 @@ export global AppWindowModels {
|
||||||
in-out property<[TaskData]> unscheduled-tasks;
|
in-out property<[TaskData]> unscheduled-tasks;
|
||||||
|
|
||||||
callback get-source-id-from-name(string) -> int;
|
callback get-source-id-from-name(string) -> int;
|
||||||
|
pure callback get-source-name-from-id(int) -> string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,6 +144,7 @@ export component MainView inherits Rectangle {
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
TaskLine {
|
TaskLine {
|
||||||
title: task.title;
|
title: task.title;
|
||||||
|
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||||
scheduled: task.date.year != 0;
|
scheduled: task.date.year != 0;
|
||||||
date: day.date;
|
date: day.date;
|
||||||
checked: task.checked;
|
checked: task.checked;
|
||||||
|
@ -187,6 +188,7 @@ export component MainView inherits Rectangle {
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
TaskLine {
|
TaskLine {
|
||||||
title: task.title;
|
title: task.title;
|
||||||
|
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||||
checked: task.checked;
|
checked: task.checked;
|
||||||
allow-edit-date: true;
|
allow-edit-date: true;
|
||||||
delete => {
|
delete => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue