mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 17:03:19 +00:00
Compare commits
3 commits
2e1e5db5ea
...
ef56efd314
Author | SHA1 | Date | |
---|---|---|---|
ef56efd314 | |||
72b004b7b0 | |||
f2f472a595 |
26 changed files with 112 additions and 25034 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -13,3 +13,6 @@
|
|||
[submodule "external/rei-json"]
|
||||
path = external/rei-json
|
||||
url = https://codeberg.org/vyn/rei-json.git
|
||||
[submodule "external/mirai-core/external/rei-json"]
|
||||
path = external/mirai-core/external/rei-json
|
||||
url = https://codeberg.org/vyn/rei-json.git
|
||||
|
|
|
@ -31,7 +31,6 @@ add_subdirectory(external/evalyte-cpp-common)
|
|||
add_executable(mirai
|
||||
src/main.cpp
|
||||
src/windows/AppWindow/AppWindow.cpp
|
||||
src/windows/SettingsWindow/SettingsWindow.cpp
|
||||
src/SeleniteSetup.cpp
|
||||
src/shared/Utils.cpp
|
||||
)
|
||||
|
@ -49,6 +48,10 @@ target_link_libraries(mirai PRIVATE evalyte-cpp-common)
|
|||
target_include_directories(mirai PRIVATE "external")
|
||||
target_link_libraries(mirai PRIVATE mirai-core)
|
||||
|
||||
add_subdirectory(external/rei-json)
|
||||
target_include_directories(mirai PRIVATE "external/rei-json/include")
|
||||
target_link_libraries(mirai PRIVATE rei-json)
|
||||
|
||||
slint_target_sources(
|
||||
mirai src/ui.slint
|
||||
NAMESPACE ui
|
||||
|
|
4
external/mirai-core/CMakeLists.txt
vendored
4
external/mirai-core/CMakeLists.txt
vendored
|
@ -21,3 +21,7 @@ add_library(mirai-core
|
|||
|
||||
target_include_directories(mirai-core PRIVATE "external")
|
||||
target_include_directories(mirai-core PRIVATE "include/mirai-core")
|
||||
|
||||
add_subdirectory(external/rei-json)
|
||||
target_include_directories(mirai-core PRIVATE "external/rei-json/include")
|
||||
target_link_libraries(mirai-core PRIVATE rei-json)
|
||||
|
|
24767
external/mirai-core/external/nlohmann/json.hpp
vendored
24767
external/mirai-core/external/nlohmann/json.hpp
vendored
File diff suppressed because it is too large
Load diff
1
external/mirai-core/external/rei-json
vendored
Submodule
1
external/mirai-core/external/rei-json
vendored
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 63e7986b0901449657c3874ed7b19618315e9f01
|
69
external/mirai-core/src/Mirai.cpp
vendored
69
external/mirai-core/src/Mirai.cpp
vendored
|
@ -8,8 +8,11 @@
|
|||
#include "DataProvider.h"
|
||||
#include "MarkdownDataProvider.h"
|
||||
#include "Source.h"
|
||||
#include "nlohmann/json.hpp"
|
||||
#include "rei-json/Array.h"
|
||||
#include "rei-json/Object.h"
|
||||
#include "rei-json/json.h"
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <print>
|
||||
|
@ -21,31 +24,32 @@ namespace mirai
|
|||
|
||||
void Mirai::loadConfig(const std::string &path)
|
||||
{
|
||||
auto configJson = nlohmann::json::parse(R"(
|
||||
{
|
||||
"files": []
|
||||
}
|
||||
)");
|
||||
std::ifstream file(path);
|
||||
if (!file) {
|
||||
|
||||
return;
|
||||
}
|
||||
configJson = nlohmann::json::parse(file);
|
||||
std::stringstream buffer;
|
||||
buffer << file.rdbuf();
|
||||
auto jsonStr = buffer.str();
|
||||
|
||||
assert(configJson.is_object());
|
||||
assert(configJson["files"].is_array());
|
||||
auto jsonSources = configJson["files"];
|
||||
for (const auto &filePath : jsonSources) {
|
||||
assert(filePath.is_object());
|
||||
const auto name = filePath["name"].get<std::string>();
|
||||
const auto path = filePath["path"].get<std::string>();
|
||||
auto configJson = rei::json::parse(jsonStr);
|
||||
|
||||
assert(configJson.isObject());
|
||||
assert(configJson.asObject()["files"].isArray());
|
||||
auto jsonSources = configJson.asObject()["files"].asArray();
|
||||
for (int i = 0; i < jsonSources.count(); ++i) {
|
||||
auto &filePath = jsonSources[i];
|
||||
assert(filePath.isObject());
|
||||
const auto name = filePath.asObject().getString("name");
|
||||
const auto path = filePath.asObject().getString("path");
|
||||
std::unique_ptr<DataProvider> file = std::make_unique<MarkdownDataProvider>(path);
|
||||
DataProvider *sourceDataProvider = file.release();
|
||||
sourceDataProvider->load();
|
||||
sources_.push_back(std::make_unique<Source>(
|
||||
SourceConstructor{.name = name, .sourceDataProvider = sourceDataProvider}
|
||||
));
|
||||
sources_.push_back(
|
||||
std::make_unique<Source>(
|
||||
SourceConstructor{.name = name, .sourceDataProvider = sourceDataProvider}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,20 +60,19 @@ void Mirai::saveConfig()
|
|||
std::print(std::cerr, "Can't save config to {}", configPath_);
|
||||
return;
|
||||
}
|
||||
auto configJson = nlohmann::json::parse(R"(
|
||||
{
|
||||
"files": []
|
||||
}
|
||||
)");
|
||||
auto files = rei::json::JsonArray{};
|
||||
auto configJson = rei::json::JsonObject{};
|
||||
configJson.set("files", files);
|
||||
for (auto &source : sources_) {
|
||||
nlohmann::json jsonSource;
|
||||
jsonSource["name"] = source->name();
|
||||
|
||||
rei::json::JsonObject jsonSource;
|
||||
jsonSource.set("name", source->name());
|
||||
auto dataProvider = dynamic_cast<MarkdownDataProvider *>(source->dataProvider());
|
||||
jsonSource["path"] = dataProvider->path();
|
||||
jsonSource["type"] = "FileSystemMarkdown";
|
||||
configJson["files"].push_back(jsonSource);
|
||||
jsonSource.set("path", dataProvider->path());
|
||||
jsonSource.set("type", "FileSystemMarkdown");
|
||||
configJson.getArray("files").push(jsonSource);
|
||||
}
|
||||
file << configJson.dump(4);
|
||||
file << rei::json::toString(configJson);
|
||||
file.close();
|
||||
}
|
||||
|
||||
|
@ -84,9 +87,11 @@ void Mirai::addSource(
|
|||
{
|
||||
DataProvider *sourceDataProvider = source.release();
|
||||
sourceDataProvider->load();
|
||||
sources_.push_back(std::make_unique<Source>(
|
||||
SourceConstructor{.name = name, .sourceDataProvider = sourceDataProvider}
|
||||
));
|
||||
sources_.push_back(
|
||||
std::make_unique<Source>(
|
||||
SourceConstructor{.name = name, .sourceDataProvider = sourceDataProvider}
|
||||
)
|
||||
);
|
||||
saveConfig();
|
||||
sourceAdded.emit(nullptr);
|
||||
};
|
||||
|
|
2
external/rei-json
vendored
2
external/rei-json
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 2639dba60a990f9dbc79b5204a925a101ecf24ba
|
||||
Subproject commit 63e7986b0901449657c3874ed7b19618315e9f01
|
2
external/selenite
vendored
2
external/selenite
vendored
|
@ -1 +1 @@
|
|||
Subproject commit 810607c01fa659f31bd11bd41a9ee5611e5db8ea
|
||||
Subproject commit 6ff7dd8ea890bec8f4f61304e64bbfeabd61e7a8
|
|
@ -150,7 +150,6 @@ export component Calendar inherits Rectangle {
|
|||
ta := TouchArea {
|
||||
pointer-event(e) => {
|
||||
if (e.button == PointerEventButton.right && e.kind == PointerEventKind.up) {
|
||||
debug(ta.mouse-x, " ", ta.mouse-y);
|
||||
eventActionsPopup.show(ta.mouse-x, ta.mouse-y);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
|
||||
import { AppModels } from "../shared/Models.slint";
|
||||
import { Date, Time, Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VActionButton, VTag, VText, Svg, VTextInput, Palette } from "@selenite";
|
||||
|
||||
|
@ -16,7 +16,7 @@ export component CreateTaskOrEvent inherits Rectangle {
|
|||
|
||||
function accepted() {
|
||||
root.create-task({
|
||||
sourceId: AppWindowModels.get-source-id-from-name(sourceInput.current-value),
|
||||
sourceId: AppModels.get-source-id-from-name(sourceInput.current-value),
|
||||
title: newTaskTitleInput.text,
|
||||
date: taskDateInput.date
|
||||
});
|
||||
|
@ -39,7 +39,7 @@ export component CreateTaskOrEvent inherits Rectangle {
|
|||
newTaskTitleInput := VTextInput {
|
||||
placeholder: "Enter new task";
|
||||
started-writting() => {
|
||||
sourceInput.current-index = AppWindowModels.default-source-index;
|
||||
sourceInput.current-index = AppModels.default-source-index;
|
||||
}
|
||||
accepted => { accepted() }
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { Event } from "../windows/AppWindow/Models.slint";
|
||||
import { Event } from "../shared/Models.slint";
|
||||
import { ScrollView } from "std-widgets.slint";
|
||||
import { VCheckBox, VTextInput, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Palette } from "@selenite";
|
||||
import { TaskLine } from "./TaskLine.slint";
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { Palette } from "@selenite";
|
||||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton, VText, VDatePicker } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { AppActions } from "../shared/Actions.slint";
|
||||
import { Modal } from "../../external/selenite/components/Modal.slint";
|
||||
import { VTimePicker } from "../../external/selenite/components/TimePicker.slint";
|
||||
|
||||
|
@ -30,7 +30,7 @@ export component AddEventModal inherits Modal {
|
|||
VButton {
|
||||
text: "Create";
|
||||
clicked => {
|
||||
AppWindowActions.create-event({
|
||||
AppActions.create-event({
|
||||
title: titleInput.text,
|
||||
date: dateInput.date,
|
||||
startsAt: startTimeInput.time,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Palette } from "@selenite";
|
||||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { AppModels } from "../shared/Models.slint";
|
||||
import { AppActions } from "../shared/Actions.slint";
|
||||
import { Modal } from "../../external/selenite/components/Modal.slint";
|
||||
|
||||
export component AddSourceModal inherits Modal {
|
||||
|
@ -28,7 +28,7 @@ export component AddSourceModal inherits Modal {
|
|||
VButton {
|
||||
text: "Add";
|
||||
clicked => {
|
||||
AppWindowActions.add-source(name, path);
|
||||
AppActions.add-source(name, path);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { Palette } from "@selenite";
|
||||
import { VTextInput } from "../../external/selenite/components/TextInput.slint";
|
||||
import { VButton } from "../../external/selenite/components/index.slint";
|
||||
import { AppWindowModels } from "../windows/AppWindow/Models.slint";
|
||||
import { AppWindowActions } from "../windows/AppWindow/Actions.slint";
|
||||
import { AppModels } from "../shared/Models.slint";
|
||||
import { AppActions } from "../shared/Actions.slint";
|
||||
import { Modal } from "../../external/selenite/components/Modal.slint";
|
||||
|
||||
export component EditSourceModal inherits Modal {
|
||||
|
@ -12,8 +12,8 @@ export component EditSourceModal inherits Modal {
|
|||
|
||||
public function edit(source-id: int) {
|
||||
source-id-to-edit = source-id;
|
||||
root.name = AppWindowModels.get-source-name-from-id(source-id);
|
||||
root.path = AppWindowModels.get-source-path-from-id(source-id);
|
||||
root.name = AppModels.get-source-name-from-id(source-id);
|
||||
root.path = AppModels.get-source-path-from-id(source-id);
|
||||
root.show();
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,7 @@ export component EditSourceModal inherits Modal {
|
|||
VButton {
|
||||
text: "Save";
|
||||
clicked => {
|
||||
AppWindowActions.edit-source(source-id-to-edit, name, path);
|
||||
AppActions.edit-source(source-id-to-edit, name, path);
|
||||
root.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { Date, Time } from "std-widgets.slint";
|
||||
import { CalendarDay } from "../../components/Calendar.slint";
|
||||
import { CalendarDay } from "../components/Calendar.slint";
|
||||
|
||||
export struct NewTaskData {
|
||||
sourceId: int,
|
||||
|
@ -17,22 +17,6 @@ export struct SaveTaskData {
|
|||
date: Date,
|
||||
}
|
||||
|
||||
export struct NewEventParams {
|
||||
title: string,
|
||||
date: Date,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
}
|
||||
|
||||
export struct SaveEventParams {
|
||||
sourceId: int,
|
||||
id: int,
|
||||
title: string,
|
||||
date: Date,
|
||||
startsAt: Time,
|
||||
endsAt: Time
|
||||
}
|
||||
|
||||
struct OpenNewTaskFormParams {
|
||||
eventSourceId: int,
|
||||
eventId: int,
|
||||
|
@ -45,23 +29,15 @@ export struct CreateEventParams {
|
|||
endsAt: Time
|
||||
}
|
||||
|
||||
export global AppWindowActions {
|
||||
export global AppActions {
|
||||
callback task-clicked(int, int);
|
||||
callback source-clicked(int);
|
||||
callback open-settings-window();
|
||||
callback open-add-source-window();
|
||||
callback add-source(name: string, path: string);
|
||||
callback edit-source(sourceId: int, name: string, path: string);
|
||||
|
||||
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 open-add-event-window();
|
||||
|
||||
callback create-task(NewTaskData);
|
||||
callback save-task(SaveTaskData);
|
||||
callback create-event(CreateEventParams);
|
|
@ -1,5 +1,5 @@
|
|||
import { Date, Time } from "std-widgets.slint";
|
||||
import { CalendarDay } from "../../components/Calendar.slint";
|
||||
import { CalendarDay } from "../components/Calendar.slint";
|
||||
|
||||
export struct Source {
|
||||
id: int,
|
||||
|
@ -37,7 +37,7 @@ export struct Day {
|
|||
relativeDaysDiff: int
|
||||
}
|
||||
|
||||
export global AppWindowModels {
|
||||
export global AppModels {
|
||||
in-out property<[Source]> sources-selected;
|
||||
in-out property<int> default-source-index;
|
||||
in-out property<[string]> sources;
|
|
@ -1,8 +1,7 @@
|
|||
import { AppWindowModels } from "windows/AppWindow/Models.slint";
|
||||
import { AppWindowActions } from "windows/AppWindow/Actions.slint";
|
||||
import { AppModels } from "shared/Models.slint";
|
||||
import { AppActions } from "shared/Actions.slint";
|
||||
import { AppWindow } from "windows/AppWindow/AppWindow.slint";
|
||||
import { SettingsWindow } from "windows/SettingsWindow/SettingsWindow.slint";
|
||||
import { Utils } from "shared/Utils.slint";
|
||||
import { Palette } from "@selenite";
|
||||
|
||||
export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions, SettingsWindow }
|
||||
export { Utils, Palette, AppWindow, AppModels, AppActions }
|
||||
|
|
|
@ -12,28 +12,22 @@
|
|||
#include "mirai-core/MarkdownDataProvider.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "selenite/palette.h"
|
||||
#include "slint.h"
|
||||
#include "slint_string.h"
|
||||
#include "ui.h"
|
||||
#include <bits/chrono.h>
|
||||
#include <cassert>
|
||||
#include <charconv>
|
||||
#include <chrono>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <ostream>
|
||||
#include <print>
|
||||
#include <ranges>
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
AppWindow::AppWindow(mirai::Mirai *miraiInstance)
|
||||
: miraiInstance_(miraiInstance), settingsWindow_(miraiInstance), view_(miraiInstance)
|
||||
: miraiInstance_(miraiInstance), view_(miraiInstance)
|
||||
{
|
||||
sources_ = std::make_shared<slint::VectorModel<ui::Source>>();
|
||||
days_ = std::make_shared<slint::VectorModel<ui::Day>>();
|
||||
|
@ -120,20 +114,6 @@ void AppWindow::setupCallbacks()
|
|||
miraiInstance_->onSourceDeleted([&](int id) {
|
||||
refreshModels();
|
||||
});
|
||||
actions().on_open_settings_window([&]() {
|
||||
settingsWindow_.open();
|
||||
});
|
||||
actions().on_open_add_source_window([&]() {
|
||||
// addSourceWindow_.open();
|
||||
});
|
||||
/*actions().on_open_edit_source_window([&](int sourceId) {*/
|
||||
/*auto source = miraiInstance_->getSourceById(sourceId);*/
|
||||
/*assert(source);*/
|
||||
/*editSourceWindow_.open(source);*/
|
||||
/*});*/
|
||||
actions().on_open_add_event_window([&]() {
|
||||
// editEventWindow_.open();
|
||||
});
|
||||
|
||||
actions().on_task_clicked([&](int sourceId, int taskId) {
|
||||
auto source = miraiInstance_->getSourceById(sourceId);
|
||||
|
@ -248,7 +228,6 @@ void AppWindow::setupCallbacks()
|
|||
});
|
||||
|
||||
actions().on_create_event([&](ui::CreateEventParams newEventParams) {
|
||||
std::println("okkk");
|
||||
const ui::Date &date = newEventParams.date;
|
||||
const std::string dateStr = SlintDateToStdString(date);
|
||||
const auto sourceId = models().get_default_source_index();
|
||||
|
@ -264,24 +243,6 @@ void AppWindow::setupCallbacks()
|
|||
view_.update();
|
||||
reloadTasks();
|
||||
});
|
||||
|
||||
/*actions().on_save_event([&](ui::SaveEventParams newEventParams) {*/
|
||||
/*const ui::Date &date = newEventParams.date;*/
|
||||
/*const std::string dateStr = SlintDateToStdString(date);*/
|
||||
/*auto source = miraiInstance_->getSourceById(newEventParams.sourceId);*/
|
||||
/*assert(source);*/
|
||||
/*auto event = source->getEventById(newEventParams.id);*/
|
||||
/*assert(event);*/
|
||||
/*event->setTitle(std::string(newEventParams.title));*/
|
||||
/*event->setStartTime(SlintTimeToMiraiTime(newEventParams.startsAt));*/
|
||||
/*event->setEndTime(SlintTimeToMiraiTime(newEventParams.endsAt));*/
|
||||
|
||||
/*// TODO we can't change the date of the event for now.*/
|
||||
|
||||
/*miraiInstance_->save();*/
|
||||
/*view_.update();*/
|
||||
/*reloadTasks();*/
|
||||
/*});*/
|
||||
}
|
||||
|
||||
std::shared_ptr<slint::VectorModel<slint::SharedString>>
|
||||
|
@ -454,12 +415,12 @@ void AppWindow::run()
|
|||
mainWindow_->run();
|
||||
}
|
||||
|
||||
const ui::AppWindowModels &AppWindow::models()
|
||||
const ui::AppModels &AppWindow::models()
|
||||
{
|
||||
return mainWindow_->global<ui::AppWindowModels>();
|
||||
return mainWindow_->global<ui::AppModels>();
|
||||
}
|
||||
|
||||
const ui::AppWindowActions &AppWindow::actions()
|
||||
const ui::AppActions &AppWindow::actions()
|
||||
{
|
||||
return mainWindow_->global<ui::AppWindowActions>();
|
||||
return mainWindow_->global<ui::AppActions>();
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../SettingsWindow/SettingsWindow.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "mirai-core/View.h"
|
||||
#include "slint.h"
|
||||
|
@ -26,8 +25,8 @@ class AppWindow
|
|||
|
||||
private:
|
||||
void setupCallbacks();
|
||||
const ui::AppWindowModels &models();
|
||||
const ui::AppWindowActions &actions();
|
||||
const ui::AppModels &models();
|
||||
const ui::AppActions &actions();
|
||||
|
||||
std::shared_ptr<slint::VectorModel<ui::Source>> sources_;
|
||||
std::shared_ptr<slint::VectorModel<ui::Day>> days_;
|
||||
|
@ -35,7 +34,6 @@ class AppWindow
|
|||
std::shared_ptr<slint::VectorModel<ui::TaskData>> unscheduledTasks_;
|
||||
|
||||
slint::ComponentHandle<ui::AppWindow> mainWindow_ = ui::AppWindow::create();
|
||||
SettingsWindow settingsWindow_;
|
||||
|
||||
mirai::Mirai *miraiInstance_;
|
||||
mirai::View view_;
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
import { AppWindowModels } from "Models.slint";
|
||||
import { AppModels } from "../../shared/Models.slint";
|
||||
import { Button, VerticalBox, CheckBox } from "std-widgets.slint";
|
||||
import { MainView } from "views/TasksView.slint";
|
||||
import { SettingsWindow } from "../SettingsWindow/SettingsWindow.slint";
|
||||
import { Palette } from "@selenite";
|
||||
import { CalendarView } from "views/CalendarView.slint";
|
||||
import { VButton } from "../../../external/selenite/components/Button.slint";
|
||||
import { ToggleButton } from "../../../external/selenite/components/index.slint";
|
||||
import { VTextInput } from "../../../external/selenite/components/TextInput.slint";
|
||||
import { AppWindowActions } from "Actions.slint";
|
||||
import { AppActions } from "../../shared/Actions.slint";
|
||||
import { SideBar } from "views/SideBar.slint";
|
||||
|
||||
export component AppWindow inherits Window {
|
||||
|
@ -70,4 +69,4 @@ export component AppWindow inherits Window {
|
|||
}
|
||||
}
|
||||
|
||||
export { AppWindowModels, Palette, SettingsWindow } // Export to make it visible to the C++ backend
|
||||
export { AppModels, Palette } // Export to make it visible to the C++ backend
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AppWindowModels, TaskData } from "../Models.slint";
|
||||
import { AppWindowActions, NewTaskData, SaveTaskData } from "../Actions.slint";
|
||||
import { AppModels, TaskData } from "../../../shared/Models.slint";
|
||||
import { AppActions, NewTaskData, SaveTaskData } from "../../../shared/Actions.slint";
|
||||
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { TaskLine } from "../../../components/TaskLine.slint";
|
||||
import { EventGroup } from "../../../components/EventGroup.slint";
|
||||
|
@ -38,9 +38,10 @@ export component CalendarView inherits Rectangle {
|
|||
height: 1px;
|
||||
}
|
||||
Calendar {
|
||||
delete-event-request(source-id, event-id) => { debug("DEELTE", source-id);AppWindowActions.delete-event(source-id, event-id) }
|
||||
init => { debug("cal len", AppWindowModels.calendar.length) }
|
||||
days: AppWindowModels.calendar;
|
||||
delete-event-request(source-id, event-id) => {
|
||||
AppActions.delete-event(source-id, event-id)
|
||||
}
|
||||
days: AppModels.calendar;
|
||||
current-date: Utils.current-date;
|
||||
current-time: Utils.current-time;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AppWindowModels, TaskData } from "../Models.slint";
|
||||
import { AppWindowActions } from "../Actions.slint";
|
||||
import { AppModels, TaskData } from "../../../shared/Models.slint";
|
||||
import { AppActions } from "../../../shared/Actions.slint";
|
||||
import { VButton, ToggleButton, VActionButton, VText, Svg, Palette } from "@selenite";
|
||||
import { EditSourceModal } from "../../../modals/EditSourceModal.slint";
|
||||
import { AddSourceModal } from "../../../modals/AddSourceModal.slint";
|
||||
|
@ -46,16 +46,16 @@ export component SideBar inherits Rectangle {
|
|||
ToggleButton {
|
||||
text: "All";
|
||||
text-alignment: left;
|
||||
active: AppWindowModels.no-source-selected;
|
||||
clicked => { AppWindowActions.source-clicked(-1) }
|
||||
active: AppModels.no-source-selected;
|
||||
clicked => { AppActions.source-clicked(-1) }
|
||||
|
||||
|
||||
}
|
||||
for item[index] in AppWindowModels.sources-selected: ToggleButton {
|
||||
for item[index] in AppModels.sources-selected: ToggleButton {
|
||||
text: item.name;
|
||||
text-alignment: left;
|
||||
active: item.selected;
|
||||
clicked => { AppWindowActions.source-clicked(item.id) }
|
||||
clicked => { AppActions.source-clicked(item.id) }
|
||||
VActionButton {
|
||||
visible: parent.active;
|
||||
icon-svg: Svg.cog;
|
||||
|
@ -70,7 +70,7 @@ export component SideBar inherits Rectangle {
|
|||
icon-svg: Svg.cog;
|
||||
text: "Settings";
|
||||
background: transparent;
|
||||
clicked => { AppWindowModels.open-settings-window() }
|
||||
clicked => { AppModels.open-settings-window() }
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import { AppWindowModels, TaskData } from "../Models.slint";
|
||||
import { AppWindowActions, NewTaskData, SaveTaskData } from "../Actions.slint";
|
||||
import { AppModels, TaskData } from "../../../shared/Models.slint";
|
||||
import { AppActions, NewTaskData, SaveTaskData } from "../../../shared/Actions.slint";
|
||||
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
||||
import { TaskLine } from "../../../components/TaskLine.slint";
|
||||
import { EventGroup } from "../../../components/EventGroup.slint";
|
||||
|
@ -23,7 +23,7 @@ export component MainView inherits Rectangle {
|
|||
VButton {
|
||||
text: "Show/Hide completed tasks";
|
||||
clicked => {
|
||||
AppWindowActions.toggle-show-completed-tasks();
|
||||
AppActions.toggle-show-completed-tasks();
|
||||
completed-tasks-visible = !completed-tasks-visible;
|
||||
}
|
||||
icon-svg: completed-tasks-visible ? icon-visible : icon-not-visible;
|
||||
|
@ -37,9 +37,9 @@ export component MainView inherits Rectangle {
|
|||
}
|
||||
|
||||
CreateTaskOrEvent {
|
||||
sources: AppWindowModels.sources;
|
||||
sources: AppModels.sources;
|
||||
create-task(data) => {
|
||||
AppWindowActions.create-task({
|
||||
AppActions.create-task({
|
||||
sourceId: data.sourceId,
|
||||
eventId: -1,
|
||||
title: data.title,
|
||||
|
@ -54,12 +54,12 @@ export component MainView inherits Rectangle {
|
|||
horizontal-stretch: 1;
|
||||
VerticalLayout {
|
||||
alignment: start;
|
||||
if AppWindowModels.days.length == 0 && AppWindowModels.unscheduled-tasks.length == 0 : VText {
|
||||
if AppModels.days.length == 0 && AppModels.unscheduled-tasks.length == 0 : VText {
|
||||
text: "There is no task to show";
|
||||
horizontal-alignment: center;
|
||||
vertical-alignment: center;
|
||||
}
|
||||
for day[dayIndex] in AppWindowModels.days: VerticalLayout {
|
||||
for day[dayIndex] in AppModels.days: VerticalLayout {
|
||||
spacing: day.tasks.length > 0 ? 16px : 0px;
|
||||
padding-bottom: 32px;
|
||||
|
||||
|
@ -92,19 +92,19 @@ export component MainView inherits Rectangle {
|
|||
padding-bottom: 8px;
|
||||
TaskLine {
|
||||
title: task.title;
|
||||
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||
source-name: AppModels.get-source-name-from-id(task.sourceId);
|
||||
scheduled: task.date.year != 0;
|
||||
date: day.date;
|
||||
checked: task.checked;
|
||||
allow-edit-date: true;
|
||||
delete => {
|
||||
AppWindowActions.delete-task-clicked(task.sourceId, task.id)
|
||||
AppActions.delete-task-clicked(task.sourceId, task.id)
|
||||
}
|
||||
toggle-check => {
|
||||
AppWindowActions.task-clicked(task.sourceId, task.id);
|
||||
AppActions.task-clicked(task.sourceId, task.id);
|
||||
}
|
||||
edited(data) => {
|
||||
AppWindowActions.save-task({
|
||||
AppActions.save-task({
|
||||
id: task.id,
|
||||
sourceId: task.sourceId,
|
||||
title: data.title,
|
||||
|
@ -117,7 +117,7 @@ export component MainView inherits Rectangle {
|
|||
}
|
||||
}
|
||||
}
|
||||
if AppWindowModels.unscheduled-tasks.length > 0 : VerticalLayout {
|
||||
if AppModels.unscheduled-tasks.length > 0 : VerticalLayout {
|
||||
Rectangle {
|
||||
//background: Palette.card-background;
|
||||
border-radius: 8px;
|
||||
|
@ -130,22 +130,22 @@ export component MainView inherits Rectangle {
|
|||
font-size: 1.2rem;
|
||||
}
|
||||
}
|
||||
for task[taskIndex] in AppWindowModels.unscheduled-tasks: VerticalLayout {
|
||||
for task[taskIndex] in AppModels.unscheduled-tasks: VerticalLayout {
|
||||
padding-top: taskIndex == 0 ? 16px : 0px;
|
||||
padding-bottom: 8px;
|
||||
TaskLine {
|
||||
title: task.title;
|
||||
source-name: AppWindowModels.get-source-name-from-id(task.sourceId);
|
||||
source-name: AppModels.get-source-name-from-id(task.sourceId);
|
||||
checked: task.checked;
|
||||
allow-edit-date: true;
|
||||
delete => {
|
||||
AppWindowActions.delete-task-clicked(task.sourceId, task.id)
|
||||
AppActions.delete-task-clicked(task.sourceId, task.id)
|
||||
}
|
||||
toggle-check => {
|
||||
AppWindowActions.task-clicked(task.sourceId, task.id);
|
||||
AppActions.task-clicked(task.sourceId, task.id);
|
||||
}
|
||||
edited(data) => {
|
||||
AppWindowActions.save-task({
|
||||
AppActions.save-task({
|
||||
id: task.id,
|
||||
sourceId: task.sourceId,
|
||||
title: data.title,
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/*
|
||||
* Mirai. Copyright (C) 2024 Vyn
|
||||
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
||||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
#include "SettingsWindow.h"
|
||||
#include "../../SeleniteSetup.h"
|
||||
#include "evalyte-cpp-common/evalyte.h"
|
||||
#include "mirai-core/DataProvider.h"
|
||||
#include "mirai-core/MarkdownDataProvider.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "slint.h"
|
||||
#include "slint_string.h"
|
||||
#include <bits/chrono.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
#include <print>
|
||||
#include <string>
|
||||
|
||||
SettingsWindow::SettingsWindow(mirai::Mirai *miraiInstance) : miraiInstance_(miraiInstance)
|
||||
{
|
||||
|
||||
const auto palettePath = std::string(getenv("HOME")) + "/.config/evalyte/theme.json";
|
||||
const auto palette = selenite::parseJson(palettePath);
|
||||
|
||||
if (palette.has_value()) {
|
||||
setSelenitePalette(window_->global<ui::Palette>(), palette.value());
|
||||
}
|
||||
|
||||
setupCallbacks();
|
||||
}
|
||||
|
||||
void SettingsWindow::setupCallbacks()
|
||||
{
|
||||
}
|
||||
|
||||
void SettingsWindow::open()
|
||||
{
|
||||
window_->show();
|
||||
}
|
||||
|
||||
void SettingsWindow::close()
|
||||
{
|
||||
window_->hide();
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
/*
|
||||
* Mirai. Copyright (C) 2024 Vyn
|
||||
* This file is licensed under version 3 of the GNU General Public License (GPL-3.0-only)
|
||||
* The license can be found in the LICENSE file or at https://www.gnu.org/licenses/gpl-3.0.txt
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "slint.h"
|
||||
#include "ui.h"
|
||||
|
||||
class SettingsWindow
|
||||
{
|
||||
|
||||
public:
|
||||
SettingsWindow(mirai::Mirai *mirai);
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
private:
|
||||
void setupCallbacks();
|
||||
|
||||
std::shared_ptr<slint::VectorModel<ui::Source>> sources_;
|
||||
slint::ComponentHandle<ui::SettingsWindow> window_ = ui::SettingsWindow::create();
|
||||
mirai::Mirai *miraiInstance_;
|
||||
};
|
|
@ -1,26 +0,0 @@
|
|||
import { AppWindowModels } from "../AppWindow/Models.slint";
|
||||
import { Button, VerticalBox, CheckBox } from "std-widgets.slint";
|
||||
import { VText, VTextInput, Palette } from "@selenite";
|
||||
|
||||
export component SettingsWindow inherits Window {
|
||||
|
||||
title: "Mirai - Settings";
|
||||
min-height: 100px;
|
||||
max-height: 4000px; // needed, otherwise the window wants to fit the content (on Swaywm)
|
||||
background: Palette.background;
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
for source[source-index] in AppWindowModels.sources-selected: VerticalLayout {
|
||||
VText {
|
||||
text: source.name;
|
||||
}
|
||||
VTextInput {
|
||||
text: source.path;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { AppWindowModels, Palette } // Export to make it visible to the C++ backend
|
Loading…
Add table
Add a link
Reference in a new issue