mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-02 01:13:19 +00:00
Add Source creation/edition + Add missing edit forms for tasks and events
This commit is contained in:
parent
f1ac8a42d1
commit
a15c23bb21
24 changed files with 358 additions and 205 deletions
2
external/mirai-core/CMakeLists.txt
vendored
2
external/mirai-core/CMakeLists.txt
vendored
|
@ -7,8 +7,6 @@ set(CMAKE_COMPILE_WARNING_AS_ERROR ON)
|
||||||
|
|
||||||
add_library(mirai-core
|
add_library(mirai-core
|
||||||
src/Mirai.cpp
|
src/Mirai.cpp
|
||||||
src/Config.cpp
|
|
||||||
src/ConfigImpl.cpp
|
|
||||||
src/Task.cpp
|
src/Task.cpp
|
||||||
src/Day.cpp
|
src/Day.cpp
|
||||||
src/Event.cpp
|
src/Event.cpp
|
||||||
|
|
29
external/mirai-core/include/mirai-core/Config.h
vendored
29
external/mirai-core/include/mirai-core/Config.h
vendored
|
@ -1,29 +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 <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace mirai
|
|
||||||
{
|
|
||||||
|
|
||||||
class ConfigImpl;
|
|
||||||
|
|
||||||
class Config
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
Config(const std::string &path);
|
|
||||||
~Config();
|
|
||||||
|
|
||||||
std::vector<std::string> sources() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<ConfigImpl> impl_;
|
|
||||||
};
|
|
||||||
} // namespace mirai
|
|
11
external/mirai-core/include/mirai-core/Mirai.h
vendored
11
external/mirai-core/include/mirai-core/Mirai.h
vendored
|
@ -19,7 +19,12 @@ class Mirai
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void loadSource(std::unique_ptr<DataProvider> &&resource);
|
Mirai(const std::string &configFilePath);
|
||||||
|
void addSource(
|
||||||
|
const std::string &name, const std::string &type, std::unique_ptr<DataProvider> &&source
|
||||||
|
);
|
||||||
|
void editSource(int id, const std::string &name, const std::string &path);
|
||||||
|
void deleteSource(int id);
|
||||||
void unloadAllSources();
|
void unloadAllSources();
|
||||||
void save();
|
void save();
|
||||||
std::optional<std::reference_wrapper<DataProvider>> getSourceByName(const std::string &name);
|
std::optional<std::reference_wrapper<DataProvider>> getSourceByName(const std::string &name);
|
||||||
|
@ -31,7 +36,9 @@ class Mirai
|
||||||
Source *getSourceById(int id);
|
Source *getSourceById(int id);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void loadConfig(const std::string &path);
|
||||||
|
void saveConfig();
|
||||||
std::vector<std::unique_ptr<Source>> sources_;
|
std::vector<std::unique_ptr<Source>> sources_;
|
||||||
// std::vector<std::string> tags_;
|
std::string configPath_;
|
||||||
};
|
};
|
||||||
} // namespace mirai
|
} // namespace mirai
|
||||||
|
|
|
@ -31,13 +31,15 @@ struct createEventParams {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SourceConstructor {
|
struct SourceConstructor {
|
||||||
|
std::string name;
|
||||||
DataProvider *sourceDataProvider;
|
DataProvider *sourceDataProvider;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Source
|
class Source
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Source(SourceConstructor params) : data(params.sourceDataProvider)
|
Source(SourceConstructor params)
|
||||||
|
: data(params.sourceDataProvider), name_(params.name), type_("FileSystemMarkdown")
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +58,8 @@ class Source
|
||||||
std::string type() const;
|
std::string type() const;
|
||||||
DataProvider *dataProvider();
|
DataProvider *dataProvider();
|
||||||
|
|
||||||
|
void setName(const std::string &name);
|
||||||
|
|
||||||
void createTask(const createTaskParams &task);
|
void createTask(const createTaskParams &task);
|
||||||
void removeTask(const Task &task);
|
void removeTask(const Task &task);
|
||||||
std::optional<Task> getTaskById(int taskId);
|
std::optional<Task> getTaskById(int taskId);
|
||||||
|
@ -86,6 +90,8 @@ class Source
|
||||||
return nextId++;
|
return nextId++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::string name_;
|
||||||
|
std::string type_;
|
||||||
DataProvider *data;
|
DataProvider *data;
|
||||||
};
|
};
|
||||||
} // namespace mirai
|
} // namespace mirai
|
||||||
|
|
30
external/mirai-core/src/Config.cpp
vendored
30
external/mirai-core/src/Config.cpp
vendored
|
@ -1,30 +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 "Config.h"
|
|
||||||
#include "ConfigImpl.h"
|
|
||||||
#include "nlohmann/json.hpp"
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace mirai
|
|
||||||
{
|
|
||||||
|
|
||||||
Config::~Config() = default;
|
|
||||||
|
|
||||||
Config::Config(const std::string &path) : impl_(new ConfigImpl(path))
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> Config::sources() const
|
|
||||||
{
|
|
||||||
return impl_->sources();
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace mirai
|
|
48
external/mirai-core/src/ConfigImpl.cpp
vendored
48
external/mirai-core/src/ConfigImpl.cpp
vendored
|
@ -1,48 +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 "ConfigImpl.h"
|
|
||||||
#include "nlohmann/json.hpp"
|
|
||||||
#include <fstream>
|
|
||||||
#include <iostream>
|
|
||||||
#include <string>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace mirai
|
|
||||||
{
|
|
||||||
ConfigImpl::ConfigImpl(const std::string &path) : path_(path)
|
|
||||||
{
|
|
||||||
std::ifstream file(path_);
|
|
||||||
if (!file) {
|
|
||||||
configJson_ = nlohmann::json::parse(R"(
|
|
||||||
{
|
|
||||||
"files": []
|
|
||||||
}
|
|
||||||
)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
configJson_ = nlohmann::json::parse(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> ConfigImpl::sources() const
|
|
||||||
{
|
|
||||||
std::vector<std::string> sources;
|
|
||||||
assert(configJson_.is_object());
|
|
||||||
assert(configJson_["files"].is_array());
|
|
||||||
auto jsonSources = configJson_["files"];
|
|
||||||
for (const auto &filePath : jsonSources) {
|
|
||||||
assert(filePath.is_string());
|
|
||||||
sources.push_back(filePath.get<std::string>());
|
|
||||||
}
|
|
||||||
return sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string ConfigImpl::path() const
|
|
||||||
{
|
|
||||||
return path_;
|
|
||||||
}
|
|
||||||
|
|
||||||
}; // namespace mirai
|
|
27
external/mirai-core/src/ConfigImpl.h
vendored
27
external/mirai-core/src/ConfigImpl.h
vendored
|
@ -1,27 +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 "nlohmann/json.hpp"
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace mirai
|
|
||||||
{
|
|
||||||
|
|
||||||
class ConfigImpl
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ConfigImpl(const std::string &path);
|
|
||||||
|
|
||||||
std::vector<std::string> sources() const;
|
|
||||||
std::string path() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::string path_;
|
|
||||||
nlohmann::json configJson_;
|
|
||||||
};
|
|
||||||
} // namespace mirai
|
|
105
external/mirai-core/src/Mirai.cpp
vendored
105
external/mirai-core/src/Mirai.cpp
vendored
|
@ -5,30 +5,115 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Mirai.h"
|
#include "Mirai.h"
|
||||||
#include "Config.h"
|
|
||||||
#include "DataProvider.h"
|
#include "DataProvider.h"
|
||||||
|
#include "MarkdownDataProvider.h"
|
||||||
#include "Source.h"
|
#include "Source.h"
|
||||||
#include "cpp-utils/debug.h"
|
#include "nlohmann/json.hpp"
|
||||||
#include "utils.h"
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <optional>
|
#include <string>
|
||||||
#include <ostream>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace mirai
|
namespace mirai
|
||||||
{
|
{
|
||||||
|
|
||||||
void Mirai::loadSource(std::unique_ptr<DataProvider> &&resource)
|
void Mirai::loadConfig(const std::string &path)
|
||||||
{
|
{
|
||||||
DataProvider *sourceDataProvider = resource.release();
|
auto configJson = nlohmann::json::parse(R"(
|
||||||
|
{
|
||||||
|
"files": []
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
std::ifstream file(path);
|
||||||
|
if (!file) {
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
configJson = nlohmann::json::parse(file);
|
||||||
|
|
||||||
|
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>();
|
||||||
|
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}
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mirai::saveConfig()
|
||||||
|
{
|
||||||
|
std::ofstream file(configPath_);
|
||||||
|
if (!file.is_open()) {
|
||||||
|
std::cerr << "Can't save config to " << configPath_ << std::endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
auto configJson = nlohmann::json::parse(R"(
|
||||||
|
{
|
||||||
|
"files": []
|
||||||
|
}
|
||||||
|
)");
|
||||||
|
for (auto &source : sources_) {
|
||||||
|
nlohmann::json jsonSource;
|
||||||
|
jsonSource["name"] = source->name();
|
||||||
|
auto dataProvider = dynamic_cast<MarkdownDataProvider *>(source->dataProvider());
|
||||||
|
jsonSource["path"] = dataProvider->path();
|
||||||
|
jsonSource["type"] = "FileSystemMarkdown";
|
||||||
|
configJson["files"].push_back(jsonSource);
|
||||||
|
}
|
||||||
|
file << configJson.dump(4);
|
||||||
|
file.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
Mirai::Mirai(const std::string &configFilePath) : configPath_(configFilePath)
|
||||||
|
{
|
||||||
|
loadConfig(configFilePath);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mirai::addSource(
|
||||||
|
const std::string &name, const std::string &type, std::unique_ptr<DataProvider> &&source
|
||||||
|
)
|
||||||
|
{
|
||||||
|
DataProvider *sourceDataProvider = source.release();
|
||||||
sourceDataProvider->load();
|
sourceDataProvider->load();
|
||||||
sources_.push_back(
|
sources_.push_back(std::make_unique<Source>(
|
||||||
std::make_unique<Source>(SourceConstructor{.sourceDataProvider = sourceDataProvider})
|
SourceConstructor{.name = name, .sourceDataProvider = sourceDataProvider}
|
||||||
);
|
));
|
||||||
|
saveConfig();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void Mirai::editSource(int id, const std::string &name, const std::string &path)
|
||||||
|
{
|
||||||
|
auto source = getSourceById(id);
|
||||||
|
source->setName(name);
|
||||||
|
|
||||||
|
DataProvider *sourceDataProvider = source->dataProvider();
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Mirai::deleteSource(int id)
|
||||||
|
{
|
||||||
|
auto source = getSourceById(id);
|
||||||
|
sources_.erase(
|
||||||
|
std::remove_if(
|
||||||
|
sources_.begin(), sources_.end(),
|
||||||
|
[&](const std::unique_ptr<Source> &source) {
|
||||||
|
return source->id == id;
|
||||||
|
}
|
||||||
|
),
|
||||||
|
sources_.end()
|
||||||
|
);
|
||||||
|
|
||||||
|
saveConfig();
|
||||||
|
}
|
||||||
|
|
||||||
void Mirai::unloadAllSources()
|
void Mirai::unloadAllSources()
|
||||||
{
|
{
|
||||||
sources_.clear();
|
sources_.clear();
|
||||||
|
|
10
external/mirai-core/src/Source.cpp
vendored
10
external/mirai-core/src/Source.cpp
vendored
|
@ -10,6 +10,7 @@
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace mirai
|
namespace mirai
|
||||||
|
@ -144,13 +145,18 @@ std::vector<Task> Source::getUnscheduledTasks()
|
||||||
|
|
||||||
std::string Source::name() const
|
std::string Source::name() const
|
||||||
{
|
{
|
||||||
return data->name();
|
return name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Source::setName(const std::string &name)
|
||||||
|
{
|
||||||
|
name_ = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string Source::type() const
|
std::string Source::type() const
|
||||||
{
|
{
|
||||||
// There is only 1 type for now
|
// There is only 1 type for now
|
||||||
return "MarkdownFile";
|
return type_;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataProvider *Source::dataProvider()
|
DataProvider *Source::dataProvider()
|
||||||
|
|
13
external/mirai-core/src/View.cpp
vendored
13
external/mirai-core/src/View.cpp
vendored
|
@ -84,12 +84,13 @@ void View::update()
|
||||||
}
|
}
|
||||||
|
|
||||||
// day's events
|
// day's events
|
||||||
auto sourceEvents = day.events() | std::ranges::views::filter([&](const Event &event) {
|
auto sourceEvents =
|
||||||
return (day.date() >= todayDate) ||
|
day.events() | std::ranges::views::filter([&](const Event &event) {
|
||||||
findFirst(event.queryTasks(), [&](const Task &task) {
|
return (!shouldHideCompletedTasks() || day.date() >= todayDate) ||
|
||||||
return task.checked() == false;
|
findFirst(event.queryTasks(), [&](const Task &task) {
|
||||||
}).has_value();
|
return task.checked() == false;
|
||||||
});
|
}).has_value();
|
||||||
|
});
|
||||||
|
|
||||||
if (day.date() >= todayDate || std::ranges::distance(sourceEvents) > 0) {
|
if (day.date() >= todayDate || std::ranges::distance(sourceEvents) > 0) {
|
||||||
if (!dates.contains(day.date())) {
|
if (!dates.contains(day.date())) {
|
||||||
|
|
2
external/selenite
vendored
2
external/selenite
vendored
|
@ -1 +1 @@
|
||||||
Subproject commit 33d6a9dee8437979b5a9bf5a716a4053f3ebf2fa
|
Subproject commit a2e151c99dd7811f348729aa08c098520cada519
|
|
@ -53,6 +53,7 @@ AppWindowBackend::AppWindowBackend(mirai::Mirai *miraiInstance)
|
||||||
std::cerr << "Warning, no " << palettePath << " found" << std::endl;
|
std::cerr << "Warning, no " << palettePath << " found" << std::endl;
|
||||||
setSelenitePalette(mainWindow_->global<ui::Palette>(), palette.value());
|
setSelenitePalette(mainWindow_->global<ui::Palette>(), palette.value());
|
||||||
setSelenitePalette(settingsWindow_->global<ui::Palette>(), palette.value());
|
setSelenitePalette(settingsWindow_->global<ui::Palette>(), palette.value());
|
||||||
|
setSelenitePalette(addSourceWindow_->global<ui::Palette>(), palette.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
mainWindow_->global<ui::Backend>().set_sources(sourcesNames);
|
mainWindow_->global<ui::Backend>().set_sources(sourcesNames);
|
||||||
|
@ -116,6 +117,40 @@ void AppWindowBackend::setupCallbacks()
|
||||||
mainWindow_->global<ui::Backend>().on_settings_clicked([&]() {
|
mainWindow_->global<ui::Backend>().on_settings_clicked([&]() {
|
||||||
settingsWindow_->show();
|
settingsWindow_->show();
|
||||||
});
|
});
|
||||||
|
mainWindow_->global<ui::Backend>().on_add_source_clicked([&]() {
|
||||||
|
addSourceWindow_->show();
|
||||||
|
});
|
||||||
|
mainWindow_->global<ui::Backend>().on_edit_source_clicked([&](int sourceId) {
|
||||||
|
auto source = miraiInstance_->getSourceById(sourceId);
|
||||||
|
assert(source);
|
||||||
|
auto markdownSource = dynamic_cast<mirai::MarkdownDataProvider *>(source->dataProvider());
|
||||||
|
editSourceWindow_->set_id(source->id);
|
||||||
|
editSourceWindow_->set_name(slint::SharedString(source->name()));
|
||||||
|
editSourceWindow_->set_path(slint::SharedString(markdownSource->path()));
|
||||||
|
editSourceWindow_->show();
|
||||||
|
});
|
||||||
|
addSourceWindow_->global<ui::Backend>().on_add_source([&](ui::AddSourceParam params) {
|
||||||
|
std::unique_ptr<mirai::DataProvider> file =
|
||||||
|
std::make_unique<mirai::MarkdownDataProvider>(std::string(params.path));
|
||||||
|
miraiInstance_->addSource(
|
||||||
|
std::string(params.name), std::string(params.type), std::move(file)
|
||||||
|
);
|
||||||
|
addSourceWindow_->hide();
|
||||||
|
reloadSources();
|
||||||
|
reloadTasks();
|
||||||
|
});
|
||||||
|
editSourceWindow_->global<ui::Backend>().on_modify_source([&](ui::ModifySourceParam params) {
|
||||||
|
miraiInstance_->editSource(params.id, std::string(params.name), std::string(params.path));
|
||||||
|
editSourceWindow_->hide();
|
||||||
|
reloadSources();
|
||||||
|
reloadTasks();
|
||||||
|
});
|
||||||
|
editSourceWindow_->global<ui::Backend>().on_delete_source([&](int sourceId) {
|
||||||
|
miraiInstance_->deleteSource(sourceId);
|
||||||
|
editSourceWindow_->hide();
|
||||||
|
reloadSources();
|
||||||
|
reloadTasks();
|
||||||
|
});
|
||||||
mainWindow_->global<ui::Backend>().on_task_clicked([&](int sourceId, int taskId) {
|
mainWindow_->global<ui::Backend>().on_task_clicked([&](int sourceId, int taskId) {
|
||||||
auto source = miraiInstance_->getSourceById(sourceId);
|
auto source = miraiInstance_->getSourceById(sourceId);
|
||||||
assert(source);
|
assert(source);
|
||||||
|
@ -296,6 +331,7 @@ void AppWindowBackend::reloadTasks()
|
||||||
auto &task = tasksForDate.at(taskIndex);
|
auto &task = tasksForDate.at(taskIndex);
|
||||||
slintDayTasks->push_back({
|
slintDayTasks->push_back({
|
||||||
.sourceId = task.sourceId(),
|
.sourceId = task.sourceId(),
|
||||||
|
.eventId = -1,
|
||||||
.id = task.id(),
|
.id = task.id(),
|
||||||
.title = slint::SharedString(task.title()),
|
.title = slint::SharedString(task.title()),
|
||||||
.checked = task.checked(),
|
.checked = task.checked(),
|
||||||
|
@ -320,6 +356,7 @@ void AppWindowBackend::reloadTasks()
|
||||||
auto &task = eventTasks.at(taskIndex);
|
auto &task = eventTasks.at(taskIndex);
|
||||||
slintTasks->push_back({
|
slintTasks->push_back({
|
||||||
.sourceId = task.sourceId(),
|
.sourceId = task.sourceId(),
|
||||||
|
.eventId = currentEvent.id(),
|
||||||
.id = task.id(),
|
.id = task.id(),
|
||||||
.title = slint::SharedString(task.title()),
|
.title = slint::SharedString(task.title()),
|
||||||
.checked = task.checked(),
|
.checked = task.checked(),
|
||||||
|
@ -336,6 +373,7 @@ void AppWindowBackend::reloadTasks()
|
||||||
auto &task = unscheduledTasksView.at(taskIndex);
|
auto &task = unscheduledTasksView.at(taskIndex);
|
||||||
unscheduledTasks_->push_back({
|
unscheduledTasks_->push_back({
|
||||||
.sourceId = task.sourceId(),
|
.sourceId = task.sourceId(),
|
||||||
|
.eventId = -1,
|
||||||
.id = task.id(),
|
.id = task.id(),
|
||||||
.title = slint::SharedString(task.title()),
|
.title = slint::SharedString(task.title()),
|
||||||
.checked = task.checked(),
|
.checked = task.checked(),
|
||||||
|
@ -389,7 +427,8 @@ void AppWindowBackend::reloadSources()
|
||||||
mirai::MarkdownDataProvider *sourceProvider =
|
mirai::MarkdownDataProvider *sourceProvider =
|
||||||
dynamic_cast<mirai::MarkdownDataProvider *>(source->dataProvider());
|
dynamic_cast<mirai::MarkdownDataProvider *>(source->dataProvider());
|
||||||
sources_->push_back(
|
sources_->push_back(
|
||||||
{.name = slint::SharedString(source->name()),
|
{.id = source->id,
|
||||||
|
.name = slint::SharedString(source->name()),
|
||||||
.selected = isSourceSelected && !noSourceSelected,
|
.selected = isSourceSelected && !noSourceSelected,
|
||||||
.path = slint::SharedString(sourceProvider->path())}
|
.path = slint::SharedString(sourceProvider->path())}
|
||||||
);
|
);
|
||||||
|
|
|
@ -34,6 +34,8 @@ class AppWindowBackend
|
||||||
|
|
||||||
slint::ComponentHandle<ui::AppWindow> mainWindow_ = ui::AppWindow::create();
|
slint::ComponentHandle<ui::AppWindow> mainWindow_ = ui::AppWindow::create();
|
||||||
slint::ComponentHandle<ui::SettingsWindow> settingsWindow_ = ui::SettingsWindow::create();
|
slint::ComponentHandle<ui::SettingsWindow> settingsWindow_ = ui::SettingsWindow::create();
|
||||||
|
slint::ComponentHandle<ui::AddSourceWindow> addSourceWindow_ = ui::AddSourceWindow::create();
|
||||||
|
slint::ComponentHandle<ui::EditSourceWindow> editSourceWindow_ = ui::EditSourceWindow::create();
|
||||||
|
|
||||||
mirai::Mirai *miraiInstance_;
|
mirai::Mirai *miraiInstance_;
|
||||||
mirai::View view_;
|
mirai::View view_;
|
||||||
|
|
15
src/main.cpp
15
src/main.cpp
|
@ -6,28 +6,15 @@
|
||||||
|
|
||||||
#include "AppWindowBackend.h"
|
#include "AppWindowBackend.h"
|
||||||
#include "evalyte-cpp-common/config.h"
|
#include "evalyte-cpp-common/config.h"
|
||||||
#include "mirai-core/Config.h"
|
|
||||||
#include "mirai-core/DataProvider.h"
|
|
||||||
#include "mirai-core/MarkdownDataProvider.h"
|
|
||||||
#include "mirai-core/Mirai.h"
|
#include "mirai-core/Mirai.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <memory>
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
int main(int argc, char **argv)
|
int main(int argc, char **argv)
|
||||||
{
|
{
|
||||||
mirai::Mirai mirai;
|
|
||||||
|
|
||||||
const auto configFilePath = evalyte::createConfigDirectoryPath("mirai") + "/config.json";
|
const auto configFilePath = evalyte::createConfigDirectoryPath("mirai") + "/config.json";
|
||||||
mirai::Config config(configFilePath);
|
mirai::Mirai mirai{configFilePath};
|
||||||
for (const auto &sourceFilePath : config.sources()) {
|
|
||||||
std::unique_ptr<mirai::DataProvider> file =
|
|
||||||
std::make_unique<mirai::MarkdownDataProvider>(sourceFilePath);
|
|
||||||
mirai.loadSource(std::move(file));
|
|
||||||
}
|
|
||||||
|
|
||||||
AppWindowBackend appWindow{&mirai};
|
AppWindowBackend appWindow{&mirai};
|
||||||
appWindow.run();
|
appWindow.run();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,8 @@ import { Button, VerticalBox, CheckBox } from "std-widgets.slint";
|
||||||
import { SideBar } from "./components/SideBar.slint";
|
import { SideBar } from "./components/SideBar.slint";
|
||||||
import { MainView } from "MainView.slint";
|
import { MainView } from "MainView.slint";
|
||||||
import { SettingsWindow } from "SettingsWindow.slint";
|
import { SettingsWindow } from "SettingsWindow.slint";
|
||||||
|
import { AddSourceWindow } from "windows/AddSourceWindow.slint";
|
||||||
|
import { EditSourceWindow } from "windows/EditSourceWindow.slint";
|
||||||
import { Palette } from "@selenite";
|
import { Palette } from "@selenite";
|
||||||
|
|
||||||
export component AppWindow inherits Window {
|
export component AppWindow inherits Window {
|
||||||
|
@ -21,4 +23,4 @@ export component AppWindow inherits Window {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { Backend, Palette, SettingsWindow } // Export to make it visible to the C++ backend
|
export { Backend, Palette, SettingsWindow, AddSourceWindow, EditSourceWindow } // Export to make it visible to the C++ backend
|
||||||
|
|
|
@ -34,7 +34,20 @@ export struct SaveEventParams {
|
||||||
endsAt: Time
|
endsAt: Time
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export struct AddSourceParam {
|
||||||
|
name: string,
|
||||||
|
type: string,
|
||||||
|
path: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export struct ModifySourceParam {
|
||||||
|
id: int,
|
||||||
|
name: string,
|
||||||
|
path: string
|
||||||
|
}
|
||||||
|
|
||||||
export struct Source {
|
export struct Source {
|
||||||
|
id: int,
|
||||||
name: string,
|
name: string,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
path: string
|
path: string
|
||||||
|
@ -42,10 +55,11 @@ export struct Source {
|
||||||
|
|
||||||
export struct TaskData {
|
export struct TaskData {
|
||||||
sourceId: int,
|
sourceId: int,
|
||||||
|
eventId: int,
|
||||||
id: int,
|
id: int,
|
||||||
title: string,
|
title: string,
|
||||||
|
date: Date,
|
||||||
checked: bool,
|
checked: bool,
|
||||||
tags: [string],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export struct Event {
|
export struct Event {
|
||||||
|
@ -87,6 +101,8 @@ export global Backend {
|
||||||
callback source-clicked(int);
|
callback source-clicked(int);
|
||||||
callback tag-clicked(int);
|
callback tag-clicked(int);
|
||||||
callback settings-clicked();
|
callback settings-clicked();
|
||||||
|
callback add-source-clicked();
|
||||||
|
callback edit-source-clicked(int);
|
||||||
|
|
||||||
callback open-new-task-form(OpenNewTaskFormParams);
|
callback open-new-task-form(OpenNewTaskFormParams);
|
||||||
callback open-edit-task-form(int, int);
|
callback open-edit-task-form(int, int);
|
||||||
|
@ -101,6 +117,11 @@ export global Backend {
|
||||||
callback create-event(NewEventParams);
|
callback create-event(NewEventParams);
|
||||||
callback save-event(SaveEventParams);
|
callback save-event(SaveEventParams);
|
||||||
|
|
||||||
|
callback add-source(AddSourceParam);
|
||||||
|
callback modify-source(ModifySourceParam);
|
||||||
|
callback delete-source(int);
|
||||||
|
|
||||||
|
// Utils
|
||||||
pure callback format-date(Date) -> string;
|
pure callback format-date(Date) -> string;
|
||||||
pure callback format-date-relative(Date) -> string;
|
pure callback format-date-relative(Date) -> string;
|
||||||
pure callback capitalize-string(string) -> string;
|
pure callback capitalize-string(string) -> string;
|
||||||
|
|
|
@ -9,6 +9,9 @@ export global Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public pure function time-to-string(time: Time) -> string {
|
public pure function time-to-string(time: Time) -> string {
|
||||||
return "\{format-zero-padding(time.hour)}h\{format-zero-padding(time.minute)}";
|
if (time.minute == 0) {
|
||||||
|
return "\{time.hour}";
|
||||||
|
}
|
||||||
|
return "\{time.hour}:\{format-zero-padding(time.minute)}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,7 +50,7 @@ export component Calendar inherits Rectangle {
|
||||||
VText {
|
VText {
|
||||||
vertical-alignment: center;
|
vertical-alignment: center;
|
||||||
horizontal-alignment: right;
|
horizontal-alignment: right;
|
||||||
text: "\{index}h";
|
text: "\{index}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,13 @@
|
||||||
import { Backend, TaskData, Event } from "../Backend.slint";
|
import { Backend, TaskData, Event } from "../Backend.slint";
|
||||||
import { ScrollView } from "std-widgets.slint";
|
import { ScrollView } from "std-widgets.slint";
|
||||||
import { VCheckBox, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Palette } from "@selenite";
|
import { VCheckBox, VTextInput, VButton, VActionButton, Svg, VTag, VPopupIconMenu, VText, Palette } from "@selenite";
|
||||||
import { TaskLine } from "./TaskLine.slint";
|
import { TaskLine } from "./TaskLine.slint";
|
||||||
import { Utils } from "../Utils.slint";
|
import { Utils } from "../Utils.slint";
|
||||||
|
|
||||||
export component EventGroup {
|
export component EventGroup {
|
||||||
in property<Event> event;
|
in property<Event> event;
|
||||||
|
private property <bool> show-add-task: false;
|
||||||
|
private property <bool> edit-name: false;
|
||||||
|
|
||||||
eventPopup := VPopupIconMenu {
|
eventPopup := VPopupIconMenu {
|
||||||
VActionButton {
|
VActionButton {
|
||||||
|
@ -13,17 +15,16 @@ export component EventGroup {
|
||||||
icon-colorize: Colors.greenyellow;
|
icon-colorize: Colors.greenyellow;
|
||||||
icon-size: 1.5rem;
|
icon-size: 1.5rem;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
clicked => { Backend.open-new-task-form({
|
clicked => {
|
||||||
eventSourceId: event.sourceId,
|
root.show-add-task = true;
|
||||||
eventId: event.id,
|
}
|
||||||
})}
|
|
||||||
}
|
}
|
||||||
VActionButton {
|
VActionButton {
|
||||||
icon-svg: Svg.pen;
|
icon-svg: Svg.pen;
|
||||||
icon-colorize: Colors.grey;
|
icon-colorize: Colors.grey;
|
||||||
icon-size: 1.5rem;
|
icon-size: 1.5rem;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
clicked => { Backend.open-edit-event-form(event.sourceId, event.id) }
|
clicked => { edit-name = true; }
|
||||||
}
|
}
|
||||||
|
|
||||||
VActionButton {
|
VActionButton {
|
||||||
|
@ -48,15 +49,14 @@ export component EventGroup {
|
||||||
spacing: 4px;
|
spacing: 4px;
|
||||||
VText {
|
VText {
|
||||||
text: Utils.time-to-string(event.startsAt);
|
text: Utils.time-to-string(event.startsAt);
|
||||||
|
horizontal-alignment: center;
|
||||||
color: Palette.accent;
|
color: Palette.accent;
|
||||||
}
|
}
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
alignment: center;
|
alignment: center;
|
||||||
Rectangle {
|
Rectangle {
|
||||||
width: 4px;
|
width: 2px;
|
||||||
background: Palette.accent;
|
background: Palette.accent;
|
||||||
border-radius: 8px;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
VText {
|
VText {
|
||||||
|
@ -72,10 +72,24 @@ export component EventGroup {
|
||||||
padding-top: 32px;
|
padding-top: 32px;
|
||||||
padding-bottom: 32px;
|
padding-bottom: 32px;
|
||||||
padding-right: 0px;
|
padding-right: 0px;
|
||||||
VText {
|
if !edit-name : VText {
|
||||||
text: event.title;
|
text: event.title;
|
||||||
font-size: 1.1rem;
|
font-size: 1.1rem;
|
||||||
}
|
}
|
||||||
|
if edit-name : title := VTextInput {
|
||||||
|
text: event.title;
|
||||||
|
accepted => {
|
||||||
|
Backend.save-event({
|
||||||
|
sourceId: event.sourceId,
|
||||||
|
id: event.id,
|
||||||
|
title: title.text,
|
||||||
|
//date: event.date,
|
||||||
|
startsAt: event.startsAt,
|
||||||
|
endsAt: event.endsAt,
|
||||||
|
});
|
||||||
|
root.edit-name = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
for task[taskIndex] in event.tasks: VerticalLayout {
|
for task[taskIndex] in event.tasks: VerticalLayout {
|
||||||
padding-top: taskIndex == 0 ? 16px : 0px;
|
padding-top: taskIndex == 0 ? 16px : 0px;
|
||||||
padding-bottom: 8px;
|
padding-bottom: 8px;
|
||||||
|
@ -85,6 +99,16 @@ export component EventGroup {
|
||||||
task-index: task.id;
|
task-index: task.id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if show-add-task : taskInput := VTextInput {
|
||||||
|
accepted => {
|
||||||
|
Backend.create-task({
|
||||||
|
sourceId: event.sourceId,
|
||||||
|
eventId: event.id,
|
||||||
|
title: taskInput.text,
|
||||||
|
});
|
||||||
|
root.show-add-task = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { Backend } from "../Backend.slint";
|
import { Backend } from "../Backend.slint";
|
||||||
import { VButton, ToggleButton, VText, Svg, Palette } from "@selenite";
|
import { VButton, ToggleButton, VActionButton, VText, Svg, Palette } from "@selenite";
|
||||||
|
|
||||||
export component SideBar inherits Rectangle {
|
export component SideBar inherits Rectangle {
|
||||||
background: Palette.pane;
|
background: Palette.pane;
|
||||||
|
@ -8,9 +8,20 @@ export component SideBar inherits Rectangle {
|
||||||
height: parent.height;
|
height: parent.height;
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
spacing: 16px;
|
spacing: 16px;
|
||||||
VText {
|
HorizontalLayout {
|
||||||
text: "Sources";
|
alignment: space-between;
|
||||||
font-size: 1.5rem;
|
spacing: 64px;
|
||||||
|
VText {
|
||||||
|
text: "Sources";
|
||||||
|
font-size: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
VActionButton {
|
||||||
|
icon-svg: Svg.plus;
|
||||||
|
icon-colorize: Palette.green;
|
||||||
|
background: transparent;
|
||||||
|
clicked => { Backend.add-source-clicked() }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
VerticalLayout {
|
VerticalLayout {
|
||||||
alignment: space-between;
|
alignment: space-between;
|
||||||
|
@ -23,23 +34,31 @@ export component SideBar inherits Rectangle {
|
||||||
text-alignment: left;
|
text-alignment: left;
|
||||||
active: Backend.no-source-selected;
|
active: Backend.no-source-selected;
|
||||||
clicked => { Backend.source-clicked(-1) }
|
clicked => { Backend.source-clicked(-1) }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
for item[index] in Backend.sources-selected: ToggleButton {
|
for item[index] in Backend.sources-selected: ToggleButton {
|
||||||
text: item.name;
|
text: item.name;
|
||||||
text-alignment: left;
|
text-alignment: left;
|
||||||
active: item.selected;
|
active: item.selected;
|
||||||
clicked => { Backend.source-clicked(index) }
|
clicked => { Backend.source-clicked(index) }
|
||||||
|
VActionButton {
|
||||||
|
visible: parent.active;
|
||||||
|
icon-svg: Svg.cog;
|
||||||
|
background: transparent;
|
||||||
|
clicked => { Backend.edit-source-clicked(item.id) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/*VerticalLayout {
|
VerticalLayout {
|
||||||
spacing: 4px;
|
spacing: 4px;
|
||||||
VButton {
|
/*VButton {
|
||||||
icon-svg: Svg.cog;
|
icon-svg: Svg.cog;
|
||||||
text: "Settings";
|
text: "Settings";
|
||||||
background: transparent;
|
background: transparent;
|
||||||
clicked => { Backend.settings-clicked() }
|
clicked => { Backend.settings-clicked() }
|
||||||
}
|
}*/
|
||||||
}*/
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,13 +1,15 @@
|
||||||
import { Backend, TaskData } from "../Backend.slint";
|
import { Backend, TaskData } from "../Backend.slint";
|
||||||
import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint";
|
import { Button, VerticalBox, CheckBox, Date, ScrollView, ComboBox } from "std-widgets.slint";
|
||||||
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite";
|
import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite";
|
||||||
import { NewTaskData, SaveTaskData } from "../Backend.slint";
|
import { NewTaskData, SaveTaskData } from "../Backend.slint";
|
||||||
|
|
||||||
export component TaskEdit inherits VerticalLayout {
|
export component TaskEdit inherits VerticalLayout {
|
||||||
in-out property <SaveTaskData> task;
|
in-out property <TaskData> task;
|
||||||
out property <bool> should-show;
|
out property <bool> should-show;
|
||||||
|
|
||||||
public function show(task: SaveTaskData) {
|
private property <Date> newDate: task.date;
|
||||||
|
|
||||||
|
public function show(task: TaskData) {
|
||||||
root.task = task;
|
root.task = task;
|
||||||
should-show = true;
|
should-show = true;
|
||||||
}
|
}
|
||||||
|
@ -16,8 +18,6 @@ export component TaskEdit inherits VerticalLayout {
|
||||||
}
|
}
|
||||||
callback accepted(SaveTaskData);
|
callback accepted(SaveTaskData);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if !should-show : Rectangle {}
|
if !should-show : Rectangle {}
|
||||||
|
|
||||||
if should-show : Rectangle {
|
if should-show : Rectangle {
|
||||||
|
@ -26,8 +26,8 @@ export component TaskEdit inherits VerticalLayout {
|
||||||
id: task.id,
|
id: task.id,
|
||||||
sourceId: task.sourceId,
|
sourceId: task.sourceId,
|
||||||
title: newTaskTitleInput.text,
|
title: newTaskTitleInput.text,
|
||||||
scheduled: taskDateInput.date.year != 0,
|
scheduled: newDate.year != 0,
|
||||||
date: taskDateInput.date
|
date: newDate
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
background: Palette.background;
|
background: Palette.background;
|
||||||
|
@ -43,9 +43,10 @@ export component TaskEdit inherits VerticalLayout {
|
||||||
HorizontalLayout {
|
HorizontalLayout {
|
||||||
alignment: start;
|
alignment: start;
|
||||||
spacing: 8px;
|
spacing: 8px;
|
||||||
taskDateInput := VDatePicker {
|
if root.task.eventId == -1 : taskDateInput := VDatePicker {
|
||||||
date: task.date;
|
date: task.date;
|
||||||
enabled: true;
|
enabled: true;
|
||||||
|
edited(date) => { newDate = date; }
|
||||||
}
|
}
|
||||||
VButton {
|
VButton {
|
||||||
text: "Modify";
|
text: "Modify";
|
||||||
|
|
|
@ -44,8 +44,10 @@ export component TaskLine inherits VerticalLayout {
|
||||||
taskEdit.show({
|
taskEdit.show({
|
||||||
sourceId: task.sourceId,
|
sourceId: task.sourceId,
|
||||||
id: task.id,
|
id: task.id,
|
||||||
|
eventId: task.eventId,
|
||||||
title: task.title,
|
title: task.title,
|
||||||
scheduled: root.date.year != 0,
|
scheduled: root.date.year != 0,
|
||||||
|
checked: task.checked,
|
||||||
date: date,
|
date: date,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -87,10 +89,10 @@ export component TaskLine inherits VerticalLayout {
|
||||||
Backend.task-clicked(source-index, task-index)
|
Backend.task-clicked(source-index, task-index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for tag[tag-index] in task.tags: VTag {
|
/*for tag[tag-index] in task.tags: VTag {
|
||||||
text: tag;
|
text: tag;
|
||||||
size: 0.8rem;
|
size: 0.8rem;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
37
ui/windows/AddSourceWindow.slint
Normal file
37
ui/windows/AddSourceWindow.slint
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
import { Backend } from "../Backend.slint";
|
||||||
|
import { VerticalBox, CheckBox } from "std-widgets.slint";
|
||||||
|
import { SideBar } from "../components/SideBar.slint";
|
||||||
|
import { VButton, VText, VTextInput, Palette } from "@selenite";
|
||||||
|
|
||||||
|
export component AddSourceWindow inherits Window {
|
||||||
|
|
||||||
|
title: "Mirai - Add source";
|
||||||
|
min-height: 100px;
|
||||||
|
max-height: 4000px; // needed, otherwise the window wants to fit the content (on Swaywm)
|
||||||
|
min-width: 400px;
|
||||||
|
default-font-size: 16px;
|
||||||
|
background: Palette.background;
|
||||||
|
|
||||||
|
VerticalLayout {
|
||||||
|
padding: 16px;
|
||||||
|
spacing: 8px;
|
||||||
|
nameInput := VTextInput {
|
||||||
|
label: "Name";
|
||||||
|
}
|
||||||
|
pathInput := VTextInput {
|
||||||
|
label: "Path";
|
||||||
|
}
|
||||||
|
VButton {
|
||||||
|
text: "Create";
|
||||||
|
clicked => {
|
||||||
|
Backend.add-source({
|
||||||
|
name: nameInput.text,
|
||||||
|
type: "FileSystemMarkdown",
|
||||||
|
path: pathInput.text
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Backend, Palette } // Export to make it visible to the C++ backend
|
47
ui/windows/EditSourceWindow.slint
Normal file
47
ui/windows/EditSourceWindow.slint
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
import { Backend } from "../Backend.slint";
|
||||||
|
import { VerticalBox, CheckBox } from "std-widgets.slint";
|
||||||
|
import { SideBar } from "../components/SideBar.slint";
|
||||||
|
import { VButton, VText, VTextInput, Palette } from "@selenite";
|
||||||
|
|
||||||
|
export component EditSourceWindow inherits Window {
|
||||||
|
in-out property <int> id;
|
||||||
|
in-out property name <=> nameInput.text;
|
||||||
|
in-out property path <=> pathInput.text;
|
||||||
|
|
||||||
|
title: "Mirai - Edit source";
|
||||||
|
min-height: 100px;
|
||||||
|
max-height: 4000px; // needed, otherwise the window wants to fit the content (on Swaywm)
|
||||||
|
min-width: 400px;
|
||||||
|
default-font-size: 16px;
|
||||||
|
background: Palette.background;
|
||||||
|
|
||||||
|
VerticalLayout {
|
||||||
|
padding: 16px;
|
||||||
|
spacing: 8px;
|
||||||
|
nameInput := VTextInput {
|
||||||
|
label: "Name";
|
||||||
|
}
|
||||||
|
pathInput := VTextInput {
|
||||||
|
label: "Path";
|
||||||
|
}
|
||||||
|
VButton {
|
||||||
|
text: "Save";
|
||||||
|
clicked => {
|
||||||
|
Backend.modify-source({
|
||||||
|
id: root.id,
|
||||||
|
name: nameInput.text,
|
||||||
|
path: pathInput.text
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
VButton {
|
||||||
|
text: "Delete";
|
||||||
|
background-color: Colors.red;
|
||||||
|
double-clicked => {
|
||||||
|
Backend.delete-source(root.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export { Backend, Palette } // Export to make it visible to the C++ backend
|
Loading…
Add table
Add a link
Reference in a new issue