Beispiel #1
0
    def __init__(self, parent=None):
        QMenu.__init__(self, parent)
        mitem = self.addAction(QIcon(I("devices/folder.png")), _("Connect to folder"))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_folder.emit())
        self.connect_to_folder_action = mitem
        mitem = self.addAction(QIcon(I("devices/itunes.png")), _("Connect to iTunes"))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_itunes.emit())
        self.connect_to_itunes_action = mitem
        itunes_ok = iswindows or (isosx and get_osx_version() < (10, 9, 0))
        mitem.setVisible(itunes_ok)

        self.addSeparator()
        self.toggle_server_action = self.addAction(QIcon(I("network-server.png")), _("Start Content Server"))
        self.toggle_server_action.triggered.connect(lambda x: self.toggle_server.emit())
        self.control_smartdevice_action = self.addAction(QIcon(I("dot_red.png")), self.DEVICE_MSGS[0])
        self.control_smartdevice_action.triggered.connect(lambda x: 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", "itunes"):
                if not (iswindows or isosx) and attr == "itunes":
                    continue
                ac = getattr(self, "connect_to_%s_action" % attr)
                r(prefix + attr, unicode(ac.text()), action=ac, group=gr)
            r(prefix + " content server", _("Start/stop content server"), action=self.toggle_server_action, group=gr)
Beispiel #2
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, unicode_type(ac.text()), action=ac,
                        group=gr)
            r(prefix+' content server', _('Start/stop Content server'),
                    action=self.toggle_server_action, group=gr)
Beispiel #3
0
    def __init__(self, parent=None):
        """
        Create menu object.

        `UndoMenu` class shows list of child items in the plain list,
        suitable for undo / redo operations.

        Items are inserted to menu with `setItems()` method.

        Methods `setMaxWidth()` and `setLength()` allow to limit the
        width (in pixels) and height (as a number of shown items) of
        menu.

        To customize summary label (shown in the bottom area of menu),
        use `setComment()` method.

        Top-most item can be obtained with `lastItem()` method.

        Arguments:
            parent (Optional[QWidget]): Parent widget. Defaults to None.
        """
        QMenu.__init__(self, parent)
        v_layout = QVBoxLayout(self)
        v_layout.setContentsMargins(0, 0, 0, 0)

        frame = QFrame(self)
        frame.setFrameStyle(QFrame.Panel | QFrame.Plain)
        v_layout.addWidget(frame)

        v_layout = QVBoxLayout(frame)
        v_layout.setContentsMargins(0, 0, 0, 0)
        v_layout.setSpacing(1)

        self._list = QListWidget(frame)
        self._list.setFrameStyle(QListWidget.NoFrame)
        self._list.setSelectionMode(QListWidget.MultiSelection)
        self._list.setVerticalScrollMode(QListWidget.ScrollPerItem)
        self._list.setVerticalScrollBarPolicy(Qt.ScrollBarAsNeeded)
        self._list.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self._list.setResizeMode(QListWidget.Adjust)
        self._list.setFocusPolicy(Qt.NoFocus)
        self._list.viewport().installEventFilter(self)
        self._list.installEventFilter(self)
        self._list.viewport().setMouseTracking(True)

        self._label = QLabel(frame)
        self._label.setAlignment(Qt.AlignCenter)

        v_layout.addWidget(self._list)
        v_layout.addWidget(HLine(frame))
        v_layout.addWidget(self._label)

        self._comment = "%d"
        self._length = 10
        self._max_width = 0

        self._updateComment()
Beispiel #4
0
    def __init__(self, parent=None):
        QMenu.__init__(self, parent)
        mitem = self.addAction(QIcon(I('devices/folder.png')),
                               _('Connect to folder'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_folder.emit())
        self.connect_to_folder_action = mitem
        mitem = self.addAction(QIcon(I('devices/itunes.png')),
                               _('Connect to iTunes'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_itunes.emit())
        self.connect_to_itunes_action = mitem
        itunes_ok = iswindows or (isosx and get_osx_version() < (10, 9, 0))
        mitem.setVisible(itunes_ok)
        mitem = self.addAction(QIcon(I('devices/bambook.png')),
                               _('Connect to Bambook'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x: self.connect_to_bambook.emit())
        self.connect_to_bambook_action = mitem
        bambook_visible = False
        if not is_disabled(BAMBOOK):
            device_ip = BAMBOOK.settings().extra_customization
            if device_ip:
                bambook_visible = True
        self.connect_to_bambook_action.setVisible(bambook_visible)

        self.addSeparator()
        self.toggle_server_action = \
            self.addAction(QIcon(I('network-server.png')),
            _('Start Content Server'))
        self.toggle_server_action.triggered.connect(
            lambda x: self.toggle_server.emit())
        self.control_smartdevice_action = \
            self.addAction(QIcon(I('dot_red.png')),
            self.DEVICE_MSGS[0])
        self.control_smartdevice_action.triggered.connect(
            lambda x: 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', 'bambook', 'itunes'):
                if not (iswindows or isosx) and attr == 'itunes':
                    continue
                ac = getattr(self, 'connect_to_%s_action' % attr)
                r(prefix + attr, unicode(ac.text()), action=ac, group=gr)
            r(prefix + ' content server',
              _('Start/stop content server'),
              action=self.toggle_server_action,
              group=gr)
Beispiel #5
0
    def __init__(self, parent=None):
        QMenu.__init__(self, parent)
        mitem = self.addAction(QIcon(I('devices/folder.png')), _('Connect to folder'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x : self.connect_to_folder.emit())
        self.connect_to_folder_action = mitem
        mitem = self.addAction(QIcon(I('devices/itunes.png')),
                _('Connect to iTunes'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x : self.connect_to_itunes.emit())
        self.connect_to_itunes_action = mitem
        itunes_ok = iswindows or (isosx and get_osx_version() < (10, 9, 0))
        mitem.setVisible(itunes_ok)
        mitem = self.addAction(QIcon(I('devices/bambook.png')), _('Connect to Bambook'))
        mitem.setEnabled(True)
        mitem.triggered.connect(lambda x : self.connect_to_bambook.emit())
        self.connect_to_bambook_action = mitem
        bambook_visible = False
        if not is_disabled(BAMBOOK):
            device_ip = BAMBOOK.settings().extra_customization
            if device_ip:
                bambook_visible = True
        self.connect_to_bambook_action.setVisible(bambook_visible)

        self.addSeparator()
        self.toggle_server_action = \
            self.addAction(QIcon(I('network-server.png')),
            _('Start Content Server'))
        self.toggle_server_action.triggered.connect(lambda x:
                self.toggle_server.emit())
        self.control_smartdevice_action = \
            self.addAction(QIcon(I('dot_red.png')),
            self.DEVICE_MSGS[0])
        self.control_smartdevice_action.triggered.connect(lambda x:
                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', 'bambook', 'itunes'):
                if not (iswindows or isosx) and attr == 'itunes':
                    continue
                ac = getattr(self, 'connect_to_%s_action'%attr)
                r(prefix + attr, unicode(ac.text()), action=ac,
                        group=gr)
            r(prefix+' content server', _('Start/stop content server'),
                    action=self.toggle_server_action, group=gr)
Beispiel #6
0
 def __init__(self, parent):
     QMenu.__init__(self, _('Choose theme (needs restart)'))
     parent.addMenu(self)
     self.group = QActionGroup(self)
     current = prefs['theme']
     alls = list(sorted(get_all_styles()))
     if current not in alls:
         current = prefs['theme'] = 'default'
     self.actions = []
     for style in alls:
         ac = self.group.addAction(style)
         ac.setCheckable(True)
         if current == style:
             ac.setChecked(True)
         self.actions.append(ac)
         ac.triggered.connect(partial(self.set_theme, style))
         self.addAction(ac)
Beispiel #7
0
 def __init__(self, parent):
     QMenu.__init__(self, _('Choose theme (needs restart)'))
     parent.addMenu(self)
     self.group = QActionGroup(self)
     current = prefs['theme']
     alls = list(sorted(get_all_styles()))
     if current not in alls:
         current = prefs['theme'] = 'default'
     self.actions = []
     for style in alls:
         ac = self.group.addAction(style)
         ac.setCheckable(True)
         if current == style:
             ac.setChecked(True)
         self.actions.append(ac)
         ac.triggered.connect(partial(self.set_theme, style))
         self.addAction(ac)
Beispiel #8
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
Beispiel #9
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