view cagou/plugins/plugin_wid_chat.kv @ 466:cd448b877d1d

install: update requirements with alabaster==0.7.12 alembic==1.4.3 anki @ file:///build/anki/src/anki/dist/anki-2.1.35-py3-none-any.whl ankirspy @ file:///build/anki/src/anki/dist/ankirspy-2.1.35-cp39-cp39-manylinux1_x86_64.whl ansi2html==1.6.0 anytree==2.8.0 apipkg==1.5 apparmor==3.0.1 appdirs==1.4.4 appimage-builder==0.8.5 aqt @ file:///build/anki/src/anki/dist/aqt-2.1.35-py3-none-any.whl argcomplete==1.12.1 argon2-cffi==20.1.0 asn1crypto==1.4.0 async-generator==1.10 attrs==20.3.0 autobahn==21.3.1 Automat==20.2.0 autopep8==1.5.5 Babel==2.9.0 backcall==0.2.0 bcrypt==3.2.0 Beaker==1.11.0 beautifulsoup4==4.9.3 black==20.8b1 bleach==3.3.0 blinker==1.4 bmap-tools==3.5 breezy==3.1.0 Brlapi==0.8.2 btrfsutil==5.11 CacheControl==0.12.6 cached-property==1.5.2 cagou==0.8.0.dev0+83c67b093350.153 cairocffi==1.2.0 CairoSVG==2.5.2 certifi==2020.6.20 cffi==1.14.5 chardet==3.0.4 click==7.1.2 colorama==0.4.4 commonmark==0.9.1 configobj==5.1.0.dev0 constantly==15.1.0 contextlib2==0.6.0.post1 coverage==5.5 cryptography==3.4.6 css-parser==1.0.6 cssselect2==0.4.1 cycler==0.10.0 Cython==0.29.22 decorator==4.4.2 defusedxml==0.6.0 diffoscope==169 distlib==0.3.1 distro==1.5.0 docker==4.4.4 docker-compose==1.28.5 docker-pycreds==0.4.0 dockerpty==0.4.1 docopt==0.6.2 docutils==0.16 dulwich==0.20.20 emrichen==0.2.3 entrypoints==0.3 extras==1.0.0 fastimport==0.9.8 file-magic==0.4.0 filelock==3.0.12 fixtures==3.0.0 flake8==3.8.4 Flask==1.1.2 Flask-BabelEx==0.9.4 Flask-Compress==1.8.0 Flask-Cors==3.0.9 Flask-Gravatar==0.5.0 Flask-Login==0.5.0 Flask-Mail==0.9.1 Flask-Migrate==2.7.0 Flask-Paranoid==0.2.0 Flask-Principal==0.4.0 Flask-Script==2.0.6 Flask-Security-Too==3.3.3 Flask-SQLAlchemy==2.4.4 Flask-WTF==0.14.3 future==0.18.2 gajim==1.2.2 gssapi==1.6.12 html2text==2020.1.16 html5lib==1.1 httpie==2.4.0 httplib2==0.19.0 hyperlink==21.0.0 idna==2.10 imagesize==1.2.0 img2pdf==0.4.0 importlib-metadata==3.4.0 incremental==17.5.0 inflect==5.3.0 iniconfig==1.1.1 ipdb==0.13.6 ipykernel==5.4.2 ipython==7.19.0 ipython-genutils==0.2.0 ipywidgets==7.6.2 isc==2.0 itsdangerous==1.1.0 jedi==0.17.2 jeepney==0.6.0 Jinja2==2.11.3 joblib==1.0.0 jsonpath-rw==1.4.0 jsonpickle==1.5.1 jsonschema==3.2.0 jupyter-client==6.1.7 jupyter-console==6.2.0 jupyter-core==4.6.3 jupyterlab-pygments==0.1.2 keyring==23.0.0 Kivy==2.0.0 kiwisolver==1.3.1 langdetect==1.0.8 ldap3==2.9.dev0 lensfun==0.3.95 LibAppArmor==3.0.1 libarchive-c==2.9 libfdt==1.6.0 libnacl==1.7.2 lockfile==0.12.2 louis==3.17.0 lxml==4.6.2 Mako==1.1.4 Markdown==3.3.3 MarkupSafe==1.1.1 matplotlib==3.3.4 mccabe==0.6.1 meld==3.20.3 mercurial==5.7.1 meson==0.57.1 miniupnpc==2.1 mistune==0.8.4 more-itertools==8.6.0 msgpack==1.0.2 mypy==0.812 mypy-extensions==0.4.3 natsort==7.1.1 nbclient==0.5.1 nbconvert==6.0.7 nbformat==5.0.8 nbxmpp==1.0.2 nest-asyncio==1.4.3 netifaces==0.10.9 netsnmp-python==1.0a1 networkx==2.5 nltk==3.5 nose==1.3.7 notebook==6.2.0 Nuitka==0.6.12.3 numpy==1.20.1 openshot-qt==2.5.1 ordered-set==4.0.2 orjson @ file:///build/python-orjson/src/python-orjson-3.5.1/target/wheels/orjson-3.5.1-cp39-cp39-manylinux2010_x86_64.whl packaging==20.9 pandas==1.2.3 pandocfilters==1.4.3 paramiko==2.7.2 parso==0.7.1 passlib==1.7.4 path==15.1.2 pathspec==0.8.1 patiencediff==0.2.1 pbr==5.5.1 pdfarranger==1.7.0 pep517==0.9.1 pexpect==4.8.0 pickleshare==0.7.5 pikepdf==2.8.0.post2 Pillow==8.1.0 pluggy==0.13.1 ply==3.11 precis-i18n==1.0.3 progress==1.5 progressbar2==3.53.1 prometheus-client==0.9.0 prompt-toolkit==3.0.17 protobuf==3.12.4 psutil==5.8.0 psycopg2==2.8.6 ptyprocess==0.7.0 pudb==2020.1 pwquality==1.4.4 py==1.10.0 pyaml==20.4.0 pyasn1==0.4.8 pyasn1-modules==0.2.8 PyAudio==0.2.11 pybind11==2.6.2 pycairo==1.20.0 pycodestyle==2.6.0 pycountry==20.7.3 pycparser==2.20 pydocstyle==5.1.1 pyenchant==3.2.0 pyflakes==2.2.0 Pygments==2.8.1 PyGObject==3.38.0 PyHamcrest==1.9.0 pyinotify==0.9.6 pymediainfo==5.0.3 PyNaCl==1.4.0 PyOpenGL==3.1.5 pyOpenSSL==20.0.1 pyparsing==2.4.7 pyPEG2==2.15.2 PyQt5==5.15.4 PyQt5-sip==12.8.1 PyQtWebEngine==5.15.4 pyrsistent==0.17.3 PySocks==1.7.1 pytest==6.2.2 python-dateutil==2.8.1 python-dotenv==0.15.0 python-editor==1.0.4 python-Levenshtein==0.12.2 python-mimeparse==1.6.0 python-utils==2.5.6 python-xlib==0.29 pytoml==0.1.21 pytz==2021.1 pyxdg==0.26 PyYAML==5.3.1 pyzmq==20.0.0 questionary==1.9.0 qutebrowser==2.1.0 Reflector==2021.1.10.0.6.34 regex==2020.11.13 requests==2.25.1 requests-toolbelt==0.9.1 requirements-parser==0.2.0 resolvelib==0.5.4 retrying==1.3.3 s3cmd==2.1.0 schema==0.7.4 scikit-learn==0.24.1 scipy==1.6.1 scons==3.1.2 screenkey==1.4 SecretStorage==3.3.1 Send2Trash==1.5.0 service-identity==18.1.0 sh==1.14.1 shortuuid==1.0.1 simplejson==3.17.2 sip==4.19.25 six==1.15.0 snowballstemmer==2.1.0 soupsieve==2.2 speaklater==1.3 Sphinx==3.5.2 sphinx-rtd-theme==0.5.1 sphinxcontrib-applehelp==1.0.2 sphinxcontrib-devhelp==1.0.2 sphinxcontrib-htmlhelp==1.0.3 sphinxcontrib-jsmath==1.0.1 sphinxcontrib-qthelp==1.0.3 sphinxcontrib-serializinghtml==1.1.4 sqlacodegen==2.3.0 SQLAlchemy==1.3.23 sqlparse==0.4.1 sshtunnel==0.1.5 subdownloader==2.1.0 systemd-python==234 team==1.0 termcolor==1.1.0 terminado==0.9.2 terminator==2.1.0 testpath==0.4.4 testtools==2.4.0 texttable==1.6.3 threadpoolctl==2.1.0 tinycss2==1.1.0 tlsh==0.2.0 toml==0.10.2 tornado==6.1 traitlets==5.0.5 treq==21.1.0 Twisted==20.3.0 txaio==21.2.1 typed-ast==1.4.2 typing-extensions==3.7.4.3 tzlocal==2.1 urllib3==1.26.3 urwid==2.1.1 validate==5.1.0.dev0 virtualenv==20.4.2 waitress==1.4.4 wcwidth==0.2.5 webencodings==0.5.1 websocket-client==0.58.0 Werkzeug==1.0.1 Whoosh==2.7.4 widgetsnbextension==3.5.1 wsaccel==0.6.3 WTForms==2.2.1 xcffib==0.11.1 youtube-dl==2021.3.3 zipp==3.4.1 zope.interface==5.2.0
author Goffi <goffi@goffi.org>
date Sat, 20 Mar 2021 14:26:33 +0100
parents 3c9ba4a694ef
children 203755bbe0fe
line wrap: on
line source

# Cagou: desktop/mobile frontend for Salut à Toi XMPP client
# Copyright (C) 2016-2021 Jérôme Poisson (goffi@goffi.org)

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

#:import _ sat.core.i18n._
#:import C cagou.core.constants.Const
#:import G cagou.G
#:import escape kivy.utils.escape_markup
#:import SimpleXHTMLWidget cagou.core.simple_xhtml.SimpleXHTMLWidget
#:import DelayedBoxLayout cagou.core.common_widgets.DelayedBoxLayout
#:import ScrollEffect kivy.effects.scroll.ScrollEffect
#:import CategorySeparator cagou.core.common_widgets.CategorySeparator


# Chat


<BaseAttachmentItem>:
    size_hint: None, None
    size: self.minimum_width, dp(50)


<AttachmentItem>:
    canvas.before:
        Color:
            rgb: app.c_prim_dark
        Line:
            rounded_rectangle: self.x + dp(1), self.y + dp(1), self.width - dp(2), self.height - dp(2), 10
        Color:
            rgb: app.c_sec_light
        RoundedRectangle:
            pos: self.x + dp(1), self.y + dp(1)
            size: (self.width - dp(2)) * root.progress / 100, self.height - dp(2)
    SymbolButtonLabel:
        symbol: root.get_symbol(root.data)
        color: 0, 0, 0, 1
        text: root.data.get('name', _('unnamed'))
        bold: False
        on_press: root.on_press()


<AttachmentImageItem>:
    size: self.minimum_width, self.minimum_height
    image: image
    orientation: "vertical"
    SizedImage:
        id: image
        anim_delay: -1
        source: "data/images/image-loading.gif"


<AttachmentImagesCollectionItem>:
    cols: 2
    size_hint: None, None
    size: dp(150), dp(150)
    padding: dp(5)
    spacing: dp(2)
    canvas.before:
        Color:
            rgb: app.c_prim
        RoundedRectangle:
            radius: [dp(5)]
            pos: self.pos
            size: self.size
        Color:
            rgb: 0, 0, 0, 1
        Line:
            rounded_rectangle: self.x, self.y, self.width, self.height, dp(5)


<AttachmentsLayout>:
    attachments: self
    size_hint: 1, None
    height: self.minimum_height
    spacing: dp(5)


<MessAvatar>:
    size_hint: None, None
    size: dp(30), dp(30)
    canvas.before:
        Color:
            rgba: (0.87,0.87,0.87,1)
        RoundedRectangle:
            radius: [dp(5)]
            pos: self.pos
            size: self.size


<MessageWidget>:
    size_hint: 1, None
    avatar: avatar
    delivery: delivery
    mess_xhtml: mess_xhtml
    right_part: right_part
    header_box: header_box
    height: self.minimum_height
    BoxLayout:
        orientation: 'vertical'
        width: avatar.width
        size_hint: None, 1
        MessAvatar:
            id: avatar
            source: root.mess_data.avatar['path'] if root.mess_data and root.mess_data.avatar else app.default_avatar
            on_press: root.chat.addNick(root.nick)
        Widget:
            # use to push the avatar on the top
            size_hint: 1, 1
    BoxLayout:
        size_hint: 1, None
        orientation: 'vertical'
        id: right_part
        height: self.minimum_height
        BoxLayout:
            id: header_box
            size_hint: 1, None
            height: time_label.height if root.mess_type != C.MESS_TYPE_INFO else 0
            opacity: 1 if root.mess_type != C.MESS_TYPE_INFO else 0
            Label:
                id: time_label
                color: (0, 0, 0, 1) if root.own_mess else (0.55,0.55,0.55,1)
                font_size: root.font_size
                text_size: None, None
                size_hint: None, None
                size: self.texture_size
                padding: dp(5), 0
                markup: True
                valign: 'middle'
                text: u"[b]{}[/b], {}".format(escape(root.nick), root.time_text)
            Symbol:
                size_hint_x: None
                width: self.height
                id: encrypted
                symbol: 'lock-filled' if root.mess_data.encrypted else 'lock-open'
                font_size: self.height - dp(3)
                color: (1, 0, 0, 1) if not root.mess_data.encrypted and root.chat.encrypted else (0.55,0.55,0.55,1)
            Label:
                id: delivery
                color: C.COLOR_BTN_LIGHT
                font_size: root.font_size
                text_size: None, None
                size_hint: None, None
                size: self.texture_size
                padding: dp(5), 0
                # XXX: DejaVuSans font is needed as check mark is not in Roboto
                # this can be removed when Kivy will be able to handle fallback mechanism
                # which will allow us to use fonts with more unicode characters
                font_name: "DejaVuSans"
                text: u''
        SimpleXHTMLWidget:
            id: mess_xhtml
            size_hint: 1, None
            height: self.minimum_height
            xhtml: root.message_xhtml or self.escape(root.message or '')
            color: (0.74,0.74,0.24,1) if root.mess_type == "info" else (0, 0, 0, 1)
            padding: root.mess_padding
            bold: True if root.mess_type == "info" else False


<AttachmentToSendItem>:
    SymbolButton:
        opacity: 0 if root.sending else 1
        size_hint: None, 1
        symbol: "cancel-circled"
        on_press: root.parent.remove_widget(root)


<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
        text: _("attachments:")
        bold: True
    AttachmentsLayout:
        id: attachments_layout
    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
    message_input: message_input
    messages_widget: messages_widget
    history_scroll: history_scroll
    send_button_visible: G.local_platform.send_button_visible or bool(attachments_to_send.attachments.children)
    ScrollView:
        id: history_scroll
        scroll_y: 0
        on_scroll_y: root.onScroll(*args)
        do_scroll_x: False
        scroll_type: ['bars', 'content']
        bar_width: dp(10)
        effect_cls: ScrollEffect
        DelayedBoxLayout:
            id: messages_widget
            size_hint_y: None
            padding: [app.MARGIN_LEFT, 0, app.MARGIN_RIGHT, dp(10)]
            spacing: dp(10)
            height: self.minimum_height
            orientation: 'vertical'
    AttachmentsToSend:
        id: attachments_to_send
    MessageInputBox:
        size_hint: 1, None
        height: self.minimum_height
        spacing: dp(10)
        padding: [app.MARGIN_LEFT, 0, app.MARGIN_RIGHT, dp(10)]
        message_input: message_input
        MessageInputWidget:
            id: message_input
            size_hint: 1, None
            height: min(self.minimum_height, dp(250))
            multiline: True
            hint_text: _(u"Enter your message here")
            on_text_validate: root.onSend(args[0])
        SymbolButton:
            # "send" button, permanent visibility depends on platform
            symbol: "forward"
            size_hint: None, 1
            width: dp(30) if root.send_button_visible else 0
            opacity: 1 if root.send_button_visible else 0
            font_size: dp(25)
            on_release: self.parent.send_text()


# Buttons added in header

<TransferButton>:
    size_hint: None, 1
    symbol: "plus-circled"
    width: dp(30)
    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>:
    auto_width: False
    MenuButton:
        text: _("bookmarks")
        on_release: root.select("bookmark")
    MenuButton:
        text: _("close")
        on_release: root.select("close")

<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
    width: dp(30)
    color: self.getColor()
    symbol: self.getSymbol()

<TrustManagementButton>:
    symbol: "shield"
    padding: dp(5), dp(10)
    bg_color: app.c_prim_dark
    size_hint: None, 1
    width: dp(30)
    on_release: self.parent.dispatch("on_trust_release")

<EncryptionButton>:
    size_hint: None, None
    width: self.parent.parent.best_width if self.parent is not None else 30
    height: dp(30)
    on_best_width: self.parent.parent.best_width = max(self.parent.parent.best_width, args[1])
    Button:
        text: root.text
        size_hint: 1, 1
        padding: dp(5), dp(10)
        color: 0, 0, 0, 1
        bold: root.bold
        background_normal: app.expand('{media}/misc/borders/border_filled_black.png')
        background_color: app.c_sec if root.selected else app.c_prim_dark
        on_release: root.dispatch("on_release")
        on_texture_size: root.best_width = self.texture_size[0] + (dp(30) if root.trust_button else 0)

<EncryptionMenu>:
    size_hint_x: None
    width: self.container.minimum_width
    auto_width: False
    canvas.before:
        Color:
            rgba: 0, 0, 0, 1
        Rectangle:
            pos: self.pos
            size: self.size


# Chat Selector

<ChatSelector>:
    jid_selector: jid_selector
    JidSelector:
        id: jid_selector
        on_select: root.on_select(args[1])
        to_show: ["opened_chats", "roster", "bookmarks"]