mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-01 08:53:20 +00:00
Remove old 'add source window'
This commit is contained in:
parent
fcdeec19ed
commit
c804ce1c7b
8 changed files with 5 additions and 142 deletions
|
@ -31,7 +31,6 @@ add_subdirectory(external/evalyte-cpp-common)
|
|||
add_executable(mirai
|
||||
src/main.cpp
|
||||
src/windows/AppWindow/AppWindow.cpp
|
||||
src/windows/AddSourceWindow/AddSourceWindow.cpp
|
||||
src/windows/SettingsWindow/SettingsWindow.cpp
|
||||
src/windows/EditEventWindow/EditEventWindow.cpp
|
||||
src/SeleniteSetup.cpp
|
||||
|
|
|
@ -2,9 +2,8 @@ import { AppWindowModels } from "windows/AppWindow/Models.slint";
|
|||
import { AppWindowActions } from "windows/AppWindow/Actions.slint";
|
||||
import { AppWindow } from "windows/AppWindow/AppWindow.slint";
|
||||
import { SettingsWindow } from "windows/SettingsWindow/SettingsWindow.slint";
|
||||
import { AddSourceWindow } from "windows/AddSourceWindow//AddSourceWindow.slint";
|
||||
import { EditEventWindow } from "windows/EditEventWindow/EditEventWindow.slint";
|
||||
import { Utils } from "shared/Utils.slint";
|
||||
import { Palette } from "@selenite";
|
||||
|
||||
export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions, SettingsWindow, AddSourceWindow, EditEventWindow }
|
||||
export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions, SettingsWindow, EditEventWindow }
|
||||
|
|
|
@ -1,59 +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 "AddSourceWindow.h"
|
||||
#include "../../SeleniteSetup.h"
|
||||
#include "evalyte-cpp-common/evalyte.h"
|
||||
#include "mirai-core/MarkdownDataProvider.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
#include "slint.h"
|
||||
#include "slint_string.h"
|
||||
#include "ui.h"
|
||||
#include <bits/chrono.h>
|
||||
#include <cassert>
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <ctime>
|
||||
#include <optional>
|
||||
#include <print>
|
||||
#include <string>
|
||||
|
||||
AddSourceWindow::AddSourceWindow(mirai::Mirai *miraiInstance) : miraiInstance_(miraiInstance)
|
||||
{
|
||||
window_->set_default_source_path(slint::SharedString(evalyte::dataDirectoryPath("mirai") + "/")
|
||||
);
|
||||
|
||||
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 AddSourceWindow::setupCallbacks()
|
||||
{
|
||||
window_->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)
|
||||
);
|
||||
window_->hide();
|
||||
});
|
||||
}
|
||||
|
||||
void AddSourceWindow::open()
|
||||
{
|
||||
window_->show();
|
||||
}
|
||||
|
||||
void AddSourceWindow::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 AddSourceWindow
|
||||
{
|
||||
|
||||
public:
|
||||
AddSourceWindow(mirai::Mirai *mirai);
|
||||
|
||||
void open();
|
||||
void close();
|
||||
|
||||
private:
|
||||
void setupCallbacks();
|
||||
|
||||
std::shared_ptr<slint::VectorModel<ui::Source>> sources_;
|
||||
slint::ComponentHandle<ui::AddSourceWindow> window_ = ui::AddSourceWindow::create();
|
||||
mirai::Mirai *miraiInstance_;
|
||||
};
|
|
@ -1,45 +0,0 @@
|
|||
import { VerticalBox, CheckBox } from "std-widgets.slint";
|
||||
import { VButton, VText, VTextInput, Palette } from "@selenite";
|
||||
|
||||
export struct AddSourceParam {
|
||||
name: string,
|
||||
type: string,
|
||||
path: string
|
||||
}
|
||||
|
||||
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;
|
||||
background: Palette.background;
|
||||
|
||||
in-out property <string> default-source-path;
|
||||
callback add-source(AddSourceParam);
|
||||
|
||||
VerticalLayout {
|
||||
padding: 16px;
|
||||
spacing: 8px;
|
||||
nameInput := VTextInput {
|
||||
label: "Name";
|
||||
text: "todo";
|
||||
}
|
||||
pathInput := VTextInput {
|
||||
label: "Path";
|
||||
text: root.default-source-path + nameInput.text + ".md";
|
||||
}
|
||||
VButton {
|
||||
text: "Create";
|
||||
clicked => {
|
||||
root.add-source({
|
||||
name: nameInput.text,
|
||||
type: "FileSystemMarkdown",
|
||||
path: pathInput.text
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export { Palette } // Export to make it visible to the C++ backend
|
|
@ -33,8 +33,8 @@
|
|||
#include <vector>
|
||||
|
||||
AppWindow::AppWindow(mirai::Mirai *miraiInstance)
|
||||
: miraiInstance_(miraiInstance), addSourceWindow_(miraiInstance),
|
||||
settingsWindow_(miraiInstance), editEventWindow_(miraiInstance), view_(miraiInstance)
|
||||
: miraiInstance_(miraiInstance), settingsWindow_(miraiInstance),
|
||||
editEventWindow_(miraiInstance), view_(miraiInstance)
|
||||
{
|
||||
sources_ = std::make_shared<slint::VectorModel<ui::Source>>();
|
||||
days_ = std::make_shared<slint::VectorModel<ui::Day>>();
|
||||
|
@ -125,7 +125,7 @@ void AppWindow::setupCallbacks()
|
|||
settingsWindow_.open();
|
||||
});
|
||||
actions().on_open_add_source_window([&]() {
|
||||
addSourceWindow_.open();
|
||||
// addSourceWindow_.open();
|
||||
});
|
||||
/*actions().on_open_edit_source_window([&](int sourceId) {*/
|
||||
/*auto source = miraiInstance_->getSourceById(sourceId);*/
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "../AddSourceWindow/AddSourceWindow.h"
|
||||
#include "../EditEventWindow/EditEventWindow.h"
|
||||
#include "../SettingsWindow/SettingsWindow.h"
|
||||
#include "mirai-core/Mirai.h"
|
||||
|
@ -38,7 +37,6 @@ class AppWindow
|
|||
|
||||
slint::ComponentHandle<ui::AppWindow> mainWindow_ = ui::AppWindow::create();
|
||||
SettingsWindow settingsWindow_;
|
||||
AddSourceWindow addSourceWindow_;
|
||||
EditEventWindow editEventWindow_;
|
||||
|
||||
mirai::Mirai *miraiInstance_;
|
||||
|
|
|
@ -2,7 +2,6 @@ import { AppWindowModels } from "Models.slint";
|
|||
import { Button, VerticalBox, CheckBox } from "std-widgets.slint";
|
||||
import { MainView } from "views/TasksView.slint";
|
||||
import { SettingsWindow } from "../SettingsWindow/SettingsWindow.slint";
|
||||
import { AddSourceWindow } from "../AddSourceWindow//AddSourceWindow.slint";
|
||||
import { Palette } from "@selenite";
|
||||
import { CalendarView } from "views/CalendarView.slint";
|
||||
import { VButton } from "../../../external/selenite/components/Button.slint";
|
||||
|
@ -71,4 +70,4 @@ export component AppWindow inherits Window {
|
|||
}
|
||||
}
|
||||
|
||||
export { AppWindowModels, Palette, SettingsWindow, AddSourceWindow } // Export to make it visible to the C++ backend
|
||||
export { AppWindowModels, Palette, SettingsWindow } // Export to make it visible to the C++ backend
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue