Generate default config file if it doesn't exist

This commit is contained in:
Vyn 2024-08-31 10:20:57 +02:00
parent cbaa1b58d8
commit 924e35ecc4
2 changed files with 13 additions and 1 deletions

View file

@ -5,9 +5,9 @@
*/
#include "ConfigImpl.h"
#include "nlohmann/json.hpp"
#include <fstream>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
@ -16,6 +16,14 @@ 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);
}

View file

@ -63,6 +63,10 @@ export component MainView inherits Rectangle {
VerticalLayout {
alignment: start;
spacing: 16px;
if Backend.visible_tasks.length == 0 : VText {
text: "There is no task to show";
horizontal-alignment: center;
}
for day[dayIndex] in Backend.visible_tasks: VerticalLayout {
Rectangle {
background: Palette.card-background;