Exemplo n.º 1
0
    def __init__(self, parent=None):
        QMenu.__init__(self, parent)
        self.ip_text = ''
        mitem = self.addAction(QIcon(I('devices/folder.png')), _('Connect to folder'))
        mitem.setEnabled(True)
        connect_lambda(mitem.triggered, self, lambda self: self.connect_to_folder.emit())
        self.connect_to_folder_action = mitem

        self.addSeparator()
        self.toggle_server_action = \
            self.addAction(QIcon(I('network-server.png')),
            _('Start Content server'))
        connect_lambda(self.toggle_server_action.triggered, self, lambda self: self.toggle_server.emit())
        self.control_smartdevice_action = \
            self.addAction(QIcon(I('dot_red.png')),
            self.DEVICE_MSGS[0])
        connect_lambda(self.control_smartdevice_action.triggered, self, lambda self: self.control_smartdevice.emit())
        self.addSeparator()

        self.email_actions = []

        if hasattr(parent, 'keyboard'):
            r = parent.keyboard.register_shortcut
            prefix = 'Share/Connect Menu '
            gr = ConnectShareAction.action_spec[0]
            for attr in ('folder', ):
                ac = getattr(self, 'connect_to_%s_action'%attr)
                r(prefix + attr, str(ac.text()), action=ac,
                        group=gr)
            r(prefix+' content server', _('Start/stop Content server'),
                    action=self.toggle_server_action, group=gr)
Exemplo n.º 2
0
 def __init__(self, parent=None):
     QMenu.__init__(self, parent)
     self.l = l = QHBoxLayout(self)
     l.setSpacing(20)
     self.items = []
     if parent is None:
         buttons = [
             QPushButton(QIcon(I(i + '.png')), i, self)
             for i in 'search tags cover_flow grid book'.split()
         ]
         for b in buttons:
             b.setVisible(False), b.setCheckable(True), b.setChecked(
                 b.text() in 'tags grid')
             b.label = b.text().capitalize()
     else:
         buttons = parent.layout_buttons
     for b in buttons:
         self.items.append(LayoutItem(b, self))
         l.addWidget(self.items[-1])
     self.current_item = None