From: Olaf Wintermann Date: Thu, 3 Sep 2026 18:21:40 +0000 (+0200) Subject: add UI for the attachments window X-Git-Url: https://uap-core.de/gitweb/?a=commitdiff_plain;h=f00975960b71b18e69ea392642bfe0fdca8dcd88;p=note.git add UI for the attachments window --- diff --git a/application/note/src/attachments_window.rs b/application/note/src/attachments_window.rs new file mode 100644 index 0000000..00cda9c --- /dev/null +++ b/application/note/src/attachments_window.rs @@ -0,0 +1,83 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2026 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +use ui_rs::ui::*; +use ui_rs::{action, button, imageviewer, tabview, ui_actions, webview, UiModel}; + +pub fn attachments_window_create(note_id: i32, selected_attachment: Option) { + let data = AttachmentsWindow::new(note_id); + + let obj = simple_window("Attachments", data, |obj, data|{ + obj.headerbar().create(|hb|{ + hb.start(|obj|{ + button!(obj, icon = UiIconSet::GoBack.as_str(), action = "go_back"); + button!(obj, icon = UiIconSet::GoBack.as_str(), action = "go_forward"); + }); + }); + + tabview!(obj, tabview_type = TabViewType::Invisible, varname = "attachment_view_type", |tv|{ + tv.tab("img", |obj|{ + imageviewer!(obj, varname = "image", fill = true); + }); + tv.tab("webview", |obj|{ + webview!(obj, varname = "webview", fill = true); + }); + }); + }); +} + + +#[derive(UiModel, Default)] +pub struct AttachmentsWindow { + note_id: i32, + + #[bind("image")] + pub image: UiImage, + + #[bind("webview")] + pub webview: UiWeb, +} + +#[ui_actions] +impl AttachmentsWindow { + pub fn new(note_id: i32) -> AttachmentsWindow { + AttachmentsWindow { + note_id, + ..Default::default() + } + } + + #[action] + pub fn go_back(&mut self, _event: &ActionEvent) { + + } + + #[action] + pub fn go_forward(&mut self, _event: &ActionEvent) { + + } +} diff --git a/application/note/src/main.rs b/application/note/src/main.rs index d8ebbb1..a8cc9f2 100644 --- a/application/note/src/main.rs +++ b/application/note/src/main.rs @@ -32,6 +32,7 @@ mod notebook; mod note; mod file; mod attachment; +mod attachments_window; use std::env; use backend::backend::{Backend, BackendHandle, BroadcastMessage};