view src/cagou/kv/profile_manager.kv @ 38:9f45098289cc

widgets handler, core: hidden widgets can now be shown with swipes: - a couple of methods have been added to handle visible and hidden widgets - a new getOrClone method allow to recreate a widget if it already has a parent (can happen even if the widget is not shown, e.g. in a carousel) - handler now display hidden widgets of the same class as the displayed one when swiping. For instance, if a chat widget is displayed, and header input is used to show an other one, it's now possible to go back to the former by swiping. QuickWidget.onDelete method can be used to handle if a widget must be really deleted (return True) or just hidden (any other value). - handler use a subclass of Carousel for this new feature, with some adjustement so event can be passed to children without too much delay (and frustration). This may need to be adjusted again in the future. - handler.cagou_widget now give the main displayed widget in the handler - handler.changeWidget must be used when widget need to be changed (it's better to use host.switchWidget which will call it itself)
author Goffi <goffi@goffi.org>
date Sun, 28 Aug 2016 15:27:48 +0200
parents 56838ad5c84b
children 1922506846be
line wrap: on
line source

# Cagou: desktop/mobile frontend for Salut à Toi XMPP client
# Copyright (C) 2016 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/>.


<ProfileManager>:
    Label:
        text: "Profile Manager"
        size_hint: 1,0.05

<PMLabel@Label>:
    size_hint: 1, 0.1

<PMInput@TextInput>:
    multiline: False
    size_hint: 1, 0.1
    write_tab: False

<PMButton@Button>:
    size_hint: 1, 0.2


<NewProfileScreen>:
    profile_name: profile_name
    jid: jid
    password: password

    BoxLayout:
        orientation: "vertical"

        Label:
            text: "Creation of a new profile"
            bold: True
            size_hint: 1, 0.1
        Label:
            text: root.error_msg
            bold: True
            size_hint: 1, 0.1
            color: 1,0,0,1
        GridLayout:
            cols: 2

            PMLabel:
                text: "Profile name"
            PMInput:
                id: profile_name

            PMLabel:
                text: "JID"
            PMInput:
                id: jid

            PMLabel:
                text: "Password"
            PMInput:
                id: password
                password: True

            Widget:
                size_hint: 1, 0.2

            Widget:
                size_hint: 1, 0.2

            PMButton:
                text: "OK"
                on_press: root.doCreate()

            PMButton:
                text: "Cancel"
                on_press:
                    root.pm.screen_manager.transition.direction = 'right'
                    root.pm.screen_manager.current = 'profiles'

            Widget:


<DeleteProfilesScreen>:
    BoxLayout:
        orientation: "vertical"

        Label:
            text: "Are you sure you want to delete the following profiles?"
            size_hint: 1, 0.1

        Label:
            text: u'\n'.join([i.text for i in root.pm.profiles_screen.list_adapter.selection])
            bold: True

        Label:
            text: u'/!\\ WARNING: this operation is irreversible'
            color: 1,0,0,1
            bold: True
            size_hint: 1, 0.2

        GridLayout:
            cols: 2

            Button:
                text: "Delete"
                size_hint: 1, 0.2
                on_press: root.doDelete()

            Button:
                text: "Cancel"
                size_hint: 1, 0.2
                on_press:
                    root.pm.screen_manager.transition.direction = 'right'
                    root.pm.screen_manager.current = 'profiles'

            Widget:


<ProfilesScreen>:
    layout: layout
    BoxLayout:
        id: layout
        orientation: 'vertical'

        Label:
            text: "Select a profile to connect with, or create a new one"
            size_hint: 1,0.05

        GridLayout:
            cols: 2
            size_hint: 1, 0.1
            Button:
                size_hint: 1, 0.1
                text: "New"
                on_press:
                    root.pm.screen_manager.transition.direction = 'left'
                    root.pm.screen_manager.current = 'new_profile'
            Button:
                disabled: not root.list_adapter.selection
                text: "Delete"
                size_hint: 1, 0.1
                on_press:
                    root.pm.screen_manager.transition.direction = 'left'
                    root.pm.screen_manager.current = 'delete_profiles'


<ConnectButton>:
    text: "Connect"
    size_hint: 1, 0.1
    disabled: not self.profile_screen.list_adapter.selection
    on_press: self.pm._onConnectProfiles()


<ProfileItem>:
    # FIXME: using cagou/images path for now, will use atlas later
    background_normal: "cagou/images/button_selected.png" if self.is_selected else "cagou/images/button.png"
    deselected_color: 1,1,1,1
    selected_color: 1,1,1,1
    color: 0,0,0,1