diff cagou/plugins/plugin_wid_chat.kv @ 448:20a807443c3f

chat: resize attachments (images only for now): if attachments to send contain oversized image, a checkbox will be shown (activated by default) to reduce automatically the size. The background color now cover the whole attachments to send widget. If not already specified, media type is guessed from filename when adding an attachment.
author Goffi <goffi@goffi.org>
date Sun, 22 Mar 2020 14:10:59 +0100
parents f3296a7f35f3
children 6c21a5a44b54
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.kv	Wed Mar 18 20:26:21 2020 +0100
+++ b/cagou/plugins/plugin_wid_chat.kv	Sun Mar 22 14:10:59 2020 +0100
@@ -172,11 +172,18 @@
 
 <AttachmentsToSend>:
     attachments: attachments_layout.attachments
+    reduce_checkbox: reduce_checkbox
     orientation: "vertical"
     size_hint: 1, None
     height: self.minimum_height if self.attachments.children else 0
     opacity: 1 if self.attachments.children else 0
     padding: [app.MARGIN_LEFT, dp(5), app.MARGIN_RIGHT, dp(5)]
+    canvas.before:
+        Color:
+            rgba: app.c_prim
+        Rectangle:
+            pos: self.pos
+            size: self.size
     Label:
         size_hint: 1, None
         size: self.texture_size
@@ -184,13 +191,26 @@
         bold: True
     AttachmentsLayout:
         id: attachments_layout
-        canvas.before:
-            Color:
-                rgba: app.c_prim
-            Rectangle:
-                pos: self.pos
-                size: self.size
-
+    BoxLayout:
+        id: resize_box
+        size_hint: 1, None
+        opacity: 1 if root.show_resize else 0
+        height: dp(25) if root.show_resize else 0
+        Widget:
+        CheckBox:
+            id: reduce_checkbox
+            size_hint: None, 1
+            width: dp(20)
+            active: True
+        Label:
+            size_hint: None, 1
+            text: _("reduce images size")
+            text_size: None, None
+            size: self.texture_size
+            valign: "middle"
+            padding_x: dp(10)
+            font_size: sp(15)
+        Widget:
 
 <Chat>:
     attachments_to_send: attachments_to_send