]> uap-core.de Git - note.git/commitdiff
add UI for the attachments window
authorOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 3 Sep 2026 18:21:40 +0000 (20:21 +0200)
committerOlaf Wintermann <olaf.wintermann@gmail.com>
Thu, 3 Sep 2026 18:21:40 +0000 (20:21 +0200)
application/note/src/attachments_window.rs [new file with mode: 0644]
application/note/src/main.rs

diff --git a/application/note/src/attachments_window.rs b/application/note/src/attachments_window.rs
new file mode 100644 (file)
index 0000000..00cda9c
--- /dev/null
@@ -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<i32>) {
+    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) {
+
+    }
+}
index d8ebbb13691e4d82fb6e4aa1443996e6b945174a..a8cc9f277f9f95aa735ef84afb78c0a18a7cfa1c 100644 (file)
@@ -32,6 +32,7 @@ mod notebook;
 mod note;
 mod file;
 mod attachment;
+mod attachments_window;
 
 use std::env;
 use backend::backend::{Backend, BackendHandle, BroadcastMessage};