diff --git a/CMakeLists.txt b/CMakeLists.txt index d90a0a6..f10b6a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,6 @@ add_executable(mirai src/main.cpp src/windows/AppWindow/AppWindow.cpp src/windows/SettingsWindow/SettingsWindow.cpp - src/windows/EditEventWindow/EditEventWindow.cpp src/SeleniteSetup.cpp src/shared/Utils.cpp ) diff --git a/external/selenite b/external/selenite index fa86c85..810607c 160000 --- a/external/selenite +++ b/external/selenite @@ -1 +1 @@ -Subproject commit fa86c85483725f269ee06001dba8c4c2a438194d +Subproject commit 810607c01fa659f31bd11bd41a9ee5611e5db8ea diff --git a/src/modals/AddEventModal.slint b/src/modals/AddEventModal.slint new file mode 100644 index 0000000..4e6a00c --- /dev/null +++ b/src/modals/AddEventModal.slint @@ -0,0 +1,43 @@ +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 { Modal } from "../../external/selenite/components/Modal.slint"; +import { VTimePicker } from "../../external/selenite/components/TimePicker.slint"; + +export component AddEventModal inherits Modal { + public function open() { + root.show(); + } + + VerticalLayout { + padding: 16px; + spacing: 8px; + titleInput := VTextInput { + label: "title"; + } + VText { text: "on"; vertical-alignment: bottom;} + dateInput := VDatePicker { + enabled: true; + } + HorizontalLayout { + spacing: 4px; + VText { text: "between"; vertical-alignment: bottom; } + startTimeInput := VTimePicker { } + VText { text: "and"; vertical-alignment: bottom; } + endTimeInput := VTimePicker { } + } + VButton { + text: "Create"; + clicked => { + AppWindowActions.create-event({ + title: titleInput.text, + date: dateInput.date, + startsAt: startTimeInput.time, + endsAt: endTimeInput.time + }); + root.close(); + } + } + } +} diff --git a/src/ui.slint b/src/ui.slint index 9f10028..2a72c3f 100644 --- a/src/ui.slint +++ b/src/ui.slint @@ -2,8 +2,7 @@ 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 { EditEventWindow } from "windows/EditEventWindow/EditEventWindow.slint"; import { Utils } from "shared/Utils.slint"; import { Palette } from "@selenite"; -export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions, SettingsWindow, EditEventWindow } +export { Utils, Palette, AppWindow, AppWindowModels, AppWindowActions, SettingsWindow } diff --git a/src/windows/AppWindow/AppWindow.cpp b/src/windows/AppWindow/AppWindow.cpp index 75f7fdb..8a632d0 100644 --- a/src/windows/AppWindow/AppWindow.cpp +++ b/src/windows/AppWindow/AppWindow.cpp @@ -33,8 +33,7 @@ #include AppWindow::AppWindow(mirai::Mirai *miraiInstance) - : miraiInstance_(miraiInstance), settingsWindow_(miraiInstance), - editEventWindow_(miraiInstance), view_(miraiInstance) + : miraiInstance_(miraiInstance), settingsWindow_(miraiInstance), view_(miraiInstance) { sources_ = std::make_shared>(); days_ = std::make_shared>(); @@ -133,7 +132,7 @@ void AppWindow::setupCallbacks() /*editSourceWindow_.open(source);*/ /*});*/ actions().on_open_add_event_window([&]() { - editEventWindow_.open(); + // editEventWindow_.open(); }); actions().on_task_clicked([&](int sourceId, int taskId) { diff --git a/src/windows/AppWindow/AppWindow.h b/src/windows/AppWindow/AppWindow.h index 177683e..0d25941 100644 --- a/src/windows/AppWindow/AppWindow.h +++ b/src/windows/AppWindow/AppWindow.h @@ -6,7 +6,6 @@ #pragma once -#include "../EditEventWindow/EditEventWindow.h" #include "../SettingsWindow/SettingsWindow.h" #include "mirai-core/Mirai.h" #include "mirai-core/View.h" @@ -37,7 +36,6 @@ class AppWindow slint::ComponentHandle mainWindow_ = ui::AppWindow::create(); SettingsWindow settingsWindow_; - EditEventWindow editEventWindow_; mirai::Mirai *miraiInstance_; mirai::View view_; diff --git a/src/windows/AppWindow/views/CalendarView.slint b/src/windows/AppWindow/views/CalendarView.slint index cd95e40..507590d 100644 --- a/src/windows/AppWindow/views/CalendarView.slint +++ b/src/windows/AppWindow/views/CalendarView.slint @@ -4,10 +4,11 @@ import { Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets import { TaskLine } from "../../../components/TaskLine.slint"; import { EventGroup } from "../../../components/EventGroup.slint"; import { Calendar } from "../../../components/Calendar.slint"; -import { VPopupIconMenu, VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite"; +import { VDatePicker, VTimePicker, VCheckBox, VButton, VTag, VText, VTextInput, Svg, Palette } from "@selenite"; import { CreateTaskOrEvent } from "../../../components/CreateTaskOrEvent.slint"; import { Utils } from "../../../shared/Utils.slint"; import { VActionButton } from "../../../../external/selenite/components/index.slint"; +import { AddEventModal } from "../../../modals/AddEventModal.slint"; export component CalendarView inherits Rectangle { @@ -15,49 +16,7 @@ export component CalendarView inherits Rectangle { private property icon-not-visible: Svg.not-visible; private property completed-tasks-visible: false; - createEventPopup := PopupWindow { - x: parent.width / 2 - 200px; - y: parent.height / 2 - 300px; - close-policy: close-on-click-outside; - background := Rectangle { - height: 100%; - width: 100%; - background: Palette.background1; - border-color: Palette.popup-border; - border-width: 1px; - border-radius: 4px; - } - VerticalLayout { - padding: 16px; - spacing: 8px; - titleInput := VTextInput { - label: "title"; - } - VText { text: "on"; vertical-alignment: bottom;} - dateInput := VDatePicker { - enabled: true; - } - HorizontalLayout { - spacing: 4px; - VText { text: "between"; vertical-alignment: bottom; } - startTimeInput := VTimePicker { } - VText { text: "and"; vertical-alignment: bottom; } - endTimeInput := VTimePicker { } - } - VButton { - text: "Create"; - clicked => { - AppWindowActions.create-event({ - title: titleInput.text, - date: dateInput.date, - startsAt: startTimeInput.time, - endsAt: endTimeInput.time - }); - createEventPopup.close(); - } - } - } - } + createEventPopup := AddEventModal {} VerticalLayout { padding: 16px; diff --git a/src/windows/EditEventWindow/EditEventWindow.cpp b/src/windows/EditEventWindow/EditEventWindow.cpp deleted file mode 100644 index 276ad05..0000000 --- a/src/windows/EditEventWindow/EditEventWindow.cpp +++ /dev/null @@ -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 "EditEventWindow.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 -#include -#include -#include -#include -#include -#include -#include -#include - -EditEventWindow::EditEventWindow(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(), palette.value()); - } - - setupCallbacks(); -} - -void EditEventWindow::setupCallbacks() -{ -} - -void EditEventWindow::open() -{ - window_->show(); -} - -void EditEventWindow::close() -{ - window_->hide(); -} diff --git a/src/windows/EditEventWindow/EditEventWindow.h b/src/windows/EditEventWindow/EditEventWindow.h deleted file mode 100644 index 4914c01..0000000 --- a/src/windows/EditEventWindow/EditEventWindow.h +++ /dev/null @@ -1,33 +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 EditEventWindow -{ - - public: - EditEventWindow(mirai::Mirai *mirai); - - void open(); - void close(); - - auto getHandle() - { - return this->window_; - } - - private: - void setupCallbacks(); - - std::shared_ptr> sources_; - slint::ComponentHandle window_ = ui::EditEventWindow::create(); - mirai::Mirai *miraiInstance_; -}; diff --git a/src/windows/EditEventWindow/EditEventWindow.slint b/src/windows/EditEventWindow/EditEventWindow.slint deleted file mode 100644 index 8f1297d..0000000 --- a/src/windows/EditEventWindow/EditEventWindow.slint +++ /dev/null @@ -1,68 +0,0 @@ -import { AppWindowModels } from "../AppWindow/Models.slint"; -import { Button, VerticalBox, CheckBox } from "std-widgets.slint"; -import { VText, VTextInput, Palette } from "@selenite"; -import { VButton } from "../../../external/selenite/components/index.slint"; -import { Date, Time, Button, VerticalBox, CheckBox, ScrollView, ComboBox } from "std-widgets.slint"; -import { VDatePicker } from "../../../external/selenite/components/DatePicker.slint"; -import { VTimePicker } from "../../../external/selenite/components/TimePicker.slint"; - -export struct CreateEventParams { - title: string, - date: Date, - startsAt: Time, - endsAt: Time -} - -export component EditEventWindow inherits Window { - - title: "Mirai - Event"; - min-height: 100px; - max-height: 500px; // needed, otherwise the window wants to fit the content (on Swaywm) - max-width: 500px; // needed, otherwise the window wants to fit the content (on Swaywm) - background: Palette.background; - in-out property sourceId; - - callback create-event(CreateEventParams); - callback delete-event(int); - - VerticalLayout { - padding: 16px; - spacing: 8px; - titleInput := VTextInput { - label: "title"; - } - VText { text: "on"; vertical-alignment: bottom;} - dateInput := VDatePicker { - enabled: true; - } - HorizontalLayout { - spacing: 4px; - VText { text: "between"; vertical-alignment: bottom; } - startTimeInput := VTimePicker { } - VText { text: "and"; vertical-alignment: bottom; } - endTimeInput := VTimePicker { } - } - VButton { - text: "Create"; - clicked => { - debug("clicked"); - root.create-event({ - title: titleInput.text, - date: dateInput.date, - startsAt: startTimeInput.time, - endsAt: endTimeInput.time - }) - } - } - VButton { - text: "Delete"; - background-color: Palette.red; - double-clicked => { - //root.delete-event(root.id) - } - } - } - -} - -export { AppWindowModels, Palette } // Export to make it visible to the C++ backend