Add color for events and source tags

This commit is contained in:
Vyn 2025-06-26 10:12:23 +02:00
parent d208fc6ca4
commit 4bca7fac3e
Signed by: vyn
GPG key ID: E1B2BE34E7A971E7
12 changed files with 95 additions and 39 deletions

View file

@ -12,6 +12,7 @@
#include "mirai-core/MarkdownDataProvider.h"
#include "mirai-core/Mirai.h"
#include "selenite/palette.h"
#include "slint_color.h"
#include "slint_string.h"
#include "ui.h"
#include <bits/chrono.h>
@ -97,6 +98,19 @@ void AppWindow::setupCallbacks()
return slint::SharedString(source->name());
});
models().on_get_source_color_from_id_as_hex([&](int sourceId) {
auto source = miraiInstance_->getSourceById(sourceId);
assert(source);
return slint::SharedString(source->color());
});
models().on_get_source_color_from_id_as_color([&](int sourceId) {
auto source = miraiInstance_->getSourceById(sourceId);
assert(source);
auto color = selenite::hexStringToColor(source->color());
return slint::Color::from_rgb_uint8(color.r, color.g, color.b);
});
models().on_get_source_path_from_id([&](int sourceId) {
auto source = miraiInstance_->getSourceById(sourceId);
assert(source);
@ -150,8 +164,11 @@ void AppWindow::setupCallbacks()
miraiInstance_->addSource(std::string(name), "FileSystemMarkdown", std::move(file));
});
actions().on_edit_source([&](int sourceId, slint::SharedString name, slint::SharedString path) {
miraiInstance_->editSource(sourceId, std::string(name), std::string(path));
actions().on_edit_source([&](int sourceId, slint::SharedString name, slint::SharedString color,
slint::SharedString path) {
miraiInstance_->editSource(
sourceId, std::string(name), std::string(color), std::string(path)
);
});
actions().on_delete_task_clicked([&](int sourceId, int taskId) {