示例#1
0
    def __init__(self, session):
        """constructor
        """
        BaseTable.__init__(self, 3, 2)
        self._session = session

        self.append_markup("<b>" + tr("File transfers") + "</b>")
        self.append_check(tr("Sort received files by sender"), "_session.config.b_download_folder_per_account")
        self.add_text(tr("Save files to:"), 0, 2, True)

        def on_path_button_clicked():
            """ updates the download dir config value """
            new_path = unicode(QtGui.QFileDialog.getExistingDirectory(directory=self._session.config.download_folder))
            set_new_path(new_path)
            path_edit.setText(new_path)

        def set_new_path(new_path):
            if new_path != self._session.config.download_folder:
                self._session.config.download_folder = new_path

        path_edit = QtGui.QLineEdit(self._session.config.get_or_set("download_folder", e3.common.locations.downloads()))
        path = QtGui.QWidget()
        path_button = QtGui.QPushButton(QtGui.QIcon.fromTheme("folder"), "")
        path_lay = QtGui.QHBoxLayout()
        path_lay.addWidget(path_edit)
        path_lay.addWidget(path_button)
        path.setLayout(path_lay)
        self.attach(path, 2, 3, 2, 3)

        path_button.clicked.connect(on_path_button_clicked)
        path_edit.textChanged.connect(lambda new_path: set_new_path(unicode(new_path)))
        self.show_all()
示例#2
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d
        widget_d['filter_edit'] = QtGui.QLineEdit()
        widget_d['msg_level_combo'] = QtGui.QComboBox()
        widget_d['filter_btn'] = QtGui.QPushButton(tr('Filter'))
        hlay = QtGui.QHBoxLayout()
        hlay.addWidget(widget_d['filter_edit'])
        hlay.addWidget(widget_d['msg_level_combo'])
        hlay.addWidget(widget_d['filter_btn'])

        widget_d['text_view'] = DebugTextView()
        lay = QtGui.QVBoxLayout()
        lay.addLayout(hlay)
        lay.addWidget(widget_d['text_view'])
        self.setLayout(lay)

        combo = widget_d['msg_level_combo']
        combo.addItem('Debug', logging.DEBUG)
        combo.addItem('Info', logging.INFO)
        combo.addItem('Warning', logging.WARNING)
        combo.addItem('Error', logging.ERROR)
        combo.addItem('Critical', logging.CRITICAL)
        self.setWindowTitle(tr('Debug'))
        self.resize(800, 600)

        combo.currentIndexChanged.connect(
                    lambda *args: self._on_filter_changed())
        widget_d['filter_btn'].clicked.connect(
                    lambda *args: self._on_filter_changed())
        widget_d['filter_edit'].returnPressed.connect(
                    lambda *args: self._on_filter_changed())
示例#3
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d
        widget_d['filter_edit'] = QtGui.QLineEdit()
        widget_d['msg_level_combo'] = QtGui.QComboBox()
        widget_d['filter_btn'] = QtGui.QPushButton(tr('Filter'))
        hlay = QtGui.QHBoxLayout()
        hlay.addWidget(widget_d['filter_edit'])
        hlay.addWidget(widget_d['msg_level_combo'])
        hlay.addWidget(widget_d['filter_btn'])

        widget_d['text_view'] = DebugTextView()
        lay = QtGui.QVBoxLayout()
        lay.addLayout(hlay)
        lay.addWidget(widget_d['text_view'])
        self.setLayout(lay)

        combo = widget_d['msg_level_combo']
        combo.addItem('Debug', logging.DEBUG)
        combo.addItem('Info', logging.INFO)
        combo.addItem('Warning', logging.WARNING)
        combo.addItem('Error', logging.ERROR)
        combo.addItem('Critical', logging.CRITICAL)
        self.setWindowTitle(tr('Debug'))
        self.resize(800, 600)

        combo.currentIndexChanged.connect(
            lambda *args: self._on_filter_changed())
        widget_d['filter_btn'].clicked.connect(
            lambda *args: self._on_filter_changed())
        widget_d['filter_edit'].returnPressed.connect(
            lambda *args: self._on_filter_changed())
示例#4
0
    def __init__(self, handler, parent=None):
        '''
        constructor

        handler -- e3common.Handler.HelpHandler
        '''
        QtGui.QMenu.__init__(self, tr('Help'), parent)
        self.handler = handler

        self.website = QtGui.QAction(tr('Website'), self)
        self.about = QtGui.QAction(ICON('help-about'), tr('About'), self)
        self.debug = QtGui.QAction(tr('Debug'), self)
        self.updatecheck = QtGui.QAction(tr('Check for updates'), self)

        self.addAction(self.website)
        self.addAction(self.about)
        self.addAction(self.debug)
        self.addSeparator()
        self.addAction(self.updatecheck)

        self.website.triggered.connect(
            lambda *args: self.handler.on_website_selected())
        self.about.triggered.connect(
            lambda *args: self.handler.on_about_selected())
        self.debug.triggered.connect(
            lambda *args: self.handler.on_debug_selected())
        self.updatecheck.triggered.connect(
            lambda *args: self.handler.on_check_update_selected())
示例#5
0
    def __init__(self, handler, parent=None):
        '''Constructor'''
        QtGui.QMenu.__init__(self, 'emesene2', parent)

        self._handler = handler

        status_menu_cls = extension.get_default('menu status')

        self.hide_show_mainwindow = QtGui.QAction(tr('Hide/Show emesene'),
                                                  self)
        self.status_menu = status_menu_cls(handler.on_status_selected)
        #self.list_contacts_menu = ContactsMenu(handler, main_window)
        self.disconnect = QtGui.QAction(ICON('network-disconnect'),
                                        tr('Disconnect'), self)
        self.quit = QtGui.QAction(ICON('application-exit'), tr('Quit'), self)

        self.addAction(self.hide_show_mainwindow)
        self.addMenu(self.status_menu)
        #self.addMenu(self.list_contacts_menu)
        self.addAction(self.disconnect)
        self.addSeparator()
        self.addAction(self.quit)

        self.disconnect.triggered.connect(
            lambda *args: self._handler.on_disconnect_selected())
        self.quit.triggered.connect(
            lambda *args: self._handler.on_quit_selected())
示例#6
0
    def __init__(self, handler, parent=None):
        '''Constructor'''
        QtGui.QMenu.__init__(self, 'emesene2', parent)
        
        self._handler = handler

        status_menu_cls = extension.get_default('menu status')
        
        self.hide_show_mainwindow = QtGui.QAction(tr('Hide/Show emesene'), self)
        self.status_menu = status_menu_cls(handler.on_status_selected)
        #self.list_contacts_menu = ContactsMenu(handler, main_window)
        self.disconnect = QtGui.QAction(ICON('network-disconnect'),
                                        tr('Disconnect'), self)
        self.quit = QtGui.QAction(ICON('application-exit'),
                                 tr('Quit'), self)
        

        self.addAction(self.hide_show_mainwindow)
        self.addMenu(self.status_menu)
        #self.addMenu(self.list_contacts_menu)        
        self.addAction(self.disconnect)
        self.addSeparator()
        self.addAction(self.quit)
        
        self.disconnect.triggered.connect(
            lambda *args: self._handler.on_disconnect_selected())
        self.quit.triggered.connect(
            lambda *args: self._handler.on_quit_selected())
示例#7
0
    def __init__(self, session, members, parent=None):
        '''Constructor'''
        QtGui.QWidget.__init__(self, parent)

        self.session = session
        self.members = members
        self._message_lbl = QtGui.QLabel()

        lay = QtGui.QHBoxLayout()
        lay.setContentsMargins(0, 0, 0, 0)
        lay.addWidget(self._message_lbl)
        self.setLayout(lay)
        self._message_lbl.setTextFormat(Qt.RichText)
        # set context menu policy
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.showContextMenu)

        self._action_d = {}
        action_d = self._action_d
        self.menu = QtGui.QMenu(tr('Copy contact information'), self)

        action_d['nick_clipboard'] = QtGui.QAction(tr('Nickname'), self)
        action_d['nick_clipboard'].triggered.connect(
            self.on_copy_nick_to_clipboard)
        self.menu.addAction(action_d['nick_clipboard'])
        action_d['message_clipboard'] = QtGui.QAction(tr('Personal message'),
                                                      self)
        action_d['message_clipboard'].triggered.connect(
            self.on_copy_message_to_clipboard)
        self.menu.addAction(action_d['message_clipboard'])
        action_d['account_clipboard'] = QtGui.QAction(tr('Email address'),
                                                      self)
        action_d['account_clipboard'].triggered.connect(
            self.on_copy_account_to_clipboard)
        self.menu.addAction(action_d['account_clipboard'])
示例#8
0
    def __init__(self, handler, parent=None):
        """
        constructor

        handler -- a e3common.Handler.GroupHandler
        """
        QtGui.QMenu.__init__(self, tr('Group'), parent)
        self._handler = handler

        self.add    = QtGui.QAction(ICON('list-add'),      tr('Add')+'...',    self)
        self.remove = QtGui.QAction(ICON('list-remove'),   tr('Remove'), self)
        self.rename = QtGui.QAction(ICON('document-edit'), tr('Rename')+'...', self)
        
        self.addAction(self.add)
        self.addAction(self.remove)
        self.addAction(self.rename)
        
        self.setIcon(QtGui.QIcon(gui.theme.users))

        self.add.triggered.connect(
            lambda *args: self._handler.on_add_group_selected())
        self.remove.triggered.connect(
            lambda *args: self._handler.on_remove_group_selected())
        self.rename.triggered.connect(
            lambda *args: self._handler.on_rename_group_selected())
示例#9
0
    def __init__(self, session, parent=None):
        '''Constructor, response_cb receive the response number, the new file
        selected and a list of the paths on the icon view.
        picture_path is the path of the current display picture'''
        Dialog.OkCancelDialog.__init__(self,
                                       tr('Avatar chooser'),
                                       expanding=True,
                                       parent=parent)
        self._session = session
        self._avatar_manager = gui.base.AvatarManager(session)
        # view names:
        self._vn = [
            tr('Used pictures'),
            tr('System pictures'),
            tr('Contact pictures')
        ]
        self._view_with_selection = None
        self._current_avatar = session.config_dir.get_path('last_avatar')
        self._widget_d = {}

        self._setup_ui()
        # update buttons
        self._on_tab_changed(0)
        used_path = self._avatar_manager.get_avatars_dir()
        system_paths = self._avatar_manager.get_system_avatars_dirs()
        cached_paths = self._avatar_manager.get_cached_avatars_dir()

        self._populate_list(self._vn[0], used_path)
        for path in system_paths:
            self._populate_list(self._vn[1], path)
        for path in cached_paths:
            self._populate_list(self._vn[2], path)
示例#10
0
    def __init__(self, handler, parent=None):
        """
        constructor

        handler -- a e3common.Handler.GroupHandler
        """
        QtGui.QMenu.__init__(self, tr('Group'), parent)
        self._handler = handler

        self.add = QtGui.QAction(ICON('list-add'), tr('Add') + '...', self)
        self.remove = QtGui.QAction(ICON('list-remove'), tr('Remove'), self)
        self.rename = QtGui.QAction(ICON('document-edit'),
                                    tr('Rename') + '...', self)

        self.addAction(self.add)
        self.addAction(self.remove)
        self.addAction(self.rename)

        self.setIcon(QtGui.QIcon(gui.theme.image_theme.users))

        self.add.triggered.connect(
            lambda *args: self._handler.on_add_group_selected())
        self.remove.triggered.connect(
            lambda *args: self._handler.on_remove_group_selected())
        self.rename.triggered.connect(
            lambda *args: self._handler.on_rename_group_selected())
示例#11
0
 def __init__(self, session, parent=None):
     '''Constructor, response_cb receive the response number, the new file
     selected and a list of the paths on the icon view.
     picture_path is the path of the current display picture'''
     Dialog.OkCancelDialog.__init__(self, tr('Avatar chooser'), 
                                    expanding=True, parent=parent)
     self._session = session
     self._avatar_manager = gui.base.AvatarManager(session)
     # view names:
     self._vn = [ tr('Used pictures'   ), 
                  tr('System pictures' ), 
                  tr('Contact pictures')  ]
     self._view_with_selection = None
     self._current_avatar = session.config_dir.get_path('last_avatar')
     self._widget_d = {}
     
     self._setup_ui()
     # update buttons
     self._on_tab_changed(0)
     used_path = self._avatar_manager.get_avatars_dir()
     system_paths = self._avatar_manager.get_system_avatars_dirs()
     cached_paths = self._avatar_manager.get_cached_avatars_dir()
     
     self._populate_list(self._vn[0], used_path)
     for path in system_paths:
         self._populate_list(self._vn[1], path)
     for path in cached_paths:
         self._populate_list(self._vn[2], path)
示例#12
0
    def _search_item(self, uid, parent):
        # TODO: refactor
        """Searches na item, given its uid"""
        if parent == self:
            item_locator = parent.item
        else:
            item_locator = parent.child

        num_rows = parent.rowCount()
        for i in range(num_rows):
            found_item = item_locator(i, 0)
            found_uid = found_item.data(Role.UidRole).toString()
            if found_uid == QtCore.QString(str(uid)).trimmed():
                return found_item
        if uid in [self.NO_GRP_UID, self.ONL_GRP_UID, self.OFF_GRP_UID]:
            group_name = {
                self.NO_GRP_UID: tr(u"No Group"),
                self.OFF_GRP_UID: tr(u"Offline"),
                self.ONL_GRP_UID: tr(u"Online"),
            }
            new_group_item = QtGui.QStandardItem(group_name[uid])
            new_group_item.setData(uid, Role.UidRole)
            new_group_item.setData(0, Role.TotalCountRole)
            new_group_item.setData(0, Role.OnlCountRole)
            self.appendRow(new_group_item)
            return new_group_item
示例#13
0
    def add_group(cls, response_cb, title=tr('Add group')):
        '''show a dialog asking for a group name, the response callback
        receives the response (stock.ADD, stock.CANCEL, stock.CLOSE)
        and the name of the group, the control for a valid group is made
        on the controller, so if the group is empty you just call the
        callback, to make a unified behaviour, and also, to only implement
        GUI logic on your code and not client logic
        cb args: response, group_name'''
        log.debug(str(response_cb))
        dialog = OkCancelDialog(title)
        group_label = QtGui.QLabel(tr('New group\'s name:'))
        group_edit  = QtGui.QLineEdit()

        lay = QtGui.QHBoxLayout()
        lay.addWidget(group_label)
        lay.addWidget(group_edit)
        dialog.setLayout(lay)

        dialog.setWindowTitle(title)
        dialog.setMinimumWidth(380)

        response = dialog.exec_()

        group_name = unicode(group_edit.text())

        response_cb(response, group_name)
示例#14
0
 def update_toggle_avatar_icon(self, show_avatars):
     if show_avatars:
         self._action_dict['toggle_avatars'].setIcon(self.theme_tool_hide_avatar)
         self._action_dict['toggle_avatars'].setToolTip(tr('Hide avatar'))
     else:
         self._action_dict['toggle_avatars'].setIcon(self.theme_tool_show_avatar)
         self._action_dict['toggle_avatars'].setToolTip(tr('Show avatar'))
示例#15
0
    def __init__(self, session):
        """constructor
        """
        BaseTable.__init__(self, 7, 1)
        self.session = session
        self.array = []
        self.append_markup('<b>'+tr('General:')+'</b>')
        self.mute_sound = self.append_check(_('Mute sounds'),
            'session.config.b_mute_sounds')
        self.append_markup('<b>'+tr('Users events:')+'</b>')
        self.array.append(self.append_check(tr('Play sound on contact online'),
            'session.config.b_play_contact_online'))
        self.array.append(self.append_check(tr('Play sound on contact offline'),
            'session.config.b_play_contact_offline'))
        self.append_markup('<b>'+tr('Messages events:')+'</b>')
        self.array.append(self.append_check(tr('Play sound on sent message'),
            'session.config.b_play_send'))
        self.array.append(self.append_check(tr('Play sound on first received message'),
            'session.config.b_play_first_send'))
        self.array.append(self.append_check(tr('Play sound on received message'),
            'session.config.b_play_type'))
        self.array.append(self.append_check(tr('Play sound on nudge'),
            'session.config.b_play_nudge'))
        self.array.append(self.append_check(tr('Mute sounds when the conversation has focus'),
            'session.config.b_mute_sounds_when_focussed'))

        self._on_mute_sounds_changed(self.session.config.b_mute_sounds)

        self.session.config.subscribe(self._on_mute_sounds_changed,
            'b_mute_sounds')

        self.show_all()
示例#16
0
    def __init__(self, handler, parent=None):
        '''
        constructor

        handler -- e3common.Handler.HelpHandler
        '''
        QtGui.QMenu.__init__(self, tr('Help'), parent)
        self.handler = handler

        self.website = QtGui.QAction(tr('Website'), self)
        self.about = QtGui.QAction(tr('About'), self)
        self.debug = QtGui.QAction(tr('Debug'), self)
        self.updatecheck = QtGui.QAction(tr('Check for updates'), self)

        self.addAction(self.website)
        self.addAction(self.about)
        self.addAction(self.debug)
        self.addSeparator()
        self.addAction(self.updatecheck)

        self.website.triggered.connect(
            lambda *args: self.handler.on_website_selected())
        self.about.triggered.connect(
            lambda *args: self.handler.on_about_selected())
        self.debug.triggered.connect(
            lambda *args: self.handler.on_debug_selected())
        self.updatecheck.triggered.connect(
            lambda *args: self.handler.on_check_update_selected())
示例#17
0
    def _search_item(self, uid, parent):
        # TODO: refactor
        '''Searches na item, given its uid'''
        if parent == self:
            item_locator = parent.item
        else:
            item_locator = parent.child

        num_rows = parent.rowCount()
        for i in range(num_rows):
            found_item = item_locator(i, 0)
            found_uid = found_item.data(Role.UidRole).toString()
            if found_uid == QtCore.QString(str(uid)).trimmed():
                return found_item
        if uid in [self.NO_GRP_UID, self.ONL_GRP_UID, self.OFF_GRP_UID]:
            if uid == self.NO_GRP_UID:
                group = e3.Group(tr("No group"), identifier='0', type_ = e3.Group.NONE)
            elif uid == self.ONL_GRP_UID:
                group = e3.Group(tr("Online"), identifier='0', type_=e3.Group.ONLINE)
            elif uid == self.OFF_GRP_UID:
                group = e3.Group(tr("Offline"), identifier='1', type_=e3.Group.OFFLINE)
            new_group_item = QtGui.QStandardItem(group.name)
            new_group_item.setData(uid, Role.UidRole)
            new_group_item.setData(0, Role.TotalCountRole)
            new_group_item.setData(0, Role.OnlCountRole)
            new_group_item.setData(group, Role.DataRole)
            self.appendRow(new_group_item)
            return new_group_item
示例#18
0
    def __init__(self, session, members, parent=None):
        '''Constructor'''
        QtGui.QWidget.__init__(self, parent)

        self.session = session
        self.members = members
        self._message_lbl = QtGui.QLabel()

        lay = QtGui.QHBoxLayout()
        lay.setContentsMargins(0, 0, 0, 0)
        lay.addWidget(self._message_lbl)
        self.setLayout(lay)
        self._message_lbl.setTextFormat(Qt.RichText)
        # set context menu policy
        self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
        self.customContextMenuRequested.connect(self.showContextMenu)

        self._action_d = {}
        action_d = self._action_d
        self.menu = QtGui.QMenu(tr('Copy contact information'), self)

        action_d['nick_clipboard'] = QtGui.QAction(tr('Nickname'), self)
        action_d['nick_clipboard'].triggered.connect(
            self.on_copy_nick_to_clipboard)
        self.menu.addAction(action_d['nick_clipboard'])
        action_d['message_clipboard'] = QtGui.QAction(tr('Personal message'), self)
        action_d['message_clipboard'].triggered.connect(
            self.on_copy_message_to_clipboard)
        self.menu.addAction(action_d['message_clipboard'])
        action_d['account_clipboard'] = QtGui.QAction(tr('Email address'), self)
        action_d['account_clipboard'].triggered.connect(
            self.on_copy_account_to_clipboard)
        self.menu.addAction(action_d['account_clipboard'])
示例#19
0
    def add_group(cls, response_cb, title=tr('Add group')):
        '''show a dialog asking for a group name, the response callback
        receives the response (stock.ADD, stock.CANCEL, stock.CLOSE)
        and the name of the group, the control for a valid group is made
        on the controller, so if the group is empty you just call the
        callback, to make a unified behaviour, and also, to only implement
        GUI logic on your code and not client logic
        cb args: response, group_name'''
        log.debug(str(response_cb))
        dialog = OkCancelDialog(title)
        group_label = QtGui.QLabel(tr('New group\'s name:'))
        group_edit = QtGui.QLineEdit()

        lay = QtGui.QHBoxLayout()
        lay.addWidget(group_label)
        lay.addWidget(group_edit)
        dialog.setLayout(lay)

        dialog.setWindowTitle(title)
        dialog.setMinimumWidth(380)

        response = dialog.exec_()

        group_name = unicode(group_edit.text())

        response_cb(response, group_name)
示例#20
0
    def _search_item(self, uid, parent):
        # TODO: refactor
        '''Searches na item, given its uid'''
        if parent == self:
            item_locator = parent.item
        else:
            item_locator = parent.child

        num_rows = parent.rowCount()
        for i in range(num_rows):
            found_item = item_locator(i, 0)
            found_uid = found_item.data(Role.UidRole).toString()
            if found_uid == QtCore.QString(str(uid)).trimmed():
                return found_item
        if uid in [self.NO_GRP_UID, self.ONL_GRP_UID, self.OFF_GRP_UID]:
            group_name = {
                self.NO_GRP_UID: tr(u'No Group'),
                self.OFF_GRP_UID: tr(u'Offline'),
                self.ONL_GRP_UID: tr(u'Online')
            }
            new_group_item = QtGui.QStandardItem(group_name[uid])
            new_group_item.setData(uid, Role.UidRole)
            new_group_item.setData(0, Role.TotalCountRole)
            new_group_item.setData(0, Role.OnlCountRole)
            self.appendRow(new_group_item)
            return new_group_item
示例#21
0
    def _search_item(self, uid, parent):
        '''Searches na item, given its uid'''
        if parent == self:
            item_locator = parent.item
        else:
            item_locator = parent.child

        num_rows = parent.rowCount()
        for i in range(num_rows):
            found_item = item_locator(i, 0)
            found_uid = found_item.data(Role.UidRole).toString()
            if found_uid == QtCore.QString(str(uid)).trimmed():
                return found_item

        if uid in [self.NO_GRP_UID, self.ONL_GRP_UID, self.OFF_GRP_UID]:
            if uid == self.NO_GRP_UID:
                group = e3.Group(tr("No group"),
                                 identifier=uid,
                                 type_=e3.Group.NONE)
            elif uid == self.ONL_GRP_UID:
                group = e3.Group(tr("Online"),
                                 identifier=uid,
                                 type_=e3.Group.ONLINE)
                group.type = e3.Group.ONLINE
            elif uid == self.OFF_GRP_UID:
                group = e3.Group(tr("Offline"),
                                 identifier=uid,
                                 type_=e3.Group.OFFLINE)
            new_group_item = self.add_group(group, force=True)
            return new_group_item
示例#22
0
    def edit_profile(cls, handler, user_nick, user_message, last_avatar):

        dialog = OkCancelDialog(unicode(tr('Change profile')))
        dialog.setWindowTitle(tr('Change profile'))

        hbox = QtGui.QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)

        Avatar = extension.get_default('avatar')
        avatar = Avatar(handler.session, size=96)
        avatar.set_from_file(last_avatar)
        if handler.session.session_has_service(
                e3.Session.SERVICE_PROFILE_PICTURE):
            avatar.clicked.connect(
                lambda *args: handler.on_set_picture_selected(handler.session))
            avatar.setToolTip(tr('Click here to set your avatar'))

            def on_picture_change_succeed(self, account, path):
                '''callback called when the picture of an account is changed'''
                # our account
                if account == handler.session.account.account:
                    avatar.set_from_file(path)

            handler.session.signals.picture_change_succeed.subscribe(
                on_picture_change_succeed)

        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)

        hbox.addWidget(avatar)
        hbox.addLayout(vbox)
        dialog.setLayout(hbox)

        nick_label = QtGui.QLabel(unicode(tr('Nick:')))

        nick = QtGui.QLineEdit()
        nick.setText(unicode(user_nick))

        pm_label = QtGui.QLabel(unicode(tr('Message:')))

        pm = QtGui.QLineEdit()
        pm.setText(unicode(user_message))

        vbox.addWidget(nick_label)
        vbox.addWidget(nick)
        vbox.addWidget(pm_label)
        vbox.addWidget(pm)

        def save_profile():
            '''save the new profile'''
            new_nick = nick.text()
            new_pm = pm.text()
            handler.save_profile(new_nick, new_pm)

        dialog.accept_response = save_profile

        dialog.show()
        dialog.exec_()
        dialog.hide()
示例#23
0
 def __init__(self, session):
     """constructor
     """
     BaseTable.__init__(self, 2, 1)
     self.session = session
     self.append_check(tr("Notify on contact online"), "session.config.b_notify_contact_online")
     self.append_check(tr("Notify on contact offline"), "session.config.b_notify_contact_offline")
     self.append_check(tr("Notify on received message"), "session.config.b_notify_receive_message")
示例#24
0
    def edit_profile(cls, handler, user_nick, user_message, last_avatar):

        dialog = OkCancelDialog(unicode(tr('Change profile')))
        dialog.setWindowTitle(tr('Change profile'))

        hbox = QtGui.QHBoxLayout()
        hbox.setContentsMargins(0, 0, 0, 0)

        Avatar = extension.get_default('avatar')
        avatar = Avatar(handler.session, size=96)
        avatar.set_from_file(last_avatar)
        if handler.session.session_has_service(e3.Session.SERVICE_PROFILE_PICTURE):
            avatar.clicked.connect(lambda *args: handler.on_set_picture_selected(handler.session))
            avatar.setToolTip(tr('Click here to set your avatar'))

            def on_picture_change_succeed(self, account, path):
                '''callback called when the picture of an account is changed'''
                # our account
                if account == handler.session.account.account:
                    avatar.set_from_file(path)
            handler.session.signals.picture_change_succeed.subscribe(
                on_picture_change_succeed)

        vbox = QtGui.QVBoxLayout()
        vbox.setContentsMargins(0, 0, 0, 0)

        hbox.addWidget(avatar)
        hbox.addLayout(vbox)
        dialog.setLayout(hbox)

        nick_label = QtGui.QLabel(unicode(tr('Nick:')))

        nick = QtGui.QLineEdit()
        nick.setText(user_nick)

        pm_label = QtGui.QLabel(unicode(tr('Message:')))

        pm = QtGui.QLineEdit()
        pm.setText(user_message)

        vbox.addWidget(nick_label)
        vbox.addWidget(nick)
        vbox.addWidget(pm_label)
        vbox.addWidget(pm)

        def save_profile():
            '''save the new profile'''
            new_nick = nick.text()
            new_pm = pm.text()
            handler.save_profile(new_nick, new_pm)

        dialog.show()
        response = dialog.exec_()
        if response == QtGui.QDialog.Accepted:
            response = gui.stock.ACCEPT
            save_profile()

        dialog.hide()
示例#25
0
 def clear_connect(self):
     self._timer.stop()
     self._widget_d['label'].setText(tr('Please wait while signing in...'))
     self._widget_d['cancel_btn'].setText(tr('Cancel login'))
     try:
         self._widget_d['cancel_btn'].clicked.disconnect()
     except TypeError:
         pass
     self._widget_d['cancel_btn'].clicked.connect(self._on_cancel_login)
示例#26
0
 def clear_connect(self):
     self._timer.stop()
     self._widget_d['label'].setText(tr('Please wait while signing in...'))
     self._widget_d['cancel_btn'].setText(tr('Cancel login'))
     try:
         self._widget_d['cancel_btn'].clicked.disconnect()
     except TypeError:
         pass
     self._widget_d['cancel_btn'].clicked.connect(self._on_cancel_login)
示例#27
0
 def rename_group(cls, group, response_cb, title=tr('Rename group')):
     '''show a dialog with the group name and ask to rename it, the
     response callback receives stock.ACCEPT, stock.CANCEL or stock.CLOSE
     the old and the new name.
     cb args: response, group, new_name
     '''
     dialog = EntryDialog(tr('New group name:'), group.name, title)
     response = dialog.exec_()
     response_cb(response, group, dialog.text())
示例#28
0
 def update_toggle_avatar_icon(self, show_avatars):
     if show_avatars:
         self._action_dict['toggle_avatars'].setIcon(
             self.theme_tool_hide_avatar)
         self._action_dict['toggle_avatars'].setToolTip(tr('Hide avatar'))
     else:
         self._action_dict['toggle_avatars'].setIcon(
             self.theme_tool_show_avatar)
         self._action_dict['toggle_avatars'].setToolTip(tr('Show avatar'))
示例#29
0
 def rename_group(cls, group, response_cb, title=tr('Rename group')):
     '''show a dialog with the group name and ask to rename it, the
     response callback receives stock.ACCEPT, stock.CANCEL or stock.CLOSE
     the old and the new name.
     cb args: response, group, new_name
     '''
     dialog = EntryDialog(tr('New group name:'), group.name, title)
     response = dialog.exec_()
     response_cb(response, group, dialog.text())
示例#30
0
 def __init__(self, session):
     '''constructor
     '''
     BaseTable.__init__(self, 2, 1)
     self.session = session
     self.append_check(tr('Notify on contact online'),
         'session.config.b_notify_contact_online')
     self.append_check(tr('Notify on contact offline'),
         'session.config.b_notify_contact_offline')
     self.append_check(tr('Notify on received message'),
         'session.config.b_notify_receive_message')
示例#31
0
 def __init__(self, session):
     '''constructor
     '''
     BaseTable.__init__(self, 2, 1)
     self.session = session
     self.append_check(tr('Notify on contact online'),
                       'session.config.b_notify_contact_online')
     self.append_check(tr('Notify on contact offline'),
                       'session.config.b_notify_contact_offline')
     self.append_check(tr('Notify on received message'),
                       'session.config.b_notify_receive_message')
示例#32
0
文件: MainMenu.py 项目: Roger/emesene
    def __init__(self, handler, config, parent=None):
        """
        constructor

        handler -- e3common.Handler.OptionsHandler
        """
        QtGui.QMenu.__init__(self, tr("Options"), parent)
        self.handler = handler

        # "Show" submenu
        self.show_menu = QtGui.QMenu(tr("Show..."))

        show_offline = QtGui.QAction(tr("Show offline contacts"), self)
        show_empty_groups = QtGui.QAction(tr("Show empty groups"), self)
        show_blocked = QtGui.QAction(tr("Show blocked contacts"), self)

        show_offline.setCheckable(True)
        show_empty_groups.setCheckable(True)
        show_blocked.setCheckable(True)
        show_offline.setChecked(config.b_show_offline)
        show_empty_groups.setChecked(config.b_show_empty_groups)
        show_blocked.setChecked(config.b_show_blocked)

        self.show_menu.addAction(show_offline)
        self.show_menu.addAction(show_empty_groups)
        self.show_menu.addAction(show_blocked)

        show_offline.triggered.connect(self.handler.on_show_offline_toggled)
        show_empty_groups.triggered.connect(self.handler.on_show_empty_groups_toggled)
        show_blocked.triggered.connect(self.handler.on_show_blocked_toggled)
        # ----

        order_action_group = QtGui.QActionGroup(self)
        by_status = QtGui.QAction(tr("Order by status"), self)
        by_group = QtGui.QAction(tr("Order by group"), self)
        group_offline = QtGui.QAction(tr("Group offline contacts"), self)
        preferences = QtGui.QAction(ICON("preferences-other"), tr("Preferences..."), self)

        self.addAction(by_status)
        self.addAction(by_group)
        self.addSeparator()
        self.addMenu(self.show_menu)
        self.addAction(group_offline)
        self.addSeparator()
        self.addAction(preferences)

        order_action_group.addAction(by_status)
        order_action_group.addAction(by_group)
        by_group.setCheckable(True)
        by_status.setCheckable(True)
        group_offline.setCheckable(True)
        by_group.setChecked(config.b_order_by_group)
        by_status.setChecked(not config.b_order_by_group)
        group_offline.setChecked(config.b_group_offline)

        by_group.triggered.connect(self.handler.on_order_by_group_toggled)
        group_offline.triggered.connect(self.handler.on_group_offline_toggled)
        preferences.triggered.connect(lambda *args: self.handler.on_preferences_selected())
        by_status.toggled.connect(self.handler.on_order_by_status_toggled)
示例#33
0
    def __init__(self, session):
        '''constructor
        '''
        BaseTable.__init__(self, 8, 2)
        self.session = session

        self.add_text(tr('If you have problems with your nickname/message/\n'
                        'picture just click on this button, sign in with \n'
                        'your account and load a picture in your Live Profile.'
                        '\nThen restart emesene and have fun.'), 0, 0, True)
        self.add_button(tr('Open Live Profile'), 1, 0, 
                        self._on_live_profile_clicked, 0, 0)
示例#34
0
    def __init__(self, session):
        '''constructor
        '''
        BaseTable.__init__(self, 8, 2)
        self.session = session

        self.add_text(
            tr('If you have problems with your nickname/message/\n'
               'picture just click on this button, sign in with \n'
               'your account and load a picture in your Live Profile.'
               '\nThen restart emesene and have fun.'), 0, 0, True)
        self.add_button(tr('Open Live Profile'), 1, 0,
                        self._on_live_profile_clicked, 0, 0)
示例#35
0
    def __init__(self, handler, parent=None):
        '''
        constructor

        handler -- a e3common.Handler.ContactHandler
        '''
        QtGui.QMenu.__init__(self, tr('Contact'), parent)
        self._handler = handler

        
        self._action_d = {}
        action_d = self._action_d
        action_d['add']     = QtGui.QAction(ICON('list-add'),       tr('Add'),     self)
        action_d['remove']  = QtGui.QAction(ICON('list-remove'),    tr('Remove'),  self)
        action_d['block']   = QtGui.QAction(ICON('dialog-cancel'),  tr('Block'),   self)
        action_d['unblock'] = QtGui.QAction(ICON('dialog-ok-apply'), 
                                       tr('Unblock'), self)
        action_d['move_to']     = QtGui.QMenu(tr('Move to group'),      self)
        action_d['copy_to']     = QtGui.QMenu(tr('Copy to group'),      self)
        action_d['remove_from'] = QtGui.QMenu(tr('Remove from group'),  self)
        action_d['set_alias']   = QtGui.QAction(tr('Set alias')+'...',       self)
        action_d['view_info']   = QtGui.QAction(tr('View information')+'...',       self)
        
        self.addActions( (action_d['add'],
                          action_d['remove'],
                          action_d['block'],
                          action_d['unblock']) )
        self.addSeparator()
        self.addMenu(     action_d['move_to'])
        self.addMenu(     action_d['copy_to'])
        self.addMenu(     action_d['remove_from'])
        self.addSeparator()
        self.addActions( (action_d['set_alias'],
                          action_d['view_info']) )
        
        self.setIcon(QtGui.QIcon(gui.theme.image_theme.user))
        
        self.aboutToShow.connect(
            lambda *args: self._update_groups())
        action_d['add'].triggered.connect(
            lambda *args: self._handler.on_add_contact_selected())
        action_d['remove'].triggered.connect(
            lambda *args: self._handler.on_remove_contact_selected())
        action_d['block'].triggered.connect(
            lambda *args: self._handler.on_block_contact_selected())
        action_d['unblock'].triggered.connect(
            lambda *args: self._handler.on_unblock_contact_selected())
        action_d['set_alias'].triggered.connect(
            lambda *args: self._handler.on_set_alias_contact_selected())
        action_d['view_info'].triggered.connect(
            lambda *args: self._handler.on_view_information_selected())
示例#36
0
    def redraw_ublock_button(self, contact_unblocked):
        """
        redraws the block button,
        setting the appropiated stock_id and tooltip
        """
        if contact_unblocked:
            ublock_icon = self.theme_tool_block
            tooltip_text = tr('Block contact')
        else:
            ublock_icon = self.theme_tool_unblock
            tooltip_text = tr('Unblock contact')

        self._action_dict['ublock'].setToolTip(tooltip_text)
        self._action_dict['ublock'].setIcon(ublock_icon)
示例#37
0
    def redraw_ublock_button(self, contact_unblocked):
        """
        redraws the block button,
        setting the appropiated stock_id and tooltip
        """
        if contact_unblocked:
            ublock_icon = self.theme_tool_block
            tooltip_text = tr('Block contact')
        else:
            ublock_icon = self.theme_tool_unblock
            tooltip_text = tr('Unblock contact')

        self._action_dict['ublock'].setToolTip(tooltip_text)
        self._action_dict['ublock'].setIcon(ublock_icon)
示例#38
0
    def __init__(self, session):
        """constructor
        """
        BaseTable.__init__(self, 1, 1)
        self.session = session

        self.append_markup('<b>'+tr('Facebook Integration:')+'</b>')
        self.append_check(tr('Enable Facebook integration'),
                          'session.config.b_fb_enable_integration')
        self.append_check(tr('Automatically check Facebook mail'),
                          'session.config.b_fb_mail_check')
        self.append_check(tr('Automatically download Facebook status'),
                          'session.config.b_fb_status_download')
        self.append_check(tr('Publish Facebook status'),
                          'session.config.b_fb_status_write')
        self.append_check(tr('Automatically download profile photo'),
                          'session.config.b_fb_picture_download')

        #XXX: we replace \n by <br> to use the same string as gtkui
        self.append_markup(tr("<b>WARNING: This will reset your facebook token."
                 "\nemesene will ask you to login into facebook on"
                 " next login</b>").replace('\n', '<br>'))

        self.add_button(tr('Reset Facebook settings'), 0, 7,
                self.reset_facebook_login, 0, 0)

        self.show_all()
示例#39
0
    def __init__(self, handler, parent=None):
        '''
        constructor

        handler -- a e3common.Handler.ContactHandler
        '''
        QtGui.QMenu.__init__(self, tr('Contact'), parent)
        self._handler = handler

        self._action_d = {}
        action_d = self._action_d
        action_d['add'] = QtGui.QAction(ICON('list-add'), tr('Add'), self)
        action_d['remove'] = QtGui.QAction(ICON('list-remove'), tr('Remove'),
                                           self)
        action_d['block'] = QtGui.QAction(ICON('dialog-cancel'), tr('Block'),
                                          self)
        action_d['unblock'] = QtGui.QAction(ICON('dialog-ok-apply'),
                                            tr('Unblock'), self)
        action_d['move_to'] = QtGui.QMenu(tr('Move to group'), self)
        action_d['copy_to'] = QtGui.QMenu(tr('Copy to group'), self)
        action_d['remove_from'] = QtGui.QMenu(tr('Remove from group'), self)
        action_d['set_alias'] = QtGui.QAction(tr('Set alias') + '...', self)
        action_d['view_info'] = QtGui.QAction(
            tr('View information') + '...', self)

        self.addActions((action_d['add'], action_d['remove'],
                         action_d['block'], action_d['unblock']))
        self.addSeparator()
        self.addMenu(action_d['move_to'])
        self.addMenu(action_d['copy_to'])
        self.addMenu(action_d['remove_from'])
        self.addSeparator()
        self.addActions((action_d['set_alias'], action_d['view_info']))

        self.setIcon(QtGui.QIcon(gui.theme.image_theme.user))

        self.aboutToShow.connect(lambda *args: self._update_groups())
        action_d['add'].triggered.connect(
            lambda *args: self._handler.on_add_contact_selected())
        action_d['remove'].triggered.connect(
            lambda *args: self._handler.on_remove_contact_selected())
        action_d['block'].triggered.connect(
            lambda *args: self._handler.on_block_contact_selected())
        action_d['unblock'].triggered.connect(
            lambda *args: self._handler.on_unblock_contact_selected())
        action_d['set_alias'].triggered.connect(
            lambda *args: self._handler.on_set_alias_contact_selected())
        action_d['view_info'].triggered.connect(
            lambda *args: self._handler.on_view_information_selected())
示例#40
0
 def __init__(self, session):
     '''constructor
     '''
     BaseTable.__init__(self, 2, 1)
     self.session = session
     self.append_check(tr('Notify on contact online'),
         'session.config.b_notify_contact_online')
     self.append_check(tr('Notify on contact offline'),
         'session.config.b_notify_contact_offline')
     self.append_check(tr('Notify on received message'),
         'session.config.b_notify_receive_message')
     self.append_check(tr('Notify when signed in from another location'),
         'session.config.b_notify_endpoint_added')
     self.append_check(tr('Notify when information of signed in location is changed'),
         'session.config.b_notify_endpoint_updated')
示例#41
0
    def __init__(self, handler, parent=None):
        """
        constructor

        handler -- a e3common.Handler.AccountHandler
        """
        QtGui.QMenu.__init__(self, tr("Profile"), parent)
        self._handler = handler

        self.change_profile = QtGui.QAction(tr("Change profile"), self)
        self.addAction(self.change_profile)

        self.setIcon(ICON("document-properties"))

        self.change_profile.triggered.connect(lambda *args: self._handler.change_profile())
示例#42
0
    def error(cls, message, response_cb=None, title=tr('Error!')):
        '''show an error dialog displaying the message, this dialog should
        have only the option to close and the response callback is optional
        since in few cases one want to know when the error dialog was closed,
        but it can happen, so return stock.CLOSE to the callback if its set'''
        dialog = StandardButtonDialog(title)

        def accept_response():
            pass

        dialog.accept_response = accept_response
        icon = QtGui.QLabel()
        message = QtGui.QLabel(unicode(message))
        message.setTextFormat(Qt.RichText)
        message.setWordWrap(True)
        message.setAlignment(Qt.AlignCenter)
        lay = QtGui.QHBoxLayout()
        lay.addWidget(icon)
        lay.addWidget(message)
        dialog.setLayout(lay)

        dialog.add_button(QtGui.QDialogButtonBox.Ok)
        dialog.setMinimumWidth(250)
        icon.setPixmap(QtGui.QIcon.fromTheme('dialog-error').pixmap(64, 64))
        dialog.exec_()
示例#43
0
    def error(cls, message, response_cb=None, title=tr('Error!')):
        '''show an error dialog displaying the message, this dialog should
        have only the option to close and the response callback is optional
        since in few cases one want to know when the error dialog was closed,
        but it can happen, so return stock.CLOSE to the callback if its set'''
        # TODO: Consider an error notification like dolphin's notifications
        # and or consider desktop integration with windows.
        # TODO: Consider making a more abstract class to use as a base for
        # every kind of message box: error, info, attention, etc...
        dialog = StandardButtonDialog(title)
        icon = QtGui.QLabel()
        message = QtGui.QLabel(unicode(message))

        lay = QtGui.QHBoxLayout()
        lay.addWidget(icon)
        lay.addWidget(message)
        dialog.setLayout(lay)

        dialog.add_button(QtGui.QDialogButtonBox.Ok)
        dialog.setMinimumWidth(250)
        #        dialog.setSizeGripEnabled(False)
        #        dialog.setSizePolicy(QtGui.QSizePolicy.Fixed,
        #                             QtGui.QSizePolicy.Fixed)
        #dialog.setModal(True)
        #        dialog.setWindowModality(Qt.WindowModal)
        icon.setPixmap(QtGui.QIcon.fromTheme('dialog-error').pixmap(64, 64))
        message.setAlignment(Qt.AlignCenter)
        dialog.exec_()
示例#44
0
    def information(cls, message, response_cb=None, title=tr('Information')):
        '''show an error dialog displaying the message, this dialog should
        have only the option to close and the response callback is optional
        since in few cases one want to know when the error dialog was closed,
        but it can happen, so return stock.CLOSE to the callback if its set'''
        '''show a warning dialog displaying the messge, this dialog should
        have only the option to accept, like the error dialog, the response
        callback is optional, but you have to check if it's not None and
        send the response (that can be stock.ACCEPT or stock.CLOSE, if
        the user closed the window with the x)'''
        dialog = StandardButtonDialog(title)

        def accept_response():
            pass

        dialog.accept_response = accept_response
        icon = QtGui.QLabel()
        message = QtGui.QLabel(unicode(message))
        message.setTextFormat(Qt.RichText)
        lay = QtGui.QHBoxLayout()
        lay.addWidget(icon)
        lay.addWidget(message)
        dialog.setLayout(lay)

        dialog.add_button(QtGui.QDialogButtonBox.Ok)
        dialog.setMinimumWidth(250)
        icon.setPixmap(QtGui.QIcon.fromTheme('dialog-warning').pixmap(64, 64))
        message.setWordWrap(True)
        message.setAlignment(Qt.AlignCenter)
        dialog.exec_()
示例#45
0
文件: Dialog.py 项目: AmiZya/emesene
    def information(cls, message, response_cb=None, title=tr('Information')):
        '''show an error dialog displaying the message, this dialog should
        have only the option to close and the response callback is optional
        since in few cases one want to know when the error dialog was closed,
        but it can happen, so return stock.CLOSE to the callback if its set'''
        '''show a warning dialog displaying the messge, this dialog should
        have only the option to accept, like the error dialog, the response
        callback is optional, but you have to check if it's not None and
        send the response (that can be stock.ACCEPT or stock.CLOSE, if
        the user closed the window with the x)'''
        dialog = StandardButtonDialog(title)
        def accept_response():
            pass
        dialog.accept_response = accept_response
        icon = QtGui.QLabel()
        message = QtGui.QLabel(unicode(message))
        message.setTextFormat(Qt.RichText)
        lay = QtGui.QHBoxLayout()
        lay.addWidget(icon)
        lay.addWidget(message)
        dialog.setLayout(lay)

        dialog.add_button(QtGui.QDialogButtonBox.Ok)
        dialog.setMinimumWidth(250)
        icon.setPixmap(QtGui.QIcon.fromTheme('dialog-warning').pixmap(64, 64))
        message.setWordWrap(True)
        message.setAlignment(Qt.AlignCenter)
        dialog.exec_()
示例#46
0
    def __init__(self,
                 allow_empty=False,
                 empty_message=tr('Click here to write'),
                 parent=None):
        QtGui.QStackedWidget.__init__(self, parent)

        self._allow_empty = allow_empty
        self._empty_message = u'<u>' + empty_message + u'</u>'
        self._is_empty_message_displayed = False

        self._text = ''

        self.line_edit = QtGui.QLineEdit()
        self.label = QLabelEmph(
            QtCore.QString('If you see this, " \
                            "please invoke setText on NickEdit.'))

        self.set_text(QtCore.QString())

        self.addWidget(self.line_edit)
        self.addWidget(self.label)
        self.setCurrentWidget(self.label)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding,
                           QtGui.QSizePolicy.Fixed)

        self.label.clicked.connect(self._on_label_clicked)
        self.line_edit.editingFinished.connect(self._on_line_edited)
示例#47
0
 def __init__(self, session):
     '''constructor
     '''
     BaseTable.__init__(self, 2, 1)
     self.session = session
     self.append_check(tr('Notify on contact online'),
                       'session.config.b_notify_contact_online')
     self.append_check(tr('Notify on contact offline'),
                       'session.config.b_notify_contact_offline')
     self.append_check(tr('Notify on received message'),
                       'session.config.b_notify_receive_message')
     self.append_check(tr('Notify when signed in from another location'),
                       'session.config.b_notify_endpoint_added')
     self.append_check(
         tr('Notify when information of signed in location is changed'),
         'session.config.b_notify_endpoint_updated')
示例#48
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d
        avatar_cls = extension.get_default('avatar')

        widget_d['display_pic'] = avatar_cls(clickable=False, crossfade=False)
        widget_d['label'] = QtGui.QLabel()
        widget_d['progress_bar'] = QtGui.QProgressBar()
        widget_d['cancel_btn'] = QtGui.QPushButton(tr('Cancel'))

        lay = QtGui.QVBoxLayout()
        lay.addSpacing(40)
        lay.addWidget(widget_d['display_pic'], 0, Qt.AlignCenter)
        lay.addStretch()
        lay.addWidget(widget_d['label'], 0, Qt.AlignCenter)
        lay.addWidget(widget_d['progress_bar'], 0, Qt.AlignCenter)
        lay.addSpacing(35)
        lay.addStretch()
        lay.addWidget(widget_d['cancel_btn'], 0, Qt.AlignCenter)
        lay.addSpacing(45)

        hor_lay = QtGui.QHBoxLayout()
        hor_lay.addStretch()
        hor_lay.addSpacing(40)
        hor_lay.addLayout(lay)
        hor_lay.addSpacing(40)
        hor_lay.addStretch()
        self.setLayout(hor_lay)

        widget_d['display_pic'].set_from_file(self._avatar_path)
        widget_d['progress_bar'].setMinimum(0)
        widget_d['progress_bar'].setMaximum(0)
        widget_d['progress_bar'].setMinimumWidth(220)
示例#49
0
    def __init__(self, handler, parent=None):
        '''
        constructor

        handler -- a e3common.Handler.AccountHandler
        '''
        QtGui.QMenu.__init__(self, tr('Profile'), parent)
        self._handler = handler

        self.change_profile = QtGui.QAction(tr('Change profile'), self)
        self.addAction(self.change_profile)

        self.setIcon(ICON('document-properties'))

        self.change_profile.triggered.connect(
            lambda *args: self._handler.change_profile())
示例#50
0
    def __init__(self, allow_empty=False, 
                 empty_message=tr('Click here to write'),
                 parent=None):
        QtGui.QStackedWidget.__init__(self, parent)

        self._allow_empty = allow_empty
        self._empty_message = u'<u>' + empty_message + u'</u>'
        self._is_empty_message_displayed = False

        self._text = ''
        
        self.line_edit = QtGui.QLineEdit()
        self.label = QLabelEmph(QtCore.QString('If you see this, " \
                            "please invoke setText on NickEdit.'))

        self.set_text(QtCore.QString())

        self.addWidget(self.line_edit)
        self.addWidget(self.label)
        self.setCurrentWidget(self.label)
        self.setSizePolicy(QtGui.QSizePolicy.Expanding, 
                           QtGui.QSizePolicy.Fixed)

        self.label.clicked.connect(self._on_label_clicked)
        self.line_edit.editingFinished.connect(self._on_line_edited)
示例#51
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_d = self._widget_d
        avatar_cls = extension.get_default('avatar')

        widget_d['display_pic'] = avatar_cls(clickable=False, crossfade=False)
        widget_d['label'] = QtGui.QLabel()
        widget_d['progress_bar'] = QtGui.QProgressBar()
        widget_d['cancel_btn'] = QtGui.QPushButton(tr('Cancel'))

        lay = QtGui.QVBoxLayout()
        lay.addSpacing(40)
        lay.addWidget(widget_d['display_pic'], 0, Qt.AlignCenter)
        lay.addStretch()
        lay.addWidget(widget_d['label'], 0, Qt.AlignCenter)
        lay.addWidget(widget_d['progress_bar'], 0, Qt.AlignCenter)
        lay.addSpacing(35)
        lay.addStretch()
        lay.addWidget(widget_d['cancel_btn'], 0, Qt.AlignCenter)
        lay.addSpacing(45)

        hor_lay = QtGui.QHBoxLayout()
        hor_lay.addStretch()
        hor_lay.addSpacing(40)
        hor_lay.addLayout(lay)
        hor_lay.addSpacing(40)
        hor_lay.addStretch()
        self.setLayout(hor_lay)

        widget_d['display_pic'].set_from_file(self._avatar_path)
        widget_d['progress_bar'].setMinimum(0)
        widget_d['progress_bar'].setMaximum(0)
        widget_d['progress_bar'].setMinimumWidth(220)
示例#52
0
    def set_contact_alias(cls, account, alias, response_cb,
                          title=tr('Set alias')):
        '''show a dialog showing the current alias and asking for the new
        one, the response callback receives,  the response
        (stock.ACCEPT, stock.CANCEL, stock.CLEAR <- to remove the alias
        or stock.CLOSE), the account, the old and the new alias.
        cb args: response, account, old_alias, new_alias'''
        def _on_reset():
            dialog.done(gui.stock.CLEAR)

        dialog = EntryDialog(label=tr('New alias:'), text=alias, title=title)
        reset_btn = dialog.add_button(QtGui.QDialogButtonBox.Reset)
        reset_btn.clicked.connect(_on_reset)

        response = dialog.exec_()
        response_cb(response, account, alias, dialog.text())
示例#53
0
    def error(cls, message, response_cb=None, title=tr('Error!')):
        '''show an error dialog displaying the message, this dialog should
        have only the option to close and the response callback is optional
        since in few cases one want to know when the error dialog was closed,
        but it can happen, so return stock.CLOSE to the callback if its set'''
        # TODO: Consider an error notification like dolphin's notifications
        # and or consider desktop integration with windows.
        # TODO: Consider making a more abstract class to use as a base for
        # every kind of message box: error, info, attention, etc...
        dialog  = StandardButtonDialog(title)
        icon    = QtGui.QLabel()
        message = QtGui.QLabel(unicode(message))

        lay = QtGui.QHBoxLayout()
        lay.addWidget(icon)
        lay.addWidget(message)
        dialog.setLayout(lay)

        dialog.add_button(QtGui.QDialogButtonBox.Ok)
        dialog.setMinimumWidth(250)
#        dialog.setSizeGripEnabled(False)
#        dialog.setSizePolicy(QtGui.QSizePolicy.Fixed,
#                             QtGui.QSizePolicy.Fixed)
    #dialog.setModal(True)
#        dialog.setWindowModality(Qt.WindowModal)
        icon.setPixmap(QtGui.QIcon.fromTheme('dialog-error').pixmap(64, 64))
        message.setAlignment(Qt.AlignCenter)
        dialog.exec_()
示例#54
0
    def __init__(self, handler, parent=None):
        '''
        constructor

        handler -- a e3common.Handler.TrayIconHandler object
        '''
        QtGui.QMenu.__init__(self, parent)
        self._handler = handler
        self.hide_show_mainwindow = QtGui.QAction(tr('Hide/Show emesene'), self)
        self.quit = QtGui.QAction(ICON('application-exit'), tr('Quit'), self)
            
        self.addAction(self.hide_show_mainwindow)
        self.addSeparator()
        self.addAction(self.quit)

        self.quit.triggered.connect(
            lambda *args: self._handler.on_quit_selected())
示例#55
0
    def add_contact(cls,
                    groups,
                    group_selected,
                    response_cb,
                    title="Add user"):
        '''show a dialog asking for an user address, and (optional)
        the group(s) where the user should be added, the response callback
        receives the response type (stock.ADD, stock.CANCEL or stock.CLOSE)
        the account and a tuple of group names where the user should be
        added (give a empty tuple if you don't implement this feature,
        the controls are made by the callback, you just ask for the email,
        don't make any control, you are just implementing a GUI! :P'''
        log.info(str(response_cb))
        dialog = OkCancelDialog(title)
        text_label = QtGui.QLabel(tr('E-mail:'))
        text_edit = QtGui.QLineEdit()
        group_label = QtGui.QLabel(tr('Group:'))
        group_combo = QtGui.QComboBox()

        lay = QtGui.QGridLayout()
        lay.addWidget(text_label, 0, 0)
        lay.addWidget(text_edit, 0, 1)
        lay.addWidget(group_label, 1, 0)
        lay.addWidget(group_combo, 1, 1)
        dialog.setLayout(lay)

        dialog.set_accept_response(gui.stock.ADD)
        text_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        group_label.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        dialog.setMinimumWidth(300)

        log.debug(str(groups))
        groups = list(groups)
        log.debug(groups)
        groups.sort()

        group_combo.addItem('<i>' + tr('No Group') + '</i>', '')
        for group in groups:
            group_combo.addItem(group.name, group.name)

        response = dialog.exec_()

        email = unicode(text_edit.text())
        group = group_combo.itemData(group_combo.currentIndex()).toPyObject()
        log.debug('[%s,%s]' % (email, group))
        response_cb(response, email, group)
示例#56
0
    def _setup_ui(self):
        '''add the widgets that will display the information of the 
        extension category and the selected extension and widgets 
        to display the extensions'''

        self.add_text(tr('Categories'), 0, 0, True)
        self.add_text(tr('Selected'), 0, 1, True)
        self.add_text('', 0, 2, True)
        self.add_text(tr('Name'), 0, 3, True)
        self.add_text(tr('Description'), 0, 4, True)
        self.add_text(tr('Author'), 0, 5, True)
        self.add_text(tr('Website'), 0, 6, True)
        self.add_label(self.name_info, 1, 3, True)
        self.add_label(self.description_info, 1, 4, True)
        self.add_label(self.author_info, 1, 5, True)
        self.add_label(self.website_info, 1, 6, True)
        self.add_button(tr('Redraw main screen'), 1, 7,
                        self._on_redraw_main_screen)
        self.attach(self.categories_cmb, 1, 2, 0, 1)
        self.attach(self.extensions_cmb, 1, 2, 1, 2)

        categories = extension.get_multiextension_categories()
        for item in categories:
            log.info('category item: %s' % item)
            self.categories_cmb.addItem(item)
        self.categories_cmb.setCurrentIndex(0)
        self._on_category_changed(self.categories_cmb)

        self.categories_cmb.currentIndexChanged.connect(
            lambda text: self._on_category_changed(self.categories_cmb))
        self.extensions_cmb.currentIndexChanged.connect(
            lambda text: self._on_extension_changed(self.extensions_cmb))
示例#57
0
    def __init__(self, handler, parent=None):
        '''
        constructor

        handler -- a e3common.Handler.TrayIconHandler object
        '''
        QtGui.QMenu.__init__(self, parent)
        self._handler = handler
        self.hide_show_mainwindow = QtGui.QAction(tr('Hide/Show emesene'),
                                                  self)
        self.quit = QtGui.QAction(ICON('application-exit'), tr('Quit'), self)

        self.addAction(self.hide_show_mainwindow)
        self.addSeparator()
        self.addAction(self.quit)

        self.quit.triggered.connect(
            lambda *args: self._handler.on_quit_selected())
示例#58
0
    def __init__(self, session, members, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.session = session
        self.members = members

        lay = QtGui.QVBoxLayout()
        self.setLayout(lay)

        Avatar = extension.get_default('avatar')
        avatar_size = self.session.config.get_or_set('i_conv_avatar_size', 64)

        self.avatar = Avatar(self.session, size=avatar_size)
        if self.session.session_has_service(
                e3.Session.SERVICE_PROFILE_PICTURE):
            self.avatar.clicked.connect(self._on_avatar_click)
            self.avatar.setToolTip(tr('Click here to set your avatar'))

        self.his_avatar = Avatar(self.session, size=avatar_size)
        self.his_avatar.setToolTip(tr('Click to see informations'))
        self.avatar.clicked.connect(self._on_his_avatar_click)

        # Obtains his picture and details.
        contact = self.session.contacts.safe_get(None)
        if members is not None:
            account = members[0]
            contact = self.session.contacts.safe_get(account)

        self.his_avatar.set_from_file(contact.picture, contact.blocked)
        self.avatar.set_from_file(self.session.config.last_avatar)

        self.index = 0  # used for the rotate picture function
        self.timer = None

        if len(members) > 1:
            self.timer = QtCore.QTimer()
            self.timer.setSingleShot(False)
            self.timer.timeout.connect(self.rotate_picture)
            self.timer.start(5000)

        lay.setContentsMargins(1, 1, 1, 1)
        lay.addWidget(self.his_avatar)
        lay.addStretch()
        lay.addWidget(self.avatar)
示例#59
0
    def set_contact_alias(cls,
                          account,
                          alias,
                          response_cb,
                          title=tr('Set alias')):
        '''show a dialog showing the current alias and asking for the new
        one, the response callback receives,  the response
        (stock.ACCEPT, stock.CANCEL, stock.CLEAR <- to remove the alias
        or stock.CLOSE), the account, the old and the new alias.
        cb args: response, account, old_alias, new_alias'''
        def _on_reset():
            dialog.done(gui.stock.CLEAR)

        dialog = EntryDialog(label=tr('New alias:'), text=alias, title=title)
        reset_btn = dialog.add_button(QtGui.QDialogButtonBox.Reset)
        reset_btn.clicked.connect(_on_reset)

        response = dialog.exec_()
        response_cb(response, account, alias, dialog.text())
示例#60
0
    def _setup_ui(self):
        '''Instantiates the widgets, and sets the layout'''
        widget_dict = self._widget_dict

        nick_edit_cls = extension.get_default('nick edit')
        status_combo_cls = extension.get_default('status combo')
        avatar_cls = extension.get_default('avatar')
        contact_list_cls = extension.get_default('contact list')

        nick_box = QtGui.QHBoxLayout()
        widget_dict['nick_edit'] = nick_edit_cls()
        widget_dict['mail_btn'] = QtGui.QToolButton()
        widget_dict['mail_btn'].setAutoRaise(True)
        widget_dict['mail_btn'].setIcon(QtGui.QIcon.fromTheme('mail-unread'))
        widget_dict['mail_btn'].setToolButtonStyle(
            QtCore.Qt.ToolButtonTextBesideIcon)
        widget_dict['mail_btn'].setText("(0)")
        nick_box.addWidget(widget_dict['nick_edit'])
        nick_box.addWidget(widget_dict['mail_btn'])

        widget_dict['psm_edit'] = nick_edit_cls(
            allow_empty=True,
            empty_message=QtCore.QString(
                tr('<u>Click here to set a personal message...</u>')))
        widget_dict['current_media'] = QtGui.QLabel()
        widget_dict['status_combo'] = status_combo_cls()
        widget_dict['display_pic'] = avatar_cls(self.session)
        widget_dict['contact_list'] = contact_list_cls(self.session)
        my_info_lay_left = QtGui.QVBoxLayout()
        my_info_lay_left.addLayout(nick_box)
        my_info_lay_left.addWidget(widget_dict['psm_edit'])
        my_info_lay_left.addWidget(widget_dict['current_media'])
        my_info_lay_left.addWidget(widget_dict['status_combo'])

        my_info_lay = QtGui.QHBoxLayout()
        my_info_lay.addWidget(widget_dict['display_pic'])
        my_info_lay.addLayout(my_info_lay_left)

        lay = QtGui.QVBoxLayout()
        lay.addLayout(my_info_lay)
        lay.addWidget(widget_dict['contact_list'])
        self.setLayout(lay)

        # First fill of personal Infos:
        self._on_ss_profile_get_succeed('', '')

        widget_dict['nick_edit'].nick_changed.connect(self._on_set_new_nick)
        widget_dict['psm_edit'].nick_changed.connect(self._on_set_new_psm)
        widget_dict['status_combo'].status_changed.connect(
            self._on_set_new_status)
        widget_dict['display_pic'].clicked.connect(
            self._on_display_pic_clicked)
        widget_dict['contact_list'].new_conversation_requested.connect(
            self.on_new_conversation_requested)
        widget_dict['mail_btn'].clicked.connect(self._on_mail_click)