Mercurial > libervia-desktop-kivy
changeset 287:5d96bcd3bfec
chat: added an extra menu (3 dots menu):
first entry is this menu display bookmarks. This menu will be used in the future to show advances actions like showing occupants or configuring room.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 27 Mar 2019 22:22:51 +0100 |
parents | 4772ba26623f |
children | 44752e8031f8 |
files | cagou/plugins/plugin_wid_chat.kv cagou/plugins/plugin_wid_chat.py |
diffstat | 2 files changed, 42 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.kv Wed Mar 27 22:22:51 2019 +0100 +++ b/cagou/plugins/plugin_wid_chat.kv Wed Mar 27 22:22:51 2019 +0100 @@ -142,6 +142,26 @@ font_size: dp(25) color: 0.4, 0.4, 0.4, 1 +<MenuButton@Button> + size_hint_y: None + height: dp(30) + on_texture_size: self.parent.parent.width = max(self.parent.parent.width, self.texture_size[0] + dp(10)) + +<ExtraMenu>: + size_hint: None, 1 + width: 10 + auto_width: False + MenuButton: + text: _("Bookmarks") + on_release: root.select("bookmark") + +<ExtraButton>: + size_hint: None, 1 + symbol: "dot-3-vert" + width: dp(30) + font_size: dp(25) + color: 0.4, 0.4, 0.4, 1 + on_release: self.chat.extra_menu.open(self) <EncryptionMainButton>: size_hint: None, 1
--- a/cagou/plugins/plugin_wid_chat.py Wed Mar 27 22:22:51 2019 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Wed Mar 27 22:22:51 2019 +0100 @@ -23,6 +23,7 @@ import sys from sat.core import log as logging from sat.core.i18n import _ +from sat.core import exceptions from cagou.core.constants import Const as C from kivy.uix.boxlayout import BoxLayout from kivy.uix.gridlayout import GridLayout @@ -174,6 +175,24 @@ menu.TransferMenu(callback=self.chat.onTransferOK).show(self) +class ExtraMenu(DropDown): + chat = properties.ObjectProperty() + + def on_select(self, menu): + if menu == 'bookmark': + G.host.bridge.menuLaunch(C.MENU_GLOBAL, (u"groups", u"bookmarks"), + {}, C.NO_SECURITY_LIMIT, self.chat.profile, + callback=partial( + G.host.actionManager, profile=self.chat.profile), + errback=G.host.errback) + else: + raise exceptions.InternalError(u"Unknown menu: {}".format(menu)) + + +class ExtraButton(SymbolButton): + chat = properties.ObjectProperty() + + class EncryptionMainButton(SymbolButton): def __init__(self, chat, **kwargs): @@ -181,7 +200,6 @@ @param chat(Chat): Chat instance """ self.chat = chat - # for now we do a simple ContextMenu as we have only OTR self.encryption_menu = EncryptionMenu(chat) super(EncryptionMainButton, self).__init__(**kwargs) self.bind(on_release=self.encryption_menu.open) @@ -393,6 +411,9 @@ if type_ == C.CHAT_ONE2ONE: self.encryption_btn = EncryptionMainButton(self) self.headerInputAddExtra(self.encryption_btn) + self.extra_menu = ExtraMenu(chat=self) + extra_btn = ExtraButton(chat=self) + self.headerInputAddExtra(extra_btn) self.header_input.hint_text = u"{}".format(target) self.postInit()