mirror of
https://codeberg.org/vyn/mirai.git
synced 2025-07-03 18:23:19 +00:00
Replace 'add source window' with popup
This commit is contained in:
parent
854152b395
commit
fcdeec19ed
8 changed files with 98 additions and 76 deletions
|
@ -50,6 +50,7 @@ export global AppWindowActions {
|
|||
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);
|
||||
|
|
|
@ -165,6 +165,12 @@ void AppWindow::setupCallbacks()
|
|||
reloadTasks();
|
||||
});
|
||||
|
||||
actions().on_add_source([&](slint::SharedString name, slint::SharedString path) {
|
||||
std::unique_ptr<mirai::DataProvider> file =
|
||||
std::make_unique<mirai::MarkdownDataProvider>(std::string(path));
|
||||
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));
|
||||
});
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { AppWindowModels } from "Models.slint";
|
||||
import { Button, VerticalBox, CheckBox } from "std-widgets.slint";
|
||||
import { SideBar } from "views/SideBar.slint";
|
||||
import { MainView } from "views/TasksView.slint";
|
||||
import { SettingsWindow } from "../SettingsWindow/SettingsWindow.slint";
|
||||
import { AddSourceWindow } from "../AddSourceWindow//AddSourceWindow.slint";
|
||||
|
@ -10,8 +9,8 @@ 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 { EditSourceModal } from "../../components/editSourceModal.slint";
|
||||
|
||||
import { SideBar } from "views/SideBar.slint";
|
||||
|
||||
export component AppWindow inherits Window {
|
||||
|
||||
title: "Mirai";
|
||||
|
@ -21,8 +20,6 @@ export component AppWindow inherits Window {
|
|||
|
||||
private property<bool> show-tasks: false;
|
||||
|
||||
|
||||
|
||||
HorizontalLayout {
|
||||
// padding: 16px;
|
||||
//spacing: 16px;
|
||||
|
@ -47,7 +44,7 @@ export component AppWindow inherits Window {
|
|||
active: show-tasks;
|
||||
clicked => { show-tasks = true }
|
||||
}
|
||||
}
|
||||
}
|
||||
SideBar {
|
||||
min-width: 256px;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
import { AppWindowModels, TaskData } from "../Models.slint";
|
||||
import { AppWindowActions } from "../Actions.slint";
|
||||
import { VButton, ToggleButton, VActionButton, VText, Svg, Palette } from "@selenite";
|
||||
import { EditSourceModal } from "../../../components/editSourceModal.slint";
|
||||
import { EditSourceModal } from "../../../modals/EditSourceModal.slint";
|
||||
import { AddSourceModal } from "../../../modals/AddSourceModal.slint";
|
||||
|
||||
export component SideBar inherits Rectangle {
|
||||
|
||||
|
@ -9,10 +10,8 @@ export component SideBar inherits Rectangle {
|
|||
editSourcePopup.edit(source-id)
|
||||
}
|
||||
|
||||
editSourcePopup := EditSourceModal {
|
||||
//x: parent.width / 2 - 200px;
|
||||
//y: parent.height / 2 - 300px;
|
||||
}
|
||||
addSourcePopup := AddSourceModal{}
|
||||
editSourcePopup := EditSourceModal {}
|
||||
|
||||
VerticalLayout {
|
||||
height: parent.height;
|
||||
|
@ -35,7 +34,7 @@ export component SideBar inherits Rectangle {
|
|||
icon-svg: Svg.plus;
|
||||
icon-colorize: Palette.green;
|
||||
background: transparent;
|
||||
clicked => { AppWindowActions.open-add-source-window() }
|
||||
clicked => { addSourcePopup.open() }
|
||||
}
|
||||
}
|
||||
VerticalLayout {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue