mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 17:03: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 { 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 { Date } from "std-widgets.slint";
|
||||
|
||||
|
@ -12,6 +12,8 @@ export struct TaskLineEditData {
|
|||
|
||||
export component TaskLine inherits VerticalLayout {
|
||||
in property<string> title;
|
||||
in property<string> source-name;
|
||||
in property<bool> hide-source-name;
|
||||
in property<bool> scheduled;
|
||||
in property<Date> date;
|
||||
in property<bool> checked;
|
||||
|
@ -82,12 +84,16 @@ export component TaskLine inherits VerticalLayout {
|
|||
alignment: start;
|
||||
spacing: 8px;
|
||||
checkbox := VCheckBox {
|
||||
text: root.title;
|
||||
text: "\{root.title}";
|
||||
checked: root.checked;
|
||||
toggled => {
|
||||
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);
|
||||
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) {
|
||||
refreshModels();
|
||||
});
|
||||
|
@ -338,6 +345,8 @@ void AppWindow::reloadTasks()
|
|||
unscheduledTasks_->clear();
|
||||
for (int taskIndex = 0; taskIndex < unscheduledTasksView.size(); ++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({
|
||||
.sourceId = task.sourceId(),
|
||||
.eventId = -1,
|
||||
|
|
|
@ -47,4 +47,5 @@ export global AppWindowModels {
|
|||
in-out property<[TaskData]> unscheduled-tasks;
|
||||
|
||||
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;
|
||||
TaskLine {
|
||||
title: task.title;
|
||||
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||
scheduled: task.date.year != 0;
|
||||
date: day.date;
|
||||
checked: task.checked;
|
||||
|
@ -187,6 +188,7 @@ export component MainView inherits Rectangle {
|
|||
padding-bottom: 8px;
|
||||
TaskLine {
|
||||
title: task.title;
|
||||
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||
checked: task.checked;
|
||||
allow-edit-date: true;
|
||||
delete => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue