Пример #1
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d

        # Classes
        conv_output_cls = extension.get_default('conversation output')
        smiley_chooser_cls = extension.get_default('smiley chooser')
        avatar_cls = extension.get_default('avatar')
        info_panel_cls = extension.get_default('info panel')
        conv_toolbar_cls = extension.get_default('conversation toolbar')

        # TOP LEFT
        widget_d['chat_output'] = conv_output_cls(self.session.config)
        top_left_lay = QtGui.QHBoxLayout()
        top_left_lay.addWidget(widget_d['chat_output'])

        # BOTTOM LEFT
        self.toolbar_handler = gui.base.ConversationToolbarHandler(
            self.session, gui.theme, self)
        widget_d['toolbar'] = conv_toolbar_cls(self.toolbar_handler,
                                               self.session)
        widget_d['toolbar'].redraw_ublock_button(
            self._get_first_contact().blocked)
        widget_d['toolbar'].update_toggle_avatar_icon(
            self.session.config.b_show_info)

        widget_d['smiley_chooser'] = smiley_chooser_cls()
        widget_d['chat_input'] = Widgets.ChatInput()

        text_edit_lay = QtGui.QHBoxLayout()
        text_edit_lay.addWidget(widget_d['chat_input'])

        bottom_left_lay = QtGui.QVBoxLayout()
        bottom_left_lay.addWidget(widget_d['toolbar'])
        bottom_left_lay.addLayout(text_edit_lay)

        widget_d['chat_input'].set_smiley_dict(gui.theme.emote_theme.emotes)

        widget_d['smiley_chooser'].emoticon_selected.connect(
            self._on_smiley_selected)
        widget_d['chat_input'].return_pressed.connect(
            self._on_send_btn_clicked)
        widget_d['chat_input'].style_changed.connect(
            self._on_new_style_selected)

        dialog = extension.get_default('dialog')

        # LEFT (TOP & BOTTOM)
        left_widget = QtGui.QSplitter(Qt.Vertical)
        splitter_up = QtGui.QWidget()
        splitter_down = QtGui.QWidget()
        splitter_up.setLayout(top_left_lay)
        splitter_down.setLayout(bottom_left_lay)
        left_widget.addWidget(splitter_up)
        left_widget.addWidget(splitter_down)

        left_widget.setCollapsible(0, False)
        left_widget.setCollapsible(1, False)
        _, splitter_pos = left_widget.getRange(1)
        left_widget.moveSplitter(splitter_pos, 1)

        # RIGHT
        widget_d['his_display_pic'] = avatar_cls(self.session)
        widget_d['my_display_pic'] = avatar_cls(self.session)

        right_lay = QtGui.QVBoxLayout()
        right_lay.addWidget(widget_d['his_display_pic'])
        right_lay.addStretch()
        right_lay.addWidget(widget_d['my_display_pic'])

        # LEFT & RIGHT
        widget_d['info_panel'] = info_panel_cls()

        lay_no_info = QtGui.QHBoxLayout()
        lay_no_info.addWidget(left_widget)
        lay_no_info.addLayout(right_lay)
        lay = QtGui.QVBoxLayout()
        lay.addWidget(widget_d['info_panel'])
        lay.addLayout(lay_no_info)

        self.setLayout(lay)
Пример #2
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d

        # Classes
        conv_output_cls = extension.get_default('conversation output')
        smiley_chooser_cls = extension.get_default('smiley chooser')
        info_panel_cls = extension.get_default('info panel')
        conv_toolbar_cls = extension.get_default('conversation toolbar')
        ContactInfo = extension.get_default('conversation info')

        # TOP LEFT
        self.output = conv_output_cls(self.session.config)
        top_left_lay = QtGui.QHBoxLayout()
        top_left_lay.setContentsMargins(0, 0, 0, 0)
        top_left_lay.addWidget(self.output)

        # BOTTOM LEFT
        self.toolbar_handler = gui.base.ConversationToolbarHandler(
            self.session, gui.theme, self)
        self.toolbar = conv_toolbar_cls(self.toolbar_handler, self.session)
        self.toolbar.redraw_ublock_button(self._get_first_contact().blocked)
        self.toolbar.update_toggle_avatar_icon(self.session.config.b_show_info)

        widget_d['smiley_chooser'] = smiley_chooser_cls()
        self.input = Widgets.ChatInput(self._on_send_message,
                                       self.cycle_history,
                                       self._send_typing_notification)

        self.bottom_left_lay = QtGui.QVBoxLayout()
        self.bottom_left_lay.setContentsMargins(0, 0, 0, 0)
        self.bottom_left_lay.addWidget(self.toolbar)
        self.bottom_left_lay.addWidget(self.input)
        if self.below_conversation:
            self.bottom_left_lay.addWidget(self.below_conversation)

        self.input.set_smiley_dict(gui.theme.emote_theme.emotes)
        widget_d['smiley_chooser'].emoticon_selected.connect(
            self._on_smiley_selected)
        self.input.style_changed.connect(self._on_new_style_selected)

        BelowConversation = extension.get_default('below conversation')
        if BelowConversation is not None:
            self.below_conversation = BelowConversation(self, self.session)

        # LEFT (TOP & BOTTOM)
        self.left_widget = QtGui.QSplitter(Qt.Vertical)
        splitter_up = QtGui.QWidget()
        splitter_down = QtGui.QWidget()
        splitter_up.setLayout(top_left_lay)
        splitter_down.setLayout(self.bottom_left_lay)
        self.left_widget.addWidget(splitter_up)
        self.left_widget.addWidget(splitter_down)
        self.left_widget.splitterMoved.connect(self.on_input_panel_resize)
        self.left_widget.setCollapsible(0, False)
        self.left_widget.setCollapsible(1, False)
        self.update_panel_position()

        # RIGHT
        self.info = ContactInfo(self.session, self.members)

        # LEFT & RIGHT
        self.header = info_panel_cls(self.session, self.members)

        self.lay_no_info = QtGui.QGridLayout()
        self.lay_no_info.addWidget(self.left_widget, 0, 1)
        self.lay_no_info.addWidget(self.info, 0, 2)
        lay = QtGui.QVBoxLayout()
        lay.setContentsMargins(1, 1, 1, 1)
        lay.addWidget(self.header)
        lay.addLayout(self.lay_no_info)

        self.setLayout(lay)
Пример #3
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d
        action_dict = self._action_dict

        # Classes
        conv_output_cls = extension.get_default('conversation output')
        smiley_chooser_cls = extension.get_default('smiley chooser')
        avatar_cls = extension.get_default('avatar')
        info_panel_cls = extension.get_default('info panel')

        # Actions
        icon_path = gui.theme.emote_theme.emote_to_path(':)')[6:]
        action_dict['add_smiley'] = QtGui.QAction(QtGui.QIcon(icon_path),
                                                  tr('Add Smiley'), self)
        icon_path = gui.theme.emote_theme.emote_to_path(':S')[6:]
        action_dict['send_nudge'] = QtGui.QAction(QtGui.QIcon(icon_path),
                                                  tr('Send Nudge'), self)
        action_dict['change_font'] = QtGui.QAction(
            QtGui.QIcon.fromTheme("preferences-desktop-font"),
            tr('Change Font'), self)
        action_dict['change_color'] = QtGui.QAction(QtGui.QIcon(""),
                                                    tr('Change Color'), self)
        action_dict['toggle_avatars'] = QtGui.QAction(
            QtGui.QIcon.fromTheme("go-next"), tr('Toggle Avatars'), self)

        # TOP LEFT
        widget_d['chat_output'] = conv_output_cls()
        top_left_lay = QtGui.QHBoxLayout()
        top_left_lay.addWidget(widget_d['chat_output'])

        # BOTTOM LEFT
        widget_d['toolbar'] = QtGui.QToolBar(self)
        widget_d['smiley_chooser'] = smiley_chooser_cls()
        widget_d['chat_input'] = Widgets.ChatInput()

        text_edit_lay = QtGui.QHBoxLayout()
        text_edit_lay.addWidget(widget_d['chat_input'])

        bottom_left_lay = QtGui.QVBoxLayout()
        bottom_left_lay.addWidget(widget_d['toolbar'])
        bottom_left_lay.addLayout(text_edit_lay)

        toolbar = widget_d['toolbar']
        toolbar.setToolButtonStyle(Qt.ToolButtonIconOnly)
        toolbar.addAction(action_dict['change_font'])
        toolbar.addAction(action_dict['change_color'])
        toolbar.addSeparator()
        toolbar.addAction(action_dict['add_smiley'])
        toolbar.addAction(action_dict['send_nudge'])
        toolbar.addSeparator()
        toolbar.addAction(action_dict['toggle_avatars'])

        widget_d['chat_input'].set_smiley_dict(gui.theme.emote_theme.emotes)

        widget_d['smiley_chooser'].emoticon_selected.connect(
            self._on_smiley_selected)
        widget_d['chat_input'].return_pressed.connect(
            self._on_send_btn_clicked)
        widget_d['chat_input'].style_changed.connect(
            self._on_new_style_selected)

        dialog = extension.get_default('dialog')
        self.toolbar_handler = gui.base.ConversationToolbarHandler(
            self._session, dialog, gui.theme, self)
        action_dict['add_smiley'].triggered.connect(
            self._on_show_smiley_chooser)
        action_dict['send_nudge'].triggered.connect(
            self.toolbar_handler.on_notify_attention_selected)
        action_dict['change_font'].triggered.connect(
            widget_d['chat_input'].show_font_chooser)
        action_dict['change_color'].triggered.connect(
            widget_d['chat_input'].show_color_chooser)
        action_dict['toggle_avatars'].triggered.connect(
            self.toolbar_handler.on_toggle_avatar_selected)

        # LEFT (TOP & BOTTOM)
        left_widget = QtGui.QSplitter(Qt.Vertical)
        splitter_up = QtGui.QWidget()
        splitter_down = QtGui.QWidget()
        splitter_up.setLayout(top_left_lay)
        splitter_down.setLayout(bottom_left_lay)
        left_widget.addWidget(splitter_up)
        left_widget.addWidget(splitter_down)

        left_widget.setCollapsible(0, False)
        left_widget.setCollapsible(1, False)
        _, splitter_pos = left_widget.getRange(1)
        left_widget.moveSplitter(splitter_pos, 1)

        # RIGHT
        widget_d['his_display_pic'] = avatar_cls(self._session)
        widget_d['my_display_pic'] = avatar_cls(self._session)

        right_lay = QtGui.QVBoxLayout()
        right_lay.addWidget(widget_d['his_display_pic'])
        right_lay.addStretch()
        right_lay.addWidget(widget_d['my_display_pic'])

        widget_d['my_display_pic'].set_display_pic_of_account()
        if self._members:
            his_email = self._members[0]
            widget_d['his_display_pic'].set_display_pic_of_account(his_email)

        # LEFT & RIGHT
        widget_d['info_panel'] = info_panel_cls()

        lay_no_info = QtGui.QHBoxLayout()
        lay_no_info.addWidget(left_widget)
        lay_no_info.addLayout(right_lay)
        lay = QtGui.QVBoxLayout()
        lay.addWidget(widget_d['info_panel'])
        lay.addLayout(lay_no_info)

        self.setLayout(lay)