コード例 #1
0
ファイル: ui.py プロジェクト: h4ck3rm1k3/calibre
    def __init__(self, parent=None):
        QStackedWidget.__init__(self, parent)
        self.welcome = w = QLabel('<p>'+_(
            'Double click a file in the left panel to start editing'
            ' it.'))
        self.addWidget(w)
        w.setWordWrap(True)
        w.setAlignment(Qt.AlignTop | Qt.AlignHCenter)

        self.container = c = QWidget(self)
        self.addWidget(c)
        l = c.l = QVBoxLayout(c)
        c.setLayout(l)
        l.setContentsMargins(0, 0, 0, 0)
        self.editor_tabs = t = QTabWidget(c)
        l.addWidget(t)
        t.setDocumentMode(True)
        t.setTabsClosable(True)
        t.setMovable(True)
        pal = self.palette()
        if pal.color(pal.WindowText).lightness() > 128:
            i = QImage(I('modified.png'))
            i.invertPixels()
            self.modified_icon = QIcon(QPixmap.fromImage(i))
        else:
            self.modified_icon = QIcon(I('modified.png'))
        self.editor_tabs.currentChanged.connect(self.current_editor_changed)
        self.editor_tabs.tabCloseRequested.connect(self._close_requested)
        self.search_panel = SearchPanel(self)
        l.addWidget(self.search_panel)
        self.restore_state()
        self.editor_tabs.tabBar().installEventFilter(self)
コード例 #2
0
ファイル: ui.py プロジェクト: Hainish/calibre
    def __init__(self, parent=None):
        QStackedWidget.__init__(self, parent)
        self.welcome = w = QLabel('<p>'+_(
            'Double click a file in the left panel to start editing'
            ' it.'))
        self.addWidget(w)
        w.setWordWrap(True)
        w.setAlignment(Qt.AlignTop | Qt.AlignHCenter)

        self.container = c = QWidget(self)
        self.addWidget(c)
        l = c.l = QVBoxLayout(c)
        c.setLayout(l)
        l.setContentsMargins(0, 0, 0, 0)
        self.editor_tabs = t = QTabWidget(c)
        l.addWidget(t)
        t.setDocumentMode(True)
        t.setTabsClosable(True)
        t.setMovable(True)
        pal = self.palette()
        if pal.color(pal.WindowText).lightness() > 128:
            i = QImage(I('modified.png'))
            i.invertPixels()
            self.modified_icon = QIcon(QPixmap.fromImage(i))
        else:
            self.modified_icon = QIcon(I('modified.png'))
        self.editor_tabs.currentChanged.connect(self.current_editor_changed)
        self.editor_tabs.tabCloseRequested.connect(self._close_requested)
        self.search_panel = SearchPanel(self)
        l.addWidget(self.search_panel)
        self.restore_state()
        self.editor_tabs.tabBar().installEventFilter(self)
コード例 #3
0
    def __init__(self, parent):
        QStackedWidget.__init__(self, parent)

        parent.cb_splitter = LibraryWidget(parent)
        self.tb_widget = TagBrowserWidget(parent)
        parent.tb_splitter = Splitter('tag_browser_splitter',
                                      _('Tag Browser'),
                                      I('tags.png'),
                                      parent=parent,
                                      side_index=0,
                                      initial_side_size=200,
                                      shortcut='Shift+Alt+T')
        parent.tb_splitter.state_changed.connect(
            self.tb_widget.set_pane_is_visible, Qt.QueuedConnection)
        parent.tb_splitter.addWidget(self.tb_widget)
        parent.tb_splitter.addWidget(parent.cb_splitter)
        parent.tb_splitter.setCollapsible(parent.tb_splitter.other_index,
                                          False)

        self.addWidget(parent.tb_splitter)
        for x in ('memory', 'card_a', 'card_b'):
            name = x + '_view'
            w = DeviceBooksView(parent)
            setattr(parent, name, w)
            self.addWidget(w)
            w.setObjectName(name)
コード例 #4
0
    def __init__(self, parent):
        QStackedWidget.__init__(self, parent)

        parent.cb_splitter = LibraryWidget(parent)
        self.tb_widget = TagBrowserWidget(parent)
        parent.tb_splitter = Splitter(
            "tag_browser_splitter",
            _("Tag Browser"),
            I("tags.png"),
            parent=parent,
            side_index=0,
            initial_side_size=200,
            shortcut=_("Shift+Alt+T"),
        )
        parent.tb_splitter.state_changed.connect(self.tb_widget.set_pane_is_visible, Qt.QueuedConnection)
        parent.tb_splitter.addWidget(self.tb_widget)
        parent.tb_splitter.addWidget(parent.cb_splitter)
        parent.tb_splitter.setCollapsible(parent.tb_splitter.other_index, False)

        self.addWidget(parent.tb_splitter)
        for x in ("memory", "card_a", "card_b"):
            name = x + "_view"
            w = DeviceBooksView(parent)
            setattr(parent, name, w)
            self.addWidget(w)
            w.setObjectName(name)
コード例 #5
0
    def __init__(
        self,
        parentWidget,
        switchPageWidget=None,
        childWidgetList=[],
        label='',
        labelColumn=0,
        spanWidth=True,
    ):
        """
        Appends a QStackedWidget (Qt) widget to the bottom of I{parentWidget}, 
        which must be a Property Manager group box.
        
        @param parentWidget: the parent group box containing this widget.
        @type  parentWidget: PM_GroupBox
        
        @param switchPageWidget: The widget that is used to switch between
                                 pages. If None (the default), it is up to the
                                 caller to manage page switching.
        @type  switchPageWidget: PM_ComboBox or PM_ListWidget
        
        @param childWidgetList: a list of child widgets (pages), typically a
                                list of PM_GroupBoxes that contain multiple
                                widgets. Each child widget will get stacked onto
                                this stacked widget as a separate page.
        @type  childWidgetList: PM_GroupBox (or other PM widgets).
        
        @param label: label that appears above (or to the left of) this widget.
        @type  label: str
        
        @param labelColumn: The column number of the label in the group box
                            grid layout. The only valid values are 0 (left 
                            column) and 1 (right column). The default is 0 
                            (left column).
        @type  labelColumn: int
        
        @param spanWidth: If True, the widget and its label will span the width
                      of the group box. Its label will appear directly above
                      the widget (unless the label is empty) and is left justified.
        @type  spanWidth: bool (default True)
        
        @see: U{B{QStackedWidget}<http://doc.trolltech.com/4/qstackedwidget.html>}
        """

        QStackedWidget.__init__(self)

        assert isinstance(parentWidget, PM_GroupBox)

        self.parentWidget = parentWidget
        self.label = label
        self.labelColumn = labelColumn
        self.spanWidth = spanWidth

        for widget in childWidgetList:
            self.addWidget(widget)

        self.setSwitchPageWidget(switchPageWidget)

        parentWidget.addPmWidget(self)
コード例 #6
0
    def __init__(self,
                 parentWidget,
                 switchPageWidget  = None,
                 childWidgetList   = [],
                 label             = '',
                 labelColumn       = 0,
                 spanWidth         = True,
                 ):
        """
        Appends a QStackedWidget (Qt) widget to the bottom of I{parentWidget},
        which must be a Property Manager group box.

        @param parentWidget: the parent group box containing this widget.
        @type  parentWidget: PM_GroupBox

        @param switchPageWidget: The widget that is used to switch between
                                 pages. If None (the default), it is up to the
                                 caller to manage page switching.
        @type  switchPageWidget: PM_ComboBox or PM_ListWidget

        @param childWidgetList: a list of child widgets (pages), typically a
                                list of PM_GroupBoxes that contain multiple
                                widgets. Each child widget will get stacked onto
                                this stacked widget as a separate page.
        @type  childWidgetList: PM_GroupBox (or other PM widgets).

        @param label: label that appears above (or to the left of) this widget.
        @type  label: str

        @param labelColumn: The column number of the label in the group box
                            grid layout. The only valid values are 0 (left
                            column) and 1 (right column). The default is 0
                            (left column).
        @type  labelColumn: int

        @param spanWidth: If True, the widget and its label will span the width
                      of the group box. Its label will appear directly above
                      the widget (unless the label is empty) and is left justified.
        @type  spanWidth: bool (default True)

        @see: U{B{QStackedWidget}<http://doc.trolltech.com/4/qstackedwidget.html>}
        """

        QStackedWidget.__init__(self)

        assert isinstance(parentWidget, PM_GroupBox)

        self.parentWidget = parentWidget
        self.label        = label
        self.labelColumn  = labelColumn
        self.spanWidth    = spanWidth

        for widget in childWidgetList:
            self.addWidget(widget)

        self.setSwitchPageWidget(switchPageWidget)

        parentWidget.addPmWidget(self)