Beispiel #1
0
    def __init__(self, parent_gb, object_name, rules, eligible_custom_fields, db):
        self.rules = rules
        self.eligible_custom_fields = eligible_custom_fields
        self.db = db
        QTableWidget.__init__(self)
        self.setObjectName(object_name)
        self.layout = parent_gb.layout()

        # Add ourselves to the layout
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        #sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        self.setMaximumSize(QSize(16777215, self.MAXIMUM_TABLE_HEIGHT))

        self.setColumnCount(0)
        self.setRowCount(0)
        self.layout.addWidget(self)

        self.last_row_selected = self.currentRow()
        self.last_rows_selected = self.selectionModel().selectedRows()

        self._init_controls()

        # Hook check_box changes
        QObject.connect(self, SIGNAL('cellChanged(int,int)'), self.enabled_state_changed)
    def _createHeader(self, iconPath, title):
        """
        Creates the Property Manager header, which contains an icon
        (a QLabel with a pixmap) and white text (a QLabel with text).
        
        @param iconPath: The relative path for the icon (PNG image) that 
                         appears in the header.
        @type  iconPath: str
        
        @param title: The title that appears in the header.
        @type  title: str
        """

        # Heading frame (dark gray), which contains
        # a pixmap and (white) heading text.
        self.headerFrame = QFrame(self)
        self.headerFrame.setFrameShape(QFrame.NoFrame)
        self.headerFrame.setFrameShadow(QFrame.Plain)

        self.headerFrame.setPalette(QPalette(pmHeaderFrameColor))
        self.headerFrame.setAutoFillBackground(True)

        # HBox layout for heading frame, containing the pixmap
        # and label (title).
        HeaderFrameHLayout = QHBoxLayout(self.headerFrame)
        # 2 pixels around edges --
        HeaderFrameHLayout.setMargin(PM_HEADER_FRAME_MARGIN)
        # 5 pixel between pixmap and label. --
        HeaderFrameHLayout.setSpacing(PM_HEADER_FRAME_SPACING)

        # PropMgr icon. Set image by calling setHeaderIcon().
        self.headerIcon = QLabel(self.headerFrame)
        self.headerIcon.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Fixed),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.headerIcon.setScaledContents(True)

        HeaderFrameHLayout.addWidget(self.headerIcon)

        # PropMgr header title text (a QLabel).
        self.headerTitle = QLabel(self.headerFrame)
        headerTitlePalette = self._getHeaderTitlePalette()
        self.headerTitle.setPalette(headerTitlePalette)
        self.headerTitle.setAlignment(PM_LABEL_LEFT_ALIGNMENT)

        # Assign header title font.
        self.headerTitle.setFont(self._getHeaderFont())
        HeaderFrameHLayout.addWidget(self.headerTitle)

        self.vBoxLayout.addWidget(self.headerFrame)

        # Set header icon and title text.
        self.setHeaderIcon(iconPath)
        self.setHeaderTitle(title)
Beispiel #3
0
    def ui_bondTools_grpBox(self, MMKitDialog):
        #Start Atom Bond tools Groupbox

        self.bondTools_grpBox = QtGui.QGroupBox(MMKitDialog)
        self.bondTools_grpBox.setObjectName("bondTools_grpBox")

        self.bondTools_grpBox.setAutoFillBackground(True)
        palette = MMKitDialog.getGroupBoxPalette()
        self.bondTools_grpBox.setPalette(palette)

        styleSheet = MMKitDialog.getGroupBoxStyleSheet()
        self.bondTools_grpBox.setStyleSheet(styleSheet)

        self.vboxlayout_grpbox1 = QtGui.QVBoxLayout(self.bondTools_grpBox)
        self.vboxlayout_grpbox1.setMargin(pmGrpBoxVboxLayoutMargin)
        self.vboxlayout_grpbox1.setSpacing(pmGrpBoxVboxLayoutSpacing)
        self.vboxlayout_grpbox1.setObjectName("vboxlayout_grpbox1")

        self.bondTool_groupBoxButton = MMKitDialog.getGroupBoxTitleButton(
            "Bonds Tool",
            self.bondTools_grpBox)

        self.vboxlayout_grpbox1.addWidget(self.bondTool_groupBoxButton)


        self.bondToolWidget = QtGui.QWidget(self.bondTools_grpBox)

        hlo_bondtool = QtGui.QHBoxLayout(self.bondToolWidget)
        hlo_bondtool.setMargin(2)
        hlo_bondtool.setSpacing(2)


        for action in self.parentMode.bond1Action, self.parentMode.bond2Action, \
            self.parentMode.bond3Action, self.parentMode.bondaAction, \
            self.parentMode.bondgAction, self.parentMode.cutBondsAction:

            btn = QtGui.QToolButton()
            btn.setDefaultAction(action)
            btn.setIconSize(QtCore.QSize(22,22))
            btn.setAutoRaise(1)
            action.setCheckable(True)
            self.parentMode.bondToolsActionGroup.addAction(action)
            hlo_bondtool.addWidget(btn)

        self.vboxlayout_grpbox1.addWidget(self.bondToolWidget)

        # End Atom Bond Tools Groupbox
        self.pmVBoxLayout.addWidget(self.bondTools_grpBox)

        # Height is fixed. Mark 2007-05-29.
        self.bondTools_grpBox.setSizePolicy(
                QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                            QSizePolicy.Policy(QSizePolicy.Fixed)))
    def ui_selectionFilter_GroupBox(self, MMKitDialog):
        #Start Selection Filter GroupBox
        self.selectionFilter_groupBox = QtGui.QGroupBox(MMKitDialog)
        self.selectionFilter_groupBox.setObjectName("selectionFilter_groupBox")

        self.selectionFilter_groupBox.setAutoFillBackground(True)
        palette = MMKitDialog.getGroupBoxPalette()
        self.selectionFilter_groupBox.setPalette(palette)

        styleSheet = MMKitDialog.getGroupBoxStyleSheet()
        self.selectionFilter_groupBox.setStyleSheet(styleSheet)

        self.hboxlayout_selfilter = QtGui.QHBoxLayout()
        self.hboxlayout_selfilter.setMargin(pmGrpBoxVboxLayoutMargin)
        self.hboxlayout_selfilter.setSpacing(6)
        self.hboxlayout_selfilter.setObjectName("hboxlayout_selfilter")

        self.vboxlayout_selfilter = QtGui.QVBoxLayout(
            self.selectionFilter_groupBox)
        self.vboxlayout_selfilter.setMargin(pmGrpBoxVboxLayoutMargin)
        self.vboxlayout_selfilter.setSpacing(6)
        self.vboxlayout_selfilter.setObjectName("vboxlayout_selfilter")

        self.filterCB = MMKitDialog.getGroupBoxTitleCheckBox(
            "Selection Filter ", self.selectionFilter_groupBox)

        self.vboxlayout_selfilter.addWidget(self.filterCB)

        self.selectionFilter_label = QtGui.QLabel(
            self.selectionFilter_groupBox)
        self.vboxlayout_selfilter.addWidget(self.selectionFilter_label)

        self.filterlistLE = QLineEdit(self.selectionFilter_groupBox)
        self.filterlistLE.setReadOnly(1)
        self.filterlistLE.setEnabled(0)

        if self.filterCB.isChecked():
            self.filterlistLE.show()
            self.selectionFilter_label.show()
        else:
            self.filterlistLE.hide()
            self.selectionFilter_label.hide()

        self.vboxlayout_selfilter.addWidget(self.filterlistLE)
        #End Selection filter GroupBox
        self.pmVBoxLayout.addWidget(self.selectionFilter_groupBox)

        # Height is fixed. Mark 2007-05-29.
        self.selectionFilter_groupBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))
Beispiel #5
0
    def _populate_subjects(self):
        '''
        '''
        # Setting size policy allows us to match Subjects fields height
        sp = QSizePolicy()
        sp.setHorizontalStretch(True)
        sp.setVerticalStretch(False)
        sp.setHeightForWidth(False)
        self.calibre_subjects.setSizePolicy(sp)
        self.marvin_subjects.setSizePolicy(sp)

        if 'tags' in self.mismatches:
            cs = "<b>Subjects:</b> {0}".format(', '.join(
                self.mismatches['tags']['calibre']))
            self.calibre_subjects.setText(self.YELLOW_BG.format(cs))
            ms = "<b>Subjects:</b> {0}".format(', '.join(
                self.mismatches['tags']['Marvin']))
            self.marvin_subjects.setText(self.YELLOW_BG.format(ms))

            calibre_height = self.calibre_subjects.sizeHint().height()
            marvin_height = self.marvin_subjects.sizeHint().height()
            if calibre_height > marvin_height:
                self.marvin_subjects.setMinimumHeight(calibre_height)
                self.marvin_subjects.setMaximumHeight(calibre_height)
            elif marvin_height > calibre_height:
                self.calibre_subjects.setMinimumHeight(marvin_height)
                self.calibre_subjects.setMaximumHeight(marvin_height)
        else:
            #self._log(repr(self.installed_book.tags))
            cs = "<b>Subjects:</b> {0}".format(', '.join(
                self.installed_book.tags))
            #self._log("cs: %s" % repr(cs))
            self.calibre_subjects.setText(cs)
            self.marvin_subjects.setText(cs)
Beispiel #6
0
    def __init__(self, parent, icon, prefs, html=None, page=None, title=''):
        self.prefs = prefs
        #QDialog.__init__(self, parent=parent)
        super(HelpView, self).__init__(parent, 'help_dialog')
        self.setWindowTitle(title)
        self.setWindowIcon(icon)
        self.l = QVBoxLayout(self)
        self.setLayout(self.l)

        self.wv = QWebView()
        if html is not None:
            self.wv.setHtml(html)
        elif page is not None:
            self.wv.load(QUrl(page))
        self.wv.setMinimumHeight(100)
        self.wv.setMaximumHeight(16777215)
        self.wv.setMinimumWidth(400)
        self.wv.setMaximumWidth(16777215)
        self.wv.setGeometry(0, 0, 400, 100)
        self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.l.addWidget(self.wv)

        # Sizing
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        self.resize_dialog()
Beispiel #7
0
    def __init__(self, parent):
        ImageView.__init__(self, parent)
        self.dialog = parent
        self._cdata = None
        self.cover_changed.connect(self.set_pixmap_from_data)

        self.select_cover_button = QPushButton(QIcon(I('document_open.png')),
                                               _('&Browse'), parent)
        self.trim_cover_button = QPushButton(QIcon(I('trim.png')), _('T&rim'),
                                             parent)
        self.remove_cover_button = QPushButton(QIcon(I('trash.png')),
                                               _('&Remove'), parent)

        self.select_cover_button.clicked.connect(self.select_cover)
        self.remove_cover_button.clicked.connect(self.remove_cover)
        self.trim_cover_button.clicked.connect(self.trim_cover)

        self.download_cover_button = QPushButton(_('Download co&ver'), parent)
        self.generate_cover_button = QPushButton(_('&Generate cover'), parent)

        self.download_cover_button.clicked.connect(self.download_cover)
        self.generate_cover_button.clicked.connect(self.generate_cover)

        self.buttons = [
            self.select_cover_button, self.remove_cover_button,
            self.trim_cover_button, self.download_cover_button,
            self.generate_cover_button
        ]

        self.frame_size = (300, 400)
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred))
    def ui_advancedOptions_groupBox(self, MMKitDialog):
        #Start Advanced Options GroupBox
        self.advancedOptions_groupBox = QtGui.QGroupBox(MMKitDialog)
        self.advancedOptions_groupBox.setObjectName("advancedOptions_groupBox")

        self.advancedOptions_groupBox.setAutoFillBackground(True)
        palette = MMKitDialog.getGroupBoxPalette()
        self.advancedOptions_groupBox.setPalette(palette)

        styleSheet = MMKitDialog.getGroupBoxStyleSheet()
        self.advancedOptions_groupBox.setStyleSheet(styleSheet)

        self.vboxlayout_grpbox4 = QtGui.QVBoxLayout(
            self.advancedOptions_groupBox)
        self.vboxlayout_grpbox4.setMargin(pmGrpBoxVboxLayoutMargin)
        self.vboxlayout_grpbox4.setSpacing(pmGrpBoxVboxLayoutSpacing)
        self.vboxlayout_grpbox4.setObjectName("vboxlayout_grpbox4")

        self.advancedOptions_groupBoxButton = MMKitDialog.getGroupBoxTitleButton(
            "Advanced Options", self.advancedOptions_groupBox)

        self.vboxlayout_grpbox4.addWidget(self.advancedOptions_groupBoxButton)

        self.autobondCB = QtGui.QCheckBox("Autobond",
                                          self.advancedOptions_groupBox)
        self.autobondCB.setChecked(
            env.prefs[buildModeAutobondEnabled_prefs_key])
        self.vboxlayout_grpbox4.addWidget(self.autobondCB)

        self.highlightingCB = QtGui.QCheckBox("Highlighting",
                                              self.advancedOptions_groupBox)
        self.highlightingCB.setChecked(
            env.prefs[buildModeHighlightingEnabled_prefs_key])
        self.vboxlayout_grpbox4.addWidget(self.highlightingCB)

        self.waterCB = QtGui.QCheckBox("Water", self.advancedOptions_groupBox)
        self.waterCB.setChecked(env.prefs[buildModeWaterEnabled_prefs_key])
        self.vboxlayout_grpbox4.addWidget(self.waterCB)

        #End Advanced Options GroupBox
        self.pmVBoxLayout.addWidget(self.advancedOptions_groupBox)

        # Height is fixed. Mark 2007-05-29.
        self.advancedOptions_groupBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))
    def __init__(self, parent, icon, prefs, html=None, page=None, title=""):
        self.prefs = prefs
        # QDialog.__init__(self, parent=parent)
        super(HelpView, self).__init__(parent, "help_dialog")
        self.setWindowTitle(title)
        self.setWindowIcon(icon)
        self.l = QVBoxLayout(self)
        self.setLayout(self.l)

        self.wv = QWebView()
        if html is not None:
            self.wv.setHtml(html)
        elif page is not None:
            self.wv.load(QUrl(page))
        self.wv.setMinimumHeight(100)
        self.wv.setMaximumHeight(16777215)
        self.wv.setMinimumWidth(400)
        self.wv.setMaximumWidth(16777215)
        self.wv.setGeometry(0, 0, 400, 100)
        self.wv.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding)
        self.l.addWidget(self.wv)

        # Sizing
        sizePolicy = QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        self.resize_dialog()
    def ui_preview_GroupBox(self, MMKitDialog):
        # Start MMKit ThumbView  (Preview) GroupBox

        self.thumbView_groupBox = QtGui.QGroupBox(MMKitDialog)
        self.thumbView_groupBox.setObjectName("thumbView_groupBox")

        self.thumbView_groupBox.setAutoFillBackground(True)
        palette = MMKitDialog.getGroupBoxPalette()
        self.thumbView_groupBox.setPalette(palette)

        styleSheet = MMKitDialog.getGroupBoxStyleSheet()
        self.thumbView_groupBox.setStyleSheet(styleSheet)

        self.vboxlayout_grpbox2 = QtGui.QVBoxLayout(self.thumbView_groupBox)
        self.vboxlayout_grpbox2.setMargin(pmGrpBoxVboxLayoutMargin)
        self.vboxlayout_grpbox2.setSpacing(pmGrpBoxVboxLayoutSpacing)
        self.vboxlayout_grpbox2.setObjectName("vboxlayout_grpbox2")

        self.thumbView_groupBoxButton = MMKitDialog.getGroupBoxTitleButton(
            "Preview", self.thumbView_groupBox)

        self.vboxlayout_grpbox2.addWidget(self.thumbView_groupBoxButton)

        self.elementFrame = QtGui.QFrame(self.thumbView_groupBox)
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Policy(3),
                                       QtGui.QSizePolicy.Policy(0))
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(1)
        sizePolicy.setHeightForWidth(
            self.elementFrame.sizePolicy().hasHeightForWidth())
        self.elementFrame.setSizePolicy(sizePolicy)
        self.elementFrame.setMinimumSize(QtCore.QSize(150, 150))
        self.elementFrame.setFrameShape(QtGui.QFrame.Box)
        self.elementFrame.setFrameShadow(QtGui.QFrame.Raised)
        self.elementFrame.setObjectName("elementFrame")

        self.vboxlayout_grpbox2.addWidget(self.elementFrame)

        #End  MMKit ThumbView  (Preview) GroupBox
        self.pmVBoxLayout.addWidget(self.thumbView_groupBox)

        # Height is fixed. Mark 2007-05-29.
        self.thumbView_groupBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))
    def _populate_subjects(self):
        '''
        '''
        # Setting size policy allows us to match Subjects fields height
        sp = QSizePolicy()
        sp.setHorizontalStretch(True)
        sp.setVerticalStretch(False)
        sp.setHeightForWidth(False)
        self.calibre_subjects.setSizePolicy(sp)
        self.marvin_subjects.setSizePolicy(sp)

        if 'tags' in self.mismatches:
            cs = "<b>Subjects:</b> {0}".format(', '.join(self.mismatches['tags']['calibre']))
            self.calibre_subjects.setText(self.YELLOW_BG.format(cs))
            ms = "<b>Subjects:</b> {0}".format(', '.join(self.mismatches['tags']['Marvin']))
            self.marvin_subjects.setText(self.YELLOW_BG.format(ms))

            calibre_height = self.calibre_subjects.sizeHint().height()
            marvin_height = self.marvin_subjects.sizeHint().height()
            if calibre_height > marvin_height:
                self.marvin_subjects.setMinimumHeight(calibre_height)
                self.marvin_subjects.setMaximumHeight(calibre_height)
            elif marvin_height > calibre_height:
                self.calibre_subjects.setMinimumHeight(marvin_height)
                self.calibre_subjects.setMaximumHeight(marvin_height)
        else:
            #self._log(repr(self.installed_book.tags))
            cs = "<b>Subjects:</b> {0}".format(', '.join(self.installed_book.tags))
            #self._log("cs: %s" % repr(cs))
            self.calibre_subjects.setText(cs)
            self.marvin_subjects.setText(cs)
Beispiel #12
0
def pmAddHeader(propMgr):
    """Creates the Property Manager header, which contains
    a pixmap and white text label.
    """

    # Heading frame (dark gray), which contains
    # a pixmap and (white) heading text.
    propMgr.header_frame = QFrame(propMgr)
    propMgr.header_frame.setFrameShape(QFrame.NoFrame)
    propMgr.header_frame.setFrameShadow(QFrame.Plain)

    header_frame_palette = propMgr.getPropMgrTitleFramePalette()
    propMgr.header_frame.setPalette(header_frame_palette)
    propMgr.header_frame.setAutoFillBackground(True)

    # HBox layout for heading frame, containing the pixmap
    # and label (title).
    HeaderFrameHLayout = QHBoxLayout(propMgr.header_frame)
    HeaderFrameHLayout.setMargin(pmHeaderFrameMargin)  # 2 pixels around edges.
    HeaderFrameHLayout.setSpacing(
        pmHeaderFrameSpacing)  # 5 pixel between pixmap and label.

    # PropMgr icon. Set image by calling setPropMgrIcon() at any time.
    propMgr.header_pixmap = QLabel(propMgr.header_frame)
    propMgr.header_pixmap.setSizePolicy(
        QSizePolicy(QSizePolicy.Policy(QSizePolicy.Fixed),
                    QSizePolicy.Policy(QSizePolicy.Fixed)))

    propMgr.header_pixmap.setScaledContents(True)

    HeaderFrameHLayout.addWidget(propMgr.header_pixmap)

    # PropMgr title label
    propMgr.header_label = QLabel(propMgr.header_frame)
    header_label_palette = propMgr.getPropMgrTitleLabelPalette()
    propMgr.header_label.setPalette(header_label_palette)
    propMgr.header_label.setAlignment(pmLabelLeftAlignment)

    # PropMgr heading font (for label).
    propMgr.header_label.setFont(getHeaderFont())
    HeaderFrameHLayout.addWidget(propMgr.header_label)

    propMgr.pmVBoxLayout.addWidget(propMgr.header_frame)
Beispiel #13
0
    def __init__(self):

        if config['gui_layout'] == 'narrow':  # narrow {{{
            self.book_details = BookDetails(False, self)
            self.stack = Stack(self)
            self.bd_splitter = Splitter('book_details_splitter',
                                        _('Book Details'),
                                        I('book.png'),
                                        orientation=Qt.Vertical,
                                        parent=self,
                                        side_index=1,
                                        shortcut=_('Shift+Alt+D'))
            self.bd_splitter.addWidget(self.stack)
            self.bd_splitter.addWidget(self.book_details)
            self.bd_splitter.setCollapsible(self.bd_splitter.other_index,
                                            False)
            self.centralwidget.layout().addWidget(self.bd_splitter)
            button_order = ('tb', 'bd', 'cb')
        # }}}
        else:  # wide {{{
            self.bd_splitter = Splitter('book_details_splitter',
                                        _('Book Details'),
                                        I('book.png'),
                                        initial_side_size=200,
                                        orientation=Qt.Horizontal,
                                        parent=self,
                                        side_index=1,
                                        shortcut=_('Shift+Alt+D'))
            self.stack = Stack(self)
            self.bd_splitter.addWidget(self.stack)
            self.book_details = BookDetails(True, self)
            self.bd_splitter.addWidget(self.book_details)
            self.bd_splitter.setCollapsible(self.bd_splitter.other_index,
                                            False)
            self.bd_splitter.setSizePolicy(
                QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
            self.centralwidget.layout().addWidget(self.bd_splitter)
            button_order = ('tb', 'cb', 'bd')
        # }}}

        self.status_bar = StatusBar(self)
        stylename = unicode(self.style().objectName())
        for x in button_order:
            button = getattr(self, x + '_splitter').button
            button.setIconSize(QSize(24, 24))
            if isosx and stylename != u'Calibre':
                button.setStyleSheet('''
                        QToolButton { background: none; border:none; padding: 0px; }
                        QToolButton:checked { background: rgba(0, 0, 0, 25%); }
                ''')
            self.status_bar.addPermanentWidget(button)
        self.status_bar.addPermanentWidget(self.jobs_button)
        self.setStatusBar(self.status_bar)
        self.status_bar.update_label.linkActivated.connect(
            self.update_link_clicked)
Beispiel #14
0
    def __init__(self,
                 gui,
                 msg,
                 size=100,
                 window_title='Marvin XD',
                 show_cancel=False,
                 on_top=False):
        flags = Qt.FramelessWindowHint
        if on_top:
            flags = Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
        QDialog.__init__(self, gui, flags)

        self._layout = QVBoxLayout()
        self.setLayout(self._layout)
        self.cancel_status = 0
        self.is_running = False

        # Add the spinner
        self.pi = ProgressIndicator(self)
        self.pi.setDisplaySize(size)
        self._layout.addSpacing(15)
        self._layout.addWidget(self.pi, 0, Qt.AlignHCenter)
        self._layout.addSpacing(15)

        # Fiddle with the message
        self.msg = QLabel(msg)
        #self.msg.setWordWrap(True)
        self.font = QFont()
        self.font.setPointSize(self.font.pointSize() + 2)
        self.msg.setFont(self.font)
        self._layout.addWidget(self.msg, 0, Qt.AlignHCenter)
        sp = QSizePolicy()
        sp.setHorizontalStretch(True)
        sp.setVerticalStretch(False)
        sp.setHeightForWidth(False)
        self.msg.setSizePolicy(sp)
        self.msg.setMinimumHeight(self.font.pointSize() + 8)

        self._layout.addSpacing(15)

        if show_cancel:
            self.bb = QDialogButtonBox()
            self.cancel_button = QPushButton(QIcon(I('window-close.png')),
                                             'Cancel')
            self.bb.addButton(self.cancel_button, self.bb.RejectRole)
            self.bb.clicked.connect(self.button_handler)
            self._layout.addWidget(self.bb)

        self.setWindowTitle(window_title)
        self.resize(self.sizeHint())
Beispiel #15
0
    def __init__(self, parent, object_name):
        self.parent = parent
        self.prefs = parent.prefs
        self.elements = self.prefs.get('appearance_css', None)
        if not self.elements:
            self.elements = default_elements

        QTableWidget.__init__(self)
        self.setObjectName(object_name)
        self.layout = parent.elements_hl.layout()

        # Add ourselves to the layout
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        #sizePolicy.setVerticalStretch(0)
        #sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        #self.setMaximumSize(QSize(16777215, self.MAXIMUM_TABLE_HEIGHT))

        self.setColumnCount(0)
        self.setRowCount(0)
        self.layout.addWidget(self)
 def __init__(self, parent=None):
     pictureflow.PictureFlow.__init__(
         self, parent, config['cover_flow_queue_length'] + 1)
     self.setMinimumSize(QSize(300, 150))
     self.setFocusPolicy(Qt.WheelFocus)
     self.setSizePolicy(
         QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
     self.dc_signal.connect(self._data_changed,
                            type=Qt.QueuedConnection)
     self.context_menu = None
     self.setContextMenuPolicy(Qt.DefaultContextMenu)
     if hasattr(self, 'setSubtitleFont'):
         self.setSubtitleFont(QFont(rating_font()))
    def __init__(self, parent, object_name):
        self.parent = parent
        self.prefs = parent.prefs
        self.elements = self.prefs.get('appearance_css', None)
        if not self.elements:
            self.elements = default_elements

        QTableWidget.__init__(self)
        self.setObjectName(object_name)
        self.layout = parent.elements_hl.layout()

        # Add ourselves to the layout
        sizePolicy = QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        #sizePolicy.setVerticalStretch(0)
        #sizePolicy.setHeightForWidth(self.sizePolicy().hasHeightForWidth())
        self.setSizePolicy(sizePolicy)
        #self.setMaximumSize(QSize(16777215, self.MAXIMUM_TABLE_HEIGHT))

        self.setColumnCount(0)
        self.setRowCount(0)
        self.layout.addWidget(self)
Beispiel #18
0
 def setupMachinesGUI(self):
     # sorted by value, i.e., ip
     for name, ip in sorted(self.machines.items(), key=ip_keys):
         name64 = b64encode(name)
         l = QLabel(self.ui.dockWidgetState)
         l.setObjectName('state_' + name64)
         sp = QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed)
         sp.setHorizontalStretch(0)
         sp.setVerticalStretch(0)
         sp.setHeightForWidth(l.sizePolicy().hasHeightForWidth())
         l.setSizePolicy(sp)
         l.setPixmap(QPixmap(':/icons/img/icons/25-Red1.png'))
         l.setScaledContents(True)
         self.stateLabels[name] = l
         self.ui.formLayoutState.addRow(ip + ', ' + name + ':', l)
         self.ping.add(name, ip)
Beispiel #19
0
    def __init__(self, parent, title=''):

        QGroupBox.__init__(self)
        if parent:
            self.setParent(parent)  #Fixed bug 2465 -- ninad 20070622

        self.setAutoFillBackground(True)
        self.setPalette(self.getPropMgrGroupBoxPalette())
        self.setStyleSheet(self.getStyleSheet())

        # Create vertical box layout
        self.VBoxLayout = QVBoxLayout(self)
        self.VBoxLayout.setMargin(pmMsgGrpBoxMargin)
        self.VBoxLayout.setSpacing(pmMsgGrpBoxSpacing)

        # Add title button to GroupBox
        self.titleButton = self.getTitleButton(title, self)
        self.VBoxLayout.addWidget(self.titleButton)
        self.connect(self.titleButton, SIGNAL("clicked()"),
                     self.toggleExpandCollapse)

        # Yellow MessageTextEdit
        self.MessageTextEdit = QtGui.QTextEdit(self)
        self.MessageTextEdit.setMaximumHeight(80)  # 80 pixels height
        self.MessageTextEdit.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)
        self.VBoxLayout.addWidget(self.MessageTextEdit)

        msg_palette = self.getMessageTextEditPalette()

        self.MessageTextEdit.setPalette(msg_palette)
        self.MessageTextEdit.setReadOnly(True)

        # wrapWrapMode seems to be set to QTextOption.WrapAnywhere on MacOS,
        # so let's force it here. Mark 2007-05-22.
        self.MessageTextEdit.setWordWrapMode(QTextOption.WordWrap)

        # These two policies very important. Mark 2007-05-22
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.MessageTextEdit.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.setWhatsThis("""<b>Messages</b>
            <p>This prompts the user for a requisite operation and/or displays
            helpful messages to the user.</p>""")

        parent.MessageTextEdit = self.MessageTextEdit

        self.hide()
Beispiel #20
0
 def __init__(self, parent=None):
     pictureflow.PictureFlow.__init__(
         self, parent, config['cover_flow_queue_length'] + 1)
     self.setMinimumSize(QSize(300, 150))
     self.setFocusPolicy(Qt.WheelFocus)
     self.setSizePolicy(
         QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
     self.dc_signal.connect(self._data_changed,
                            type=Qt.QueuedConnection)
     self.context_menu = None
     self.setContextMenuPolicy(Qt.DefaultContextMenu)
     try:
         self.setPreserveAspectRatio(gprefs['cb_preserve_aspect_ratio'])
     except AttributeError:
         pass  # source checkout without updated binary
     if hasattr(self, 'setSubtitleFont'):
         self.setSubtitleFont(QFont(rating_font()))
     if not gprefs['cover_browser_reflections']:
         self.setShowReflections(False)
    def __init__(self, gui, msg, size=100, window_title="Marvin XD", show_cancel=False, on_top=False):
        flags = Qt.FramelessWindowHint
        if on_top:
            flags = Qt.FramelessWindowHint | Qt.WindowStaysOnTopHint
        QDialog.__init__(self, gui, flags)

        self._layout = QVBoxLayout()
        self.setLayout(self._layout)
        self.cancel_status = 0
        self.is_running = False

        # Add the spinner
        self.pi = ProgressIndicator(self)
        self.pi.setDisplaySize(size)
        self._layout.addSpacing(15)
        self._layout.addWidget(self.pi, 0, Qt.AlignHCenter)
        self._layout.addSpacing(15)

        # Fiddle with the message
        self.msg = QLabel(msg)
        # self.msg.setWordWrap(True)
        self.font = QFont()
        self.font.setPointSize(self.font.pointSize() + 2)
        self.msg.setFont(self.font)
        self._layout.addWidget(self.msg, 0, Qt.AlignHCenter)
        sp = QSizePolicy()
        sp.setHorizontalStretch(True)
        sp.setVerticalStretch(False)
        sp.setHeightForWidth(False)
        self.msg.setSizePolicy(sp)
        self.msg.setMinimumHeight(self.font.pointSize() + 8)

        self._layout.addSpacing(15)

        if show_cancel:
            self.bb = QDialogButtonBox()
            self.cancel_button = QPushButton(QIcon(I("window-close.png")), "Cancel")
            self.bb.addButton(self.cancel_button, self.bb.RejectRole)
            self.bb.clicked.connect(self.button_handler)
            self._layout.addWidget(self.bb)

        self.setWindowTitle(window_title)
        self.resize(self.sizeHint())
Beispiel #22
0
    def initialize_view(self, debug_javascript=False):
        self.setRenderHints(QPainter.Antialiasing|QPainter.TextAntialiasing|QPainter.SmoothPixmapTransform)
        self.flipper = SlideFlip(self)
        self.is_auto_repeat_event = False
        self.debug_javascript = debug_javascript
        self.shortcuts =  Shortcuts(SHORTCUTS, 'shortcuts/viewer')
        self.setSizePolicy(QSizePolicy(QSizePolicy.Expanding, QSizePolicy.Expanding))
        self._size_hint = QSize(510, 680)
        self.initial_pos = 0.0
        self.to_bottom = False
        self.document = Document(self.shortcuts, parent=self,
                debug_javascript=debug_javascript)
        self.setPage(self.document)
        self.inspector = WebInspector(self, self.document)
        self.manager = None
        self._reference_mode = False
        self._ignore_scrollbar_signals = False
        self.loading_url = None
        self.loadFinished.connect(self.load_finished)
        self.connect(self.document, SIGNAL('linkClicked(QUrl)'), self.link_clicked)
        self.connect(self.document, SIGNAL('linkHovered(QString,QString,QString)'), self.link_hovered)
        self.connect(self.document, SIGNAL('selectionChanged()'), self.selection_changed)
        self.connect(self.document, SIGNAL('animated_scroll_done()'),
                self.animated_scroll_done, Qt.QueuedConnection)
        self.document.page_turn.connect(self.page_turn_requested)
        copy_action = self.pageAction(self.document.Copy)
        copy_action.setIcon(QIcon(I('convert.png')))
        d = self.document
        self.unimplemented_actions = list(map(self.pageAction,
            [d.DownloadImageToDisk, d.OpenLinkInNewWindow, d.DownloadLinkToDisk,
                d.OpenImageInNewWindow, d.OpenLink, d.Reload, d.InspectElement]))

        self.search_online_action = QAction(QIcon(I('search.png')), '', self)
        self.search_online_action.triggered.connect(self.search_online)
        self.addAction(self.search_online_action)
        self.dictionary_action = QAction(QIcon(I('dictionary.png')),
                _('&Lookup in dictionary'), self)
        self.dictionary_action.triggered.connect(self.lookup)
        self.addAction(self.dictionary_action)
        self.image_popup = ImagePopup(self)
        self.table_popup = TablePopup(self)
        self.view_image_action = QAction(QIcon(I('view-image.png')), _('View &image...'), self)
        self.view_image_action.triggered.connect(self.image_popup)
        self.view_table_action = QAction(QIcon(I('view.png')), _('View &table...'), self)
        self.view_table_action.triggered.connect(self.popup_table)
        self.search_action = QAction(QIcon(I('dictionary.png')),
                _('&Search for next occurrence'), self)
        self.search_action.triggered.connect(self.search_next)
        self.addAction(self.search_action)

        self.goto_location_action = QAction(_('Go to...'), self)
        self.goto_location_menu = m = QMenu(self)
        self.goto_location_actions = a = {
                'Next Page': self.next_page,
                'Previous Page': self.previous_page,
                'Section Top' : partial(self.scroll_to, 0),
                'Document Top': self.goto_document_start,
                'Section Bottom':partial(self.scroll_to, 1),
                'Document Bottom': self.goto_document_end,
                'Next Section': self.goto_next_section,
                'Previous Section': self.goto_previous_section,
        }
        for name, key in [(_('Next Section'), 'Next Section'),
                (_('Previous Section'), 'Previous Section'),
                (None, None),
                (_('Document Start'), 'Document Top'),
                (_('Document End'), 'Document Bottom'),
                (None, None),
                (_('Section Start'), 'Section Top'),
                (_('Section End'), 'Section Bottom'),
                (None, None),
                (_('Next Page'), 'Next Page'),
                (_('Previous Page'), 'Previous Page')]:
            if key is None:
                m.addSeparator()
            else:
                m.addAction(name, a[key], self.shortcuts.get_sequences(key)[0])
        self.goto_location_action.setMenu(self.goto_location_menu)
        self.grabGesture(Qt.SwipeGesture)

        self.restore_fonts_action = QAction(_('Default font size'), self)
        self.restore_fonts_action.setCheckable(True)
        self.restore_fonts_action.triggered.connect(self.restore_font_size)
    def ui_MMKit_GroupBox(self, MMKitDialog):
        #Start MMKit groupbox (includes atom, clipboard and library tabs)
        self.MMKit_groupBox = QtGui.QGroupBox(MMKitDialog)
        self.MMKit_groupBox.setObjectName("MMKit_groupBox")

        self.MMKit_groupBox.setAutoFillBackground(True)
        palette = MMKitDialog.getGroupBoxPalette()
        self.MMKit_groupBox.setPalette(palette)

        styleSheet = MMKitDialog.getGroupBoxStyleSheet()
        self.MMKit_groupBox.setStyleSheet(styleSheet)

        self.MMKitGrpBox_VBoxLayout = QtGui.QVBoxLayout(self.MMKit_groupBox)
        self.MMKitGrpBox_VBoxLayout.setMargin(pmGrpBoxVboxLayoutMargin)
        self.MMKitGrpBox_VBoxLayout.setSpacing(pmGrpBoxVboxLayoutSpacing)
        self.MMKitGrpBox_VBoxLayout.setObjectName("MMKitGrpBox_VBoxLayout")

        self.MMKitGrpBox_TitleButton = MMKitDialog.getGroupBoxTitleButton(
            "MMKit", self.MMKit_groupBox)

        self.MMKitGrpBox_VBoxLayout.addWidget(self.MMKitGrpBox_TitleButton)

        self.mmkit_tab = QtGui.QTabWidget(self.MMKit_groupBox)
        self.mmkit_tab.setEnabled(True)

        # Height is fixed. Mark 2007-05-29.
        self.mmkit_tab.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.mmkit_tab.setObjectName("mmkit_tab")

        self.atomsPage = QtGui.QWidget()
        self.atomsPage.setObjectName("atomsPage")

        self.mmkit_tab.addTab(self.atomsPage, "")

        self.atomsPageFrame = QtGui.QFrame(self.atomsPage)

        # atomsPageFrame needs to be reviewed carefully. Mark 2007-06-20
        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.Policy(3),
                                       QtGui.QSizePolicy.Policy(1))
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(
            self.atomsPageFrame.sizePolicy().hasHeightForWidth())
        self.atomsPageFrame.setSizePolicy(sizePolicy)
        self.atomsPageFrame.setFrameShape(QtGui.QFrame.NoFrame)
        self.atomsPageFrame.setFrameShadow(QtGui.QFrame.Plain)
        self.atomsPageFrame.setMinimumSize(QtCore.QSize(100, 100))
        self.atomsPageFrame.setObjectName("atomsPageFrame")

        self.atomsPage_VBoxLayout = QtGui.QVBoxLayout(self.atomsPageFrame)
        self.atomsPage_VBoxLayout.setMargin(
            pmMMKitPageMargin)  # Was 4. Mark 2007-05-30
        self.atomsPage_VBoxLayout.setSpacing(2)

        # Element Button GroupBox begins here. #####################

        self.elementButtonGroup = QtGui.QGroupBox(self.atomsPageFrame)

        sizePolicy = QtGui.QSizePolicy(QtGui.QSizePolicy.MinimumExpanding,
                                       QtGui.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        self.elementButtonGroup.setSizePolicy(sizePolicy)
        self.elementButtonGroup.setMinimumSize(
            QtCore.QSize(pmMMKitButtonWidth * 4, pmMMKitButtonHeight * 4 + 4))
        self.elementButtonGroup.setObjectName("elementButtonGroup")

        self.MMKit_GridLayout = QtGui.QGridLayout(self.elementButtonGroup)
        self.MMKit_GridLayout.setMargin(1)  # Was 0. Mark 2007-05-30
        self.MMKit_GridLayout.setSpacing(0)
        self.MMKit_GridLayout.setObjectName("MMKit_GridLayout")

        # Font for toolbuttons.
        font = QFont(self.atomsPageFrame.font())
        font.setFamily(pmMMKitButtonFont)
        font.setPointSize(pmMMKitButtonFontPointSize)
        font.setBold(pmMMKitButtonFontBold)
        #font.setWeight(75)
        #font.setItalic(False)
        #font.setUnderline(False)
        #font.setStrikeOut(False)

        # All this would be much nicer using a dictionary in a loop.
        # Later, when time permits. Mark 2007-05-30.

        self.toolButton1 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton1.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton1.setCheckable(True)
        self.toolButton1.setFont(font)
        self.toolButton1.setObjectName("toolButton1")
        self.MMKit_GridLayout.addWidget(self.toolButton1, 0, 4, 1, 1)

        self.toolButton2 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton2.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton2.setCheckable(True)
        self.toolButton2.setFont(font)
        self.toolButton2.setObjectName("toolButton2")
        self.MMKit_GridLayout.addWidget(self.toolButton2, 0, 5, 1, 1)

        self.toolButton6 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton6.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton6.setCheckable(True)
        self.toolButton6.setFont(font)
        self.toolButton6.setObjectName("toolButton6")
        self.MMKit_GridLayout.addWidget(self.toolButton6, 1, 1, 1, 1)

        self.toolButton7 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton7.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton7.setCheckable(True)
        self.toolButton7.setFont(font)
        self.toolButton7.setObjectName("toolButton7")
        self.MMKit_GridLayout.addWidget(self.toolButton7, 1, 2, 1, 1)

        self.toolButton8 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton8.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton8.setCheckable(True)
        self.toolButton8.setFont(font)
        self.toolButton8.setObjectName("toolButton8")
        self.MMKit_GridLayout.addWidget(self.toolButton8, 1, 3, 1, 1)

        self.toolButton10 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton10.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton10.setCheckable(True)
        self.toolButton10.setFont(font)
        self.toolButton10.setObjectName("toolButton10")
        self.MMKit_GridLayout.addWidget(self.toolButton10, 1, 5, 1, 1)

        self.toolButton9 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton9.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton9.setCheckable(True)
        self.toolButton9.setFont(font)
        self.toolButton9.setObjectName("toolButton9")
        self.MMKit_GridLayout.addWidget(self.toolButton9, 1, 4, 1, 1)

        self.toolButton13 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton13.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton13.setCheckable(True)
        self.toolButton13.setFont(font)
        self.toolButton13.setObjectName("toolButton13")
        self.MMKit_GridLayout.addWidget(self.toolButton13, 2, 0, 1, 1)

        self.toolButton17 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton17.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton17.setCheckable(True)
        self.toolButton17.setFont(font)
        self.toolButton17.setObjectName("toolButton17")
        self.MMKit_GridLayout.addWidget(self.toolButton17, 2, 4, 1, 1)

        self.toolButton5 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton5.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton5.setCheckable(True)
        self.toolButton5.setFont(font)
        self.toolButton5.setObjectName("toolButton5")
        self.MMKit_GridLayout.addWidget(self.toolButton5, 1, 0, 1, 1)

        self.toolButton10_2 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton10_2.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton10_2.setCheckable(True)
        self.toolButton10_2.setFont(font)
        self.toolButton10_2.setObjectName("toolButton10_2")
        self.MMKit_GridLayout.addWidget(self.toolButton10_2, 2, 5, 1, 1)

        self.toolButton15 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton15.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton15.setCheckable(True)
        self.toolButton15.setFont(font)
        self.toolButton15.setObjectName("toolButton15")
        self.MMKit_GridLayout.addWidget(self.toolButton15, 2, 2, 1, 1)

        self.toolButton16 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton16.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton16.setCheckable(True)
        self.toolButton16.setFont(font)
        self.toolButton16.setObjectName("toolButton16")
        self.MMKit_GridLayout.addWidget(self.toolButton16, 2, 3, 1, 1)

        self.toolButton14 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton14.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton14.setCheckable(True)
        self.toolButton14.setFont(font)
        self.toolButton14.setObjectName("toolButton14")
        self.MMKit_GridLayout.addWidget(self.toolButton14, 2, 1, 1, 1)

        self.toolButton33 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton33.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton33.setCheckable(True)
        self.toolButton33.setFont(font)
        self.toolButton33.setObjectName("toolButton33")
        self.MMKit_GridLayout.addWidget(self.toolButton33, 3, 2, 1, 1)

        self.toolButton34 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton34.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton34.setCheckable(True)
        self.toolButton34.setFont(font)
        self.toolButton34.setObjectName("toolButton34")
        self.MMKit_GridLayout.addWidget(self.toolButton34, 3, 3, 1, 1)

        self.toolButton35 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton35.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton35.setCheckable(True)
        self.toolButton35.setFont(font)
        self.toolButton35.setObjectName("toolButton35")
        self.MMKit_GridLayout.addWidget(self.toolButton35, 3, 4, 1, 1)

        self.toolButton32 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton32.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton32.setCheckable(True)
        self.toolButton32.setFont(font)
        self.toolButton32.setObjectName("toolButton32")
        self.MMKit_GridLayout.addWidget(self.toolButton32, 3, 1, 1, 1)

        self.toolButton36 = QtGui.QToolButton(self.elementButtonGroup)
        self.toolButton36.setFixedSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.toolButton36.setCheckable(True)
        self.toolButton36.setFont(font)
        self.toolButton36.setObjectName("toolButton36")
        self.MMKit_GridLayout.addWidget(self.toolButton36, 3, 5, 1, 1)

        self.atomsPage_VBoxLayout.addWidget(self.elementButtonGroup)

        # Height is fixed (i.e. locked). Mark 2007-05-29.
        self.elementButtonGroup.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        # Atomic Hybrid label
        self.atomic_hybrids_label = QtGui.QLabel(self.atomsPageFrame)
        self.atomic_hybrids_label.setText("Atomic Hybrids :")
        self.atomsPage_VBoxLayout.addWidget(self.atomic_hybrids_label)

        # Elements Button GroupBox ends here. #######################

        # This special HBoxLayout contains both the hybrid button group and a
        # vert spacer (width = 0) to keep the Qt layout working properly
        # in certain situations like that described in bug 2407.
        # Mark 2007-06-20.
        self.special_HBoxLayout = QtGui.QHBoxLayout()
        self.special_HBoxLayout.setMargin(0)
        self.special_HBoxLayout.setSpacing(6)
        self.special_HBoxLayout.setObjectName("special_HBoxLayout")
        self.atomsPage_VBoxLayout.addLayout(self.special_HBoxLayout)

        # Hybrid GroupBox begins here ###############################

        self.hybrid_btngrp = QtGui.QGroupBox(self.atomsPageFrame)
        self.hybrid_btngrp.setObjectName("hybrid_btngrp")
        self.special_HBoxLayout.addWidget(self.hybrid_btngrp)

        self.hybridBtns_HBoxLayout = QtGui.QHBoxLayout(self.hybrid_btngrp)
        self.hybridBtns_HBoxLayout.setMargin(2)
        self.hybridBtns_HBoxLayout.setSpacing(0)
        self.hybridBtns_HBoxLayout.setObjectName("hybridBtns_HBoxLayout")

        self.sp3_btn = QtGui.QToolButton(self.hybrid_btngrp)
        self.sp3_btn.setMinimumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.sp3_btn.setMaximumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.sp3_btn.setCheckable(True)
        self.sp3_btn.setObjectName("sp3_btn")
        self.hybridBtns_HBoxLayout.addWidget(self.sp3_btn)

        self.sp2_btn = QtGui.QToolButton(self.hybrid_btngrp)
        self.sp2_btn.setMinimumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.sp2_btn.setMaximumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.sp2_btn.setCheckable(True)
        self.sp2_btn.setObjectName("sp2_btn")
        self.hybridBtns_HBoxLayout.addWidget(self.sp2_btn)

        self.sp_btn = QtGui.QToolButton(self.hybrid_btngrp)
        self.sp_btn.setMinimumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.sp_btn.setMaximumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.sp_btn.setCheckable(True)
        self.sp_btn.setObjectName("sp_btn")
        self.hybridBtns_HBoxLayout.addWidget(self.sp_btn)

        self.graphitic_btn = QtGui.QToolButton(self.hybrid_btngrp)
        self.graphitic_btn.setMinimumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.graphitic_btn.setMaximumSize(
            QtCore.QSize(pmMMKitButtonWidth, pmMMKitButtonHeight))
        self.graphitic_btn.setCheckable(True)
        self.graphitic_btn.setObjectName("graphitic_btn")
        self.hybridBtns_HBoxLayout.addWidget(self.graphitic_btn)

        # This VSpacer is needed to help (but not completely) fix bug 2407. It
        # maintains the height of the layout(s) containing the hybrid button
        # group when it is hidden using hide(). Without this spacer the layout
        # gets screwed up in special situations like that described in bug 2407.
        # The + 10 below is needed to account for the margin (4 pixels) and
        # the additional 6 just help (I have a theory that the height of the
        # frame containing the label above the hybrid group box shrinks when
        # the label is hidden by inserting a space character). I'm
        # not going to worry about this now. +10 works well enough.
        # Mark 2007-06-20.
        VSpacer = QtGui.QSpacerItem(0, pmMMKitButtonHeight + 10,
                                    QtGui.QSizePolicy.Fixed,
                                    QtGui.QSizePolicy.Fixed)
        #self.hybridBtns_HBoxLayout.addItem(VSpacer)
        self.special_HBoxLayout.addItem(VSpacer)

        self.hybridBtns_HBoxLayout.addStretch(0)

        # Height is fixed. Mark 2007-05-29.
        self.hybrid_btngrp.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        # This spacer keeps the MMKit button grid compressed when
        # the hybrid button group is hidden.
        self.atomsPageBottomVSpacer = \
            QtGui.QSpacerItem(5, 0,
                              QtGui.QSizePolicy.Fixed,
                              QtGui.QSizePolicy.MinimumExpanding)

        self.atomsPage_VBoxLayout.addItem(self.atomsPageBottomVSpacer)

        # Clipboard page begins here ############################################

        self.clipboardPage = QtGui.QWidget()
        self.clipboardPage.setObjectName("clipboardPage")

        self.gridlayout3 = QtGui.QGridLayout(self.clipboardPage)
        self.gridlayout3.setMargin(pmMMKitPageMargin)  # Was 4. Mark 2007-05-30
        self.gridlayout3.setSpacing(2)
        self.gridlayout3.setObjectName("gridlayout3")

        self.chunkListBox = QtGui.QListWidget(self.clipboardPage)

        self.chunkListBox.setMinimumSize(QtCore.QSize(100, 100))

        # Height is fixed. Mark 2007-05-29.
        self.chunkListBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.chunkListBox.setObjectName("chunkListBox")
        self.gridlayout3.addWidget(self.chunkListBox, 0, 0, 1, 1)
        self.mmkit_tab.addTab(self.clipboardPage, "")

        self.libraryPage = QtGui.QWidget()
        #self.libraryPage = QtGui.QScrollArea()
        #self.libraryPageWidget = QtGui.QWidget()
        #self.libraryPage.setWidget(self.libraryPageWidget)
        self.libraryPage.setObjectName("libraryPage")
        self.mmkit_tab.addTab(self.libraryPage, "")

        self.MMKitGrpBox_VBoxLayout.addWidget(self.mmkit_tab)

        self.transmuteAtomsAction = QtGui.QWidgetAction(self.w)
        self.transmuteAtomsAction.setText("Transmute Atoms")
        self.transmuteAtomsAction.setIcon(
            geticon('ui/actions/Toolbars/Smart/Transmute_Atoms'))
        self.transmuteAtomsAction.setCheckable(False)

        transmuteBtn_HBoxLayout = QtGui.QHBoxLayout()

        self.transmuteBtn = QtGui.QToolButton(self.MMKit_groupBox)
        self.transmuteBtn.setDefaultAction(self.transmuteAtomsAction)
        self.transmuteBtn.setFixedSize(QtCore.QSize(36, 36))
        self.transmuteBtn.setIconSize(QtCore.QSize(22, 22))
        transmuteBtn_HBoxLayout.addWidget(self.transmuteBtn)

        self.browseButton = QtGui.QPushButton(MMKitDialog)
        transmuteBtn_HBoxLayout.addWidget(self.browseButton)

        self.defaultPartLibButton = QtGui.QPushButton(MMKitDialog)
        transmuteBtn_HBoxLayout.addWidget(self.defaultPartLibButton)

        self.atomsPageSpacer = QtGui.QSpacerItem(0, 5,
                                                 QtGui.QSizePolicy.Expanding,
                                                 QtGui.QSizePolicy.Minimum)

        transmuteBtn_HBoxLayout.addItem(self.atomsPageSpacer)

        self.MMKitGrpBox_VBoxLayout.addLayout(transmuteBtn_HBoxLayout)

        self.transmuteCB = QtGui.QCheckBox(" Force to Keep Bonds",
                                           self.MMKit_groupBox)

        self.MMKitGrpBox_VBoxLayout.addWidget(self.transmuteCB)

        #End MMKit groupbox
        self.pmVBoxLayout.addWidget(self.MMKit_groupBox)

        # This line is important. Without it, the MMKit groupbox is
        # too wide by default and causes a horizontal scrollbar
        # to be displayed at the bottom of the PropMgr. Mark 2007-05-30
        self.MMKit_groupBox.setMinimumWidth(200)

        # Height is fixed. Mark 2007-05-29.
        self.MMKit_groupBox.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.MinimumExpanding),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))
Beispiel #24
0
    def do_layout(self):
        self.central_widget.clear()
        self.labels = []
        sto = QWidget.setTabOrder

        self.central_widget.tabBar().setVisible(False)
        tab0 = QWidget(self)
        self.central_widget.addTab(tab0, _("&Metadata"))
        l = QGridLayout()
        tab0.setLayout(l)

        # Basic metadata in col 0
        tl = QGridLayout()
        gb = QGroupBox(_('Basic metadata'), tab0)
        l.addWidget(gb, 0, 0, 1, 1)
        gb.setLayout(tl)

        self.button_box_layout.insertWidget(1, self.fetch_metadata_button)
        self.button_box_layout.insertWidget(2, self.config_metadata_button)
        sto(self.button_box, self.fetch_metadata_button)
        sto(self.fetch_metadata_button, self.config_metadata_button)
        sto(self.config_metadata_button, self.title)

        def create_row(row, widget, tab_to, button=None, icon=None, span=1):
            ql = BuddyLabel(widget)
            tl.addWidget(ql, row, 1, 1, 1)
            tl.addWidget(widget, row, 2, 1, 1)
            if button is not None:
                tl.addWidget(button, row, 3, span, 1)
                if icon is not None:
                    button.setIcon(QIcon(I(icon)))
            if tab_to is not None:
                if button is not None:
                    sto(widget, button)
                    sto(button, tab_to)
                else:
                    sto(widget, tab_to)

        tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1)
        tl.addWidget(self.manage_authors_button, 2, 0, 2, 1)
        tl.addWidget(self.paste_isbn_button, 12, 0, 1, 1)
        tl.addWidget(self.tags_editor_button, 6, 0, 1, 1)

        create_row(0, self.title, self.title_sort,
                   button=self.deduce_title_sort_button, span=2,
                   icon='auto_author_sort.png')
        create_row(1, self.title_sort, self.authors)
        create_row(2, self.authors, self.author_sort,
                   button=self.deduce_author_sort_button,
                   span=2, icon='auto_author_sort.png')
        create_row(3, self.author_sort, self.series)
        create_row(4, self.series, self.series_index,
                   button=self.clear_series_button, icon='trash.png')
        create_row(5, self.series_index, self.tags)
        create_row(6, self.tags, self.rating, button=self.clear_tags_button)
        create_row(7, self.rating, self.pubdate, button=self.clear_ratings_button)
        create_row(8, self.pubdate, self.publisher,
                   button=self.pubdate.clear_button, icon='trash.png')
        create_row(9, self.publisher, self.languages)
        create_row(10, self.languages, self.timestamp)
        create_row(11, self.timestamp, self.identifiers,
                   button=self.timestamp.clear_button, icon='trash.png')
        create_row(12, self.identifiers, self.comments,
                   button=self.clear_identifiers_button, icon='trash.png')
        sto(self.clear_identifiers_button, self.swap_title_author_button)
        sto(self.swap_title_author_button, self.manage_authors_button)
        sto(self.manage_authors_button, self.tags_editor_button)
        sto(self.tags_editor_button, self.paste_isbn_button)
        tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding),
                   13, 1, 1 ,1)

        # Custom metadata in col 1
        w = getattr(self, 'custom_metadata_widgets_parent', None)
        if w is not None:
            gb = QGroupBox(_('Custom metadata'), tab0)
            gbl = QVBoxLayout()
            gb.setLayout(gbl)
            sr = QScrollArea(gb)
            sr.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
            sr.setWidgetResizable(True)
            sr.setFrameStyle(QFrame.NoFrame)
            sr.setWidget(w)
            gbl.addWidget(sr)
            l.addWidget(gb, 0, 1, 1, 1)
            sp = QSizePolicy()
            sp.setVerticalStretch(10)
            sp.setHorizontalPolicy(QSizePolicy.Minimum)
            sp.setVerticalPolicy(QSizePolicy.Expanding)
            gb.setSizePolicy(sp)
            self.set_custom_metadata_tab_order()

        # comments span col 0 & 1
        w = QGroupBox(_('Comments'), tab0)
        sp = QSizePolicy()
        sp.setVerticalStretch(10)
        sp.setHorizontalPolicy(QSizePolicy.Expanding)
        sp.setVerticalPolicy(QSizePolicy.Expanding)
        w.setSizePolicy(sp)
        lb = QHBoxLayout()
        w.setLayout(lb)
        lb.addWidget(self.comments)
        l.addWidget(w, 1, 0, 1, 2)

        # Cover & formats in col 3
        gb = QGroupBox(_('Cover'), tab0)
        lb = QGridLayout()
        gb.setLayout(lb)
        lb.addWidget(self.cover, 0, 0, 1, 3, alignment=Qt.AlignCenter)
        sto(self.manage_authors_button, self.cover.buttons[0])
        for i, b in enumerate(self.cover.buttons[:3]):
            lb.addWidget(b, 1, i, 1, 1)
            sto(b, self.cover.buttons[i+1])
        hl = QHBoxLayout()
        for b in self.cover.buttons[3:]:
            hl.addWidget(b)
        sto(self.cover.buttons[-2], self.cover.buttons[-1])
        lb.addLayout(hl, 2, 0, 1, 3)
        l.addWidget(gb, 0, 2, 1, 1)
        l.addWidget(self.formats_manager, 1, 2, 1, 1)
        sto(self.cover.buttons[-1], self.formats_manager)

        self.formats_manager.formats.setMaximumWidth(10000)
        self.formats_manager.formats.setIconSize(QSize(32, 32))
Beispiel #25
0
    def do_layout(self):
        self.central_widget.clear()
        self.tabs = []
        self.labels = []
        sto = QWidget.setTabOrder

        self.on_drag_enter.connect(self.handle_drag_enter)
        self.tabs.append(DragTrackingWidget(self, self.on_drag_enter))
        self.central_widget.addTab(self.tabs[0], _("&Metadata"))
        self.tabs[0].l = QGridLayout()
        self.tabs[0].setLayout(self.tabs[0].l)

        self.tabs.append(QWidget(self))
        self.central_widget.addTab(self.tabs[1], _("&Cover and formats"))
        self.tabs[1].l = QGridLayout()
        self.tabs[1].setLayout(self.tabs[1].l)

        # accept drop events so we can automatically switch to the second tab to
        # drop covers and formats
        self.tabs[0].setAcceptDrops(True)

        # Tab 0
        tab0 = self.tabs[0]

        tl = QGridLayout()
        gb = QGroupBox(_('&Basic metadata'), self.tabs[0])
        self.tabs[0].l.addWidget(gb, 0, 0, 1, 1)
        gb.setLayout(tl)

        self.button_box_layout.insertWidget(1, self.fetch_metadata_button)
        self.button_box_layout.insertWidget(2, self.config_metadata_button)
        sto(self.button_box, self.fetch_metadata_button)
        sto(self.fetch_metadata_button, self.config_metadata_button)
        sto(self.config_metadata_button, self.title)

        def create_row(row, widget, tab_to, button=None, icon=None, span=1):
            ql = BuddyLabel(widget)
            tl.addWidget(ql, row, 1, 1, 1)
            tl.addWidget(widget, row, 2, 1, 1)
            if button is not None:
                tl.addWidget(button, row, 3, span, 1)
                if icon is not None:
                    button.setIcon(QIcon(I(icon)))
            if tab_to is not None:
                if button is not None:
                    sto(widget, button)
                    sto(button, tab_to)
                else:
                    sto(widget, tab_to)

        tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1)
        tl.addWidget(self.manage_authors_button, 2, 0, 1, 1)
        tl.addWidget(self.paste_isbn_button, 12, 0, 1, 1)
        tl.addWidget(self.tags_editor_button, 6, 0, 1, 1)

        create_row(0, self.title, self.title_sort,
                   button=self.deduce_title_sort_button, span=2,
                   icon='auto_author_sort.png')
        create_row(1, self.title_sort, self.authors)
        create_row(2, self.authors, self.author_sort,
                   button=self.deduce_author_sort_button,
                   span=2, icon='auto_author_sort.png')
        create_row(3, self.author_sort, self.series)
        create_row(4, self.series, self.series_index,
                   button=self.clear_series_button, icon='trash.png')
        create_row(5, self.series_index, self.tags)
        create_row(6, self.tags, self.rating, button=self.clear_tags_button)
        create_row(7, self.rating, self.pubdate, button=self.clear_ratings_button)
        create_row(8, self.pubdate, self.publisher,
                   button=self.pubdate.clear_button, icon='trash.png')
        create_row(9, self.publisher, self.languages)
        create_row(10, self.languages, self.timestamp)
        create_row(11, self.timestamp, self.identifiers,
                   button=self.timestamp.clear_button, icon='trash.png')
        create_row(12, self.identifiers, self.comments,
                   button=self.clear_identifiers_button, icon='trash.png')
        sto(self.clear_identifiers_button, self.swap_title_author_button)
        sto(self.swap_title_author_button, self.manage_authors_button)
        sto(self.manage_authors_button, self.tags_editor_button)
        sto(self.tags_editor_button, self.paste_isbn_button)
        tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding),
                   13, 1, 1 ,1)

        w = getattr(self, 'custom_metadata_widgets_parent', None)
        if w is not None:
            gb = QGroupBox(_('C&ustom metadata'), tab0)
            gbl = QVBoxLayout()
            gb.setLayout(gbl)
            sr = QScrollArea(tab0)
            sr.setWidgetResizable(True)
            sr.setFrameStyle(QFrame.NoFrame)
            sr.setWidget(w)
            gbl.addWidget(sr)
            self.tabs[0].l.addWidget(gb, 0, 1, 1, 1)
            sto(self.identifiers, gb)

        w = QGroupBox(_('&Comments'), tab0)
        sp = QSizePolicy()
        sp.setVerticalStretch(10)
        sp.setHorizontalPolicy(QSizePolicy.Expanding)
        sp.setVerticalPolicy(QSizePolicy.Expanding)
        w.setSizePolicy(sp)
        l = QHBoxLayout()
        w.setLayout(l)
        l.addWidget(self.comments)
        tab0.l.addWidget(w, 1, 0, 1, 2)

        # Tab 1
        tab1 = self.tabs[1]

        wsp = QWidget(tab1)
        wgl = QVBoxLayout()
        wsp.setLayout(wgl)

        # right-hand side of splitter
        gb = QGroupBox(_('Change cover'), tab1)
        l = QGridLayout()
        gb.setLayout(l)
        for i, b in enumerate(self.cover.buttons[:3]):
            l.addWidget(b, 0, i, 1, 1)
            sto(b, self.cover.buttons[i+1])
        hl = QHBoxLayout()
        for b in self.cover.buttons[3:]:
            hl.addWidget(b)
        sto(self.cover.buttons[-2], self.cover.buttons[-1])
        l.addLayout(hl, 1, 0, 1, 3)
        wgl.addWidget(gb)
        wgl.addItem(QSpacerItem(10, 10, QSizePolicy.Expanding,
            QSizePolicy.Expanding))
        wgl.addItem(QSpacerItem(10, 10, QSizePolicy.Expanding,
            QSizePolicy.Expanding))
        wgl.addWidget(self.formats_manager)

        self.splitter = QSplitter(Qt.Horizontal, tab1)
        tab1.l.addWidget(self.splitter)
        self.splitter.addWidget(self.cover)
        self.splitter.addWidget(wsp)

        self.formats_manager.formats.setMaximumWidth(10000)
        self.formats_manager.formats.setIconSize(QSize(64, 64))
 def __init__(self, 
              parentWidget, 
              title          = '', 
              connectTitleButton = True,
              setAsDefault   = True
              ):
     """
     Appends a PM_GroupBox widget to I{parentWidget}, a L{PM_Dialog} or a 
     L{PM_GroupBox}.
     
     If I{parentWidget} is a L{PM_Dialog}, the group box will have a title 
     button at the top for collapsing and expanding the group box. If 
     I{parentWidget} is a PM_GroupBox, the title will simply be a text 
     label at the top of the group box.
     
     @param parentWidget: The parent dialog or group box containing this
                          widget.
     @type  parentWidget: L{PM_Dialog} or L{PM_GroupBox}
     
     @param title: The title (button) text. If empty, no title is added.
     @type  title: str
     
     @param connectTitleButton: If True, this class will automatically 
                   connect the title button of the groupbox to send signal
                   to expand or collapse the groupbox. Otherwise, the caller
                   has to connect this signal by itself. See:
                   B{Ui_MovePropertyManager.addGroupBoxes} and 
                   B{MovePropertyManager.connect_or_disconnect_signals} for
                   examples where the client connects this slot. 
     @type  connectTitleButton: bool
            
     
     @param setAsDefault: If False, no widgets in this group box will have 
                          thier default values restored when the B{Restore 
                          Defaults} button is clicked, regardless thier own 
                          I{setAsDefault} value.
     @type  setAsDefault: bool
     
     @see: U{B{QGroupBox}<http://doc.trolltech.com/4/qgroupbox.html>}
     """
   
     QGroupBox.__init__(self)
     
     self.parentWidget = parentWidget
     
     # Calling addWidget() here is important. If done at the end,
     # the title button does not get assigned its palette for some 
     # unknown reason. Mark 2007-05-20.
     # Add self to PropMgr's vBoxLayout
     if parentWidget:
         parentWidget._groupBoxCount += 1
         parentWidget.vBoxLayout.addWidget(self)
         parentWidget._widgetList.append(self)
         
     _groupBoxCount = 0
     self._widgetList = []
     self._title = title
     self.setAsDefault = setAsDefault
     
     self.setAutoFillBackground(True)
     self.setStyleSheet(self._getStyleSheet())
     
     # Create vertical box layout which will contain two widgets:
     # - the group box title button (or title) on row 0.
     # - the container widget for all PM widgets on row 1.
     self._vBoxLayout = QVBoxLayout(self)
     self._vBoxLayout.setMargin(0)
     self._vBoxLayout.setSpacing(0)
     
     # _containerWidget contains all PM widgets in this group box.
     # Its sole purpose is to easily support the collapsing and
     # expanding of a group box by calling this widget's hide()
     # and show() methods.
     self._containerWidget = QWidget()
     
     self._vBoxLayout.insertWidget(0, self._containerWidget)
     
     # Create vertical box layout
     self.vBoxLayout = QVBoxLayout(self._containerWidget)
     self.vBoxLayout.setMargin(PM_GROUPBOX_VBOXLAYOUT_MARGIN)
     self.vBoxLayout.setSpacing(PM_GROUPBOX_VBOXLAYOUT_SPACING)
     
     # Create grid layout
     self.gridLayout = QGridLayout()
     self.gridLayout.setMargin(PM_GRIDLAYOUT_MARGIN)
     self.gridLayout.setSpacing(PM_GRIDLAYOUT_SPACING)
     
     # Insert grid layout in its own vBoxLayout
     self.vBoxLayout.addLayout(self.gridLayout)
     
     # Add title button (or just a title if the parent is not a PM_Dialog).
     if not parentWidget or isinstance(parentWidget, PM_GroupBox):
         self.setTitle(title)
     else: # Parent is a PM_Dialog, so add a title button.
         if not self.titleButtonRequested:
             self.setTitle(title)
         else:
             self.titleButton = self._getTitleButton(self, title)
             self._vBoxLayout.insertWidget(0, self.titleButton)
             if connectTitleButton:
                 self.connect( self.titleButton, 
                               SIGNAL("clicked()"),
                               self.toggleExpandCollapse)
             self._insertMacSpacer()
         
     # Fixes the height of the group box. Very important. Mark 2007-05-29
     self.setSizePolicy(
         QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                     QSizePolicy.Policy(QSizePolicy.Fixed)))
     
     self._addBottomSpacer()
     return
Beispiel #27
0
    def __init__(self,
                 parent=None,
                 desc=None,
                 name=None,
                 modal=0,
                 fl=0,
                 env=None,
                 type="QDialog"):
        if env is None:
            import foundation.env as env  # this is a little weird... probably it'll be ok, and logically it seems correct.

        self.desc = desc

        self.typ = type
        if type == "QDialog":
            QDialog.__init__(self, parent, name, modal, fl)
        elif type == "QTextEdit":
            QTextEdit.__init__(self, parent, name)
        elif type == "QFrame":
            QFrame.__init__(self, parent, name)
        else:
            print "don't know about type == %r" % (type, )

        self.image1 = QPixmap()
        self.image1.loadFromData(image1_data,
                                 "PNG")  # should be: title_icon ####
        self.image3 = QPixmap()
        self.image3.loadFromData(image3_data, "PNG")
        self.image4 = QPixmap()
        self.image4.loadFromData(image4_data, "PNG")
        self.image5 = QPixmap()
        self.image5.loadFromData(image5_data, "PNG")
        self.image6 = QPixmap()
        self.image6.loadFromData(image6_data, "PNG")
        self.image7 = QPixmap()
        self.image7.loadFromData(image7_data, "PNG")
        self.image0 = QPixmap(image0_data)  # should be: border_icon ####
        self.image2 = QPixmap(image2_data)  # should be: sponsor_pixmap ####

        try:
            ####@@@@
            title_icon_name = self.desc.options.get('title_icon')
            border_icon_name = self.desc.options.get('border_icon')
            if title_icon_name:
                self.image1 = imagename_to_pixmap(
                    title_icon_name)  ###@@@ pass icon_path
                ###@@@ import imagename_to_pixmap or use env function
                # or let that func itself be an arg, or have an env arg for it
                ###e rename it icon_name_to_pixmap, or find_icon? (the latter only if it's ok if it returns an iconset)
                ###e use iconset instead?
            if border_icon_name:
                self.image0 = imagename_to_pixmap(border_icon_name)
        except:
            print_compact_traceback(
                "bug in icon-setting code, using fallback icons: ")
            pass

        if not name:
            self.setName("parameter_dialog_or_frame")  ###

        ###k guess this will need: if type == 'QDialog'
        self.setIcon(self.image0)  # should be: border_icon ####

        nanotube_dialogLayout = QVBoxLayout(self, 0, 0,
                                            "nanotube_dialogLayout")

        self.heading_frame = QFrame(self, "heading_frame")
        self.heading_frame.setPaletteBackgroundColor(QColor(122, 122, 122))
        self.heading_frame.setFrameShape(QFrame.NoFrame)
        self.heading_frame.setFrameShadow(QFrame.Plain)
        heading_frameLayout = QHBoxLayout(self.heading_frame, 0, 3,
                                          "heading_frameLayout")

        self.heading_pixmap = QLabel(self.heading_frame, "heading_pixmap")
        self.heading_pixmap.setSizePolicy(
            QSizePolicy(QSizePolicy.Fixed, QSizePolicy.Fixed, 0, 0,
                        self.heading_pixmap.sizePolicy().hasHeightForWidth()))
        self.heading_pixmap.setPixmap(
            self.image1)  # should be: title_icon ####
        self.heading_pixmap.setScaledContents(1)
        heading_frameLayout.addWidget(self.heading_pixmap)

        self.heading_label = QLabel(self.heading_frame, "heading_label")
        self.heading_label.setPaletteForegroundColor(QColor(255, 255, 255))
        heading_label_font = QFont(self.heading_label.font())
        heading_label_font.setPointSize(12)
        heading_label_font.setBold(1)
        self.heading_label.setFont(heading_label_font)
        heading_frameLayout.addWidget(self.heading_label)
        nanotube_dialogLayout.addWidget(self.heading_frame)

        self.body_frame = QFrame(self, "body_frame")
        self.body_frame.setFrameShape(QFrame.StyledPanel)
        self.body_frame.setFrameShadow(QFrame.Raised)
        body_frameLayout = QVBoxLayout(self.body_frame, 3, 3,
                                       "body_frameLayout")

        self.sponsor_frame = QFrame(self.body_frame, "sponsor_frame")
        self.sponsor_frame.setPaletteBackgroundColor(QColor(255, 255, 255))
        self.sponsor_frame.setFrameShape(QFrame.StyledPanel)
        self.sponsor_frame.setFrameShadow(QFrame.Raised)
        sponsor_frameLayout = QHBoxLayout(self.sponsor_frame, 0, 0,
                                          "sponsor_frameLayout")

        self.sponsor_btn = QPushButton(self.sponsor_frame, "sponsor_btn")
        self.sponsor_btn.setAutoDefault(0)  #bruce 060703 bugfix
        self.sponsor_btn.setSizePolicy(
            QSizePolicy(QSizePolicy.Preferred, QSizePolicy.Preferred, 0, 0,
                        self.sponsor_btn.sizePolicy().hasHeightForWidth()))
        self.sponsor_btn.setPaletteBackgroundColor(QColor(255, 255, 255))
        self.sponsor_btn.setPixmap(
            self.image2
        )  # should be: sponsor_pixmap #### [also we'll need to support >1 sponsor]
        self.sponsor_btn.setFlat(1)
        sponsor_frameLayout.addWidget(self.sponsor_btn)
        body_frameLayout.addWidget(self.sponsor_frame)

        layout59 = QHBoxLayout(None, 0, 6, "layout59")
        left_spacer = QSpacerItem(20, 20, QSizePolicy.Expanding,
                                  QSizePolicy.Minimum)
        layout59.addItem(left_spacer)

        self.done_btn = QToolButton(self.body_frame, "done_btn")
        self.done_btn.setIcon(QIcon(self.image3))
        layout59.addWidget(self.done_btn)

        self.abort_btn = QToolButton(self.body_frame, "abort_btn")
        self.abort_btn.setIcon(QIcon(self.image4))
        layout59.addWidget(self.abort_btn)

        self.preview_btn = QToolButton(self.body_frame, "preview_btn")
        self.preview_btn.setIcon(QIcon(self.image5))
        layout59.addWidget(self.preview_btn)

        self.whatsthis_btn = QToolButton(self.body_frame, "whatsthis_btn")
        self.whatsthis_btn.setIcon(QIcon(self.image6))
        layout59.addWidget(self.whatsthis_btn)
        right_spacer = QSpacerItem(20, 20, QSizePolicy.Expanding,
                                   QSizePolicy.Minimum)
        layout59.addItem(right_spacer)
        body_frameLayout.addLayout(layout59)

        self.groups = []
        self.param_getters = {
        }  # map from param name to get-function (which gets current value out of its widget or controller)

        for group_desc in self.desc.kids('group'):

            # == start parameters_grpbox ### this will differ for Windows style

            header_refs = [
            ]  # keep python refcounted refs to all objects we make (at least the ones pyuic stored in self attrs)

            self.parameters_grpbox = QGroupBox(self.body_frame,
                                               "parameters_grpbox")
            self.parameters_grpbox.setFrameShape(QGroupBox.StyledPanel)
            self.parameters_grpbox.setFrameShadow(QGroupBox.Sunken)
            self.parameters_grpbox.setMargin(0)
            self.parameters_grpbox.setColumnLayout(0, Qt.Vertical)
            self.parameters_grpbox.layout().setSpacing(1)
            self.parameters_grpbox.layout().setMargin(4)
            parameters_grpboxLayout = QVBoxLayout(
                self.parameters_grpbox.layout())
            parameters_grpboxLayout.setAlignment(Qt.AlignTop)

            layout20 = QHBoxLayout(None, 0, 6, "layout20")

            self.nt_parameters_grpbtn = QPushButton(self.parameters_grpbox,
                                                    "nt_parameters_grpbtn")
            self.nt_parameters_grpbtn.setSizePolicy(
                QSizePolicy(
                    QSizePolicy.Minimum, QSizePolicy.Fixed, 0, 0,
                    self.nt_parameters_grpbtn.sizePolicy().hasHeightForWidth())
            )
            self.nt_parameters_grpbtn.setMaximumSize(QSize(16, 16))
            self.nt_parameters_grpbtn.setAutoDefault(0)
            self.nt_parameters_grpbtn.setIcon(QIcon(
                self.image7))  ### not always right, but doesn't matter
            self.nt_parameters_grpbtn.setFlat(1)
            layout20.addWidget(self.nt_parameters_grpbtn)

            self.parameters_grpbox_label = QLabel(self.parameters_grpbox,
                                                  "parameters_grpbox_label")
            self.parameters_grpbox_label.setSizePolicy(
                QSizePolicy(
                    QSizePolicy.Preferred, QSizePolicy.Minimum, 0, 0,
                    self.parameters_grpbox_label.sizePolicy().
                    hasHeightForWidth()))
            self.parameters_grpbox_label.setAlignment(QLabel.AlignVCenter)
            layout20.addWidget(self.parameters_grpbox_label)
            gbx_spacer1 = QSpacerItem(67, 16, QSizePolicy.Expanding,
                                      QSizePolicy.Minimum)
            layout20.addItem(gbx_spacer1)
            parameters_grpboxLayout.addLayout(layout20)

            nt_parameters_body_layout = QGridLayout(
                None, 1, 1, 0, 6, "nt_parameters_body_layout"
            )  ### what is 6 -- is it related to number of items???
            # is it 6 in all the ones we got, but that could be a designer error so i better look it up sometime.

            # == start its kids

            # will use from above: self.parameters_grpbox, nt_parameters_body_layout

            nextrow = 0  # which row of the QGridLayout to start filling next (loop variable)
            hidethese = [
            ]  # set of objects to hide or show, when this group is closed or opened

            for param in group_desc.kids('parameter'):
                # param (a group subobj desc) is always a parameter, but we already plan to extend this beyond that,
                # so we redundantly test for this here.
                getter = None
                paramname = None
                # set these for use by uniform code at the end (e.g. for tooltips)
                editfield = None
                label = None
                if param.isa('parameter'):
                    label = QLabel(self.parameters_grpbox, "members_label")
                    label.setAlignment(QLabel.AlignVCenter | QLabel.AlignRight)
                    nt_parameters_body_layout.addWidget(label, nextrow, 0)
                    hidethese.append(label)
                    thisrow = nextrow
                    nextrow += 1
                    #e following should be known in a place that knows the input language, not here
                    paramname = param.options.get('name') or (
                        param.args and param.args[0]) or "?"
                    paramlabel = param.options.get(
                        'label'
                    ) or paramname  ##e wrong, label "" or none ought to be possible
                    # QtGui.QApplication.translate(self.__class__.__name__, "xyz")
                    label.setText(
                        QtGui.QApplication.translate(self.__class__.__name__,
                                                     paramlabel))

                if param.isa('parameter',
                             widget='combobox',
                             type=('str', None)):
                    self.members_combox = QComboBox(
                        0, self.parameters_grpbox,
                        "members_combox")  ###k  what's 0?
                    editfield = self.members_combox
                    #### it probably needs a handler class, and then that could do this setup
                    self.members_combox.clear()
                    default = param.options.get(
                        'default', None)  # None is not equal to any string
                    thewidgetkid = param.kids(
                        'widget'
                    )[-1]  # kluge; need to think what the desc method for this should be
                    for item in thewidgetkid.kids('item'):
                        itemval = item.args[0]
                        itemtext = itemval
                        self.members_combox.insertItem(
                            QtGui.QApplication.translate(
                                self.__class__.__name__,
                                itemtext))  #k __tr ok??
                        if itemval == default:  #k or itemtext?
                            pass  ##k i find no setItem in our py code, so not sure yet what to do for this.
                    nt_parameters_body_layout.addWidget(
                        self.members_combox, thisrow, 1)
                    hidethese.append(self.members_combox)
                    getter = (lambda combobox=self.members_combox: str(
                        combobox.currentText()))
                    ##e due to __tr or non-str values, it might be better to use currentIndex and look it up in a table
                    # (though whether __tr is good here might depend on what it's used for)

                elif param.isa('parameter',
                               widget=('lineedit', None),
                               type=('str', None)):
                    # this covers explicit str|lineedit, and 3 default cases str, lineedit, neither.
                    # (i.e. if you say parameter and nothing else, it's str lineedit by default.)
                    self.length_linedit = QLineEdit(self.parameters_grpbox,
                                                    "length_linedit")
                    editfield = self.length_linedit
                    nt_parameters_body_layout.addWidget(
                        self.length_linedit, thisrow, 1)
                    hidethese.append(self.length_linedit)
                    default = str(param.options.get('default', ""))
                    self.length_linedit.setText(
                        QtGui.QApplication.translate(self.__class__.__name__,
                                                     default))  # __tr ok?
                    getter = (lambda lineedit=self.length_linedit: str(
                        lineedit.text()))

                elif param.isa('parameter',
                               widget=('lineedit', None),
                               type='float'):
                    self.length_linedit = QLineEdit(self.parameters_grpbox,
                                                    "length_linedit")
                    editfield = self.length_linedit
                    nt_parameters_body_layout.addWidget(
                        self.length_linedit, thisrow, 1)
                    hidethese.append(self.length_linedit)
                    controller = FloatLineeditController_Qt(
                        self, param, self.length_linedit)
                    header_refs.append(controller)
                    getter = controller.get_value

                elif param.isa('parameter', widget = ('spinbox', None), type = 'int') or \
                     param.isa('parameter', widget = ('spinbox'), type = None):
                    self.chirality_N_spinbox = QSpinBox(
                        self.parameters_grpbox, "chirality_N_spinbox"
                    )  # was chirality_m_spinbox, now chirality_N_spinbox
                    editfield = self.chirality_N_spinbox
                    ### seems like Qt defaults for min and max are 0,100 -- way too small a range!
                    if param.options.has_key('min') or 1:
                        self.chirality_N_spinbox.setMinimum(
                            param.options.get('min', -999999999))  # was 0
                    if param.options.has_key('max') or 1:
                        self.chirality_N_spinbox.setMaximum(
                            param.options.get(
                                'max',
                                +999999999))  # wasn't in egcode, but needed
                    self.chirality_N_spinbox.setValue(
                        param.options.get('default', 0))  # was 5
                    ##e note: i suspect this default 0 should come from something that knows this desc grammar.
                    suffix = param.options.get('suffix', '')
                    if suffix:
                        self.chirality_N_spinbox.setSuffix(
                            QtGui.QApplication.translate(
                                self.__class__.__name__, suffix))
                    else:
                        self.chirality_N_spinbox.setSuffix(
                            QString.null)  # probably not needed
                    nt_parameters_body_layout.addWidget(
                        self.chirality_N_spinbox, thisrow, 1)
                    hidethese.append(self.chirality_N_spinbox)
                    getter = self.chirality_N_spinbox.value  # note: it also has .text, which includes suffix

                else:
                    print "didn't match:", param  ###e improve this

                # things done the same way for all kinds of param-editing widgets
                if 1:  #bruce 060703 moved this down here, as bugfix
                    # set tooltip (same one for editfield and label)
                    tooltip = param.options.get('tooltip', '')
                    ###e do it for more kinds of params; share the code somehow; do it in controller, or setup-aid?
                    ###k QToolTip appropriateness; tooltip option might be entirely untested
                    if tooltip and label:
                        QToolTip.add(
                            label,
                            QtGui.QApplication.translate(
                                self.__class__.__name__, tooltip))
                    if tooltip and editfield:
                        QToolTip.add(
                            editfield,
                            QtGui.QApplication.translate(
                                self.__class__.__name__, tooltip)
                        )  ##k ok?? review once not all params have same-row labels.

                if getter and paramname and paramname != '?':
                    self.param_getters[paramname] = getter
                ### also bind these params to actions...
                continue  # next param

            header_refs.extend([
                self.parameters_grpbox, self.nt_parameters_grpbtn,
                self.parameters_grpbox_label
            ])

            # now create the logic/control object for the group
            group = CollapsibleGroupController_Qt(self, group_desc,
                                                  header_refs, hidethese,
                                                  self.nt_parameters_grpbtn)
            ### maybe ask env for the class to use for this?
            self.groups.append(
                group
            )  ### needed?? only for scanning the params, AFAIK -- oh, and to maintain a python refcount.

            # from languageChange:
            if 1:  # i don't know if these are needed:
                self.parameters_grpbox.setTitle(QString.null)
                self.nt_parameters_grpbtn.setText(QString.null)
            self.parameters_grpbox_label.setText(
                QtGui.QApplication.translate(
                    self.__class__.__name__,
                    group_desc.args[0]))  # was "Nanotube Parameters"
            ##e note that it's questionable in the syntax design for this property of a group (overall group label)
            # to be in that position (desc arg 0).

            # == end its kids

            parameters_grpboxLayout.addLayout(nt_parameters_body_layout)
            body_frameLayout.addWidget(self.parameters_grpbox)

            # == end parameters groupbox

            continue  # next group

        nanotube_dialogLayout.addWidget(self.body_frame)
        spacer14 = QSpacerItem(20, 20, QSizePolicy.Minimum,
                               QSizePolicy.Expanding)
        nanotube_dialogLayout.addItem(spacer14)

        layout42 = QHBoxLayout(None, 4, 6, "layout42")
        btm_spacer = QSpacerItem(59, 20, QSizePolicy.Expanding,
                                 QSizePolicy.Minimum)
        layout42.addItem(btm_spacer)

        self.cancel_btn = QPushButton(self, "cancel_btn")
        self.cancel_btn.setAutoDefault(0)  #bruce 060703 bugfix
        layout42.addWidget(self.cancel_btn)

        self.ok_btn = QPushButton(self, "ok_btn")
        self.ok_btn.setAutoDefault(0)  #bruce 060703 bugfix
        layout42.addWidget(self.ok_btn)
        nanotube_dialogLayout.addLayout(layout42)

        self.languageChange()

        self.resize(
            QSize(246, 618).expandedTo(self.minimumSizeHint())
        )  ### this size will need to be adjusted (guess -- it's only place overall size is set)
        qt4todo('self.clearWState(Qt.WState_Polished)')

        ## self.connect(self.nt_parameters_grpbtn,SIGNAL("clicked()"),self.toggle_nt_parameters_grpbtn) ####

        # new:
        for button, methodname in (
            (self.sponsor_btn,
             'do_sponsor_btn'),  #e generalize to more than one sponsor button
            (self.done_btn, 'do_done_btn'),
            (self.abort_btn, 'do_abort_btn'),
            (self.preview_btn, 'do_preview_btn'),
            (self.whatsthis_btn, 'do_whatsthis_btn'),
            (self.cancel_btn, 'do_cancel_btn'),
            (self.ok_btn, 'do_ok_btn')):
            if hasattr(self, methodname):
                self.connect(button, SIGNAL("clicked()"),
                             getattr(self, methodname))
        return
Beispiel #28
0
    def __init__(self, win):
        """
        Constructor for Ui_ReportsDockWidget.
        @param win: The main window
        @type  win: QMainWindow
        """
        QDockWidget.__init__(self, win)
        
        self.win = win
        #Define layout
        self._containerWidget = QWidget()
        self.setWidget(self._containerWidget)        
        
        # Create vertical box layout
        self.vBoxLayout = QVBoxLayout(self._containerWidget)
        vBoxLayout = self.vBoxLayout
        vBoxLayout.setMargin(0)
        vBoxLayout.setSpacing(0)
        
        self.setEnabled(True) 
        self.setFloating(False)
        self.setVisible(True)
        self.setWindowTitle(self._title)
        self.setAutoFillBackground(True)
        self.setPalette(getPalette( None,
                                    QPalette.Window,
                                    pmGrpBoxColor))
        
        # Create the reports tabwidget. It will contain the history tab
        # and possibly other tabs containing reports.
        self.reportsTabWidget = QTabWidget()
        self.reportsTabWidget.setObjectName("reportsTabWidget")
        self.reportsTabWidget.setCurrentIndex(0)
        self.reportsTabWidget.setAutoFillBackground(True)
        vBoxLayout.addWidget(self.reportsTabWidget)

        # Create the history tab. It will contain the history widget.
        self.historyTab = QWidget()
        self.historyTab.setObjectName("historyTab")
        self.reportsTabWidget.addTab(self.historyTab, "History") 

        self.historyTabLayout = QVBoxLayout(self.historyTab)
        historyTabLayout = self.historyTabLayout
        historyTabLayout.setMargin(0)
        historyTabLayout.setSpacing(0)
        
        self._addHistoryWidget()
        
        self.setMinimumHeight(100)
        self.setSizePolicy(
                QSizePolicy(QSizePolicy.Policy(QSizePolicy.Expanding),
                            QSizePolicy.Policy(QSizePolicy.Expanding)))
        
        win.addDockWidget(Qt.BottomDockWidgetArea, self)
        
        # Since the connection to the toggle() slot hasn't been made yet,
        # we must set the checkmark and hide/show self manually.
        if env.prefs[displayReportsWidget_prefs_key]:
            self.win.viewReportsAction.setChecked(True) 
            # No slot connected yet, so show self manually.
            self.show()
        else:
            self.win.viewReportsAction.setChecked(False)
            # No slot connected yet, so hide self manually.
            self.hide()
Beispiel #29
0
    def __init__(self, parentWidget, title="Message"):
        """
        PM_MessageGroupBox constructor.

        @param parentWidget: the PM_Dialog containing this message groupbox.
        @type  parentWidget: PM_Dialog

        @param title: The title on the collapse button
        @type  title: str
        """

        PM_GroupBox.__init__(self, parentWidget, title)

        self.vBoxLayout.setMargin(0)
        self.vBoxLayout.setSpacing(0)

        self.gridLayout.setMargin(0)
        self.gridLayout.setSpacing(0)

        self.MessageTextEdit = PM_TextEdit(
            self,
            label='',
            spanWidth=True,
            addToParent=False,
            ##cursorPosition = 'beginning'
        )
        # We pass addToParent = False to suppress the usual call by
        # PM_TextEdit.__init__ of self.addPmWidget(new textedit widget),
        # since we need to add it to self in a different way (below).
        # [bruce 071103 refactored this from what used to be a special case
        #  in PM_TextEdit.__init__ based on self being an instance of
        #  PM_MessageGroupBox.]

        # Needed for Intel MacOS. Otherwise, the horizontal scrollbar
        # is displayed in the MessageGroupBox. Mark 2007-05-24.
        # Shouldn't be needed with _setHeight() in PM_TextEdit.

        #Note 2008-06-17: We now permit a vertical scrollbar in message groupbox
        #--Ninad

        self.MessageTextEdit.setHorizontalScrollBarPolicy(
            Qt.ScrollBarAlwaysOff)

        # Add self.MessageTextEdit to self's vBoxLayout.
        self.vBoxLayout.addWidget(self.MessageTextEdit)
        # We should be calling the PM's getMessageTextEditPalette() method,
        # but that will take some extra work which I will do soon. Mark 2007-06-21
        self.MessageTextEdit.setPalette(
            getPalette(None, QPalette.Base, pmMessageBoxColor))
        self.MessageTextEdit.setReadOnly(True)
        #@self.MessageTextEdit.labelWidget = None # Never has one. Mark 2007-05-31
        self._widgetList.append(self.MessageTextEdit)
        self._rowCount += 1

        # wrapWrapMode seems to be set to QTextOption.WrapAnywhere on MacOS,
        # so let's force it here. Mark 2007-05-22.
        self.MessageTextEdit.setWordWrapMode(QTextOption.WordWrap)

        parentWidget.MessageTextEdit = self.MessageTextEdit

        # These two policies very important. Mark 2007-05-22
        self.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.MessageTextEdit.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Preferred),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        self.setWhatsThis("""<b>Messages</b>
                          <p>This prompts the user for a requisite operation and/or displays 
helpful messages to the user.</p>""")

        # Hide until insertHtmlMessage() loads a message.
        self.hide()
Beispiel #30
0
    def do_layout(self):
        self.central_widget.clear()
        self.tabs = []
        self.labels = []
        sto = QWidget.setTabOrder

        self.on_drag_enter.connect(self.handle_drag_enter)
        self.tabs.append(DragTrackingWidget(self, self.on_drag_enter))
        self.central_widget.addTab(self.tabs[0], _("&Metadata"))
        self.tabs[0].l = QGridLayout()
        self.tabs[0].setLayout(self.tabs[0].l)

        self.tabs.append(QWidget(self))
        self.central_widget.addTab(self.tabs[1], _("&Cover and formats"))
        self.tabs[1].l = QGridLayout()
        self.tabs[1].setLayout(self.tabs[1].l)

        # accept drop events so we can automatically switch to the second tab to
        # drop covers and formats
        self.tabs[0].setAcceptDrops(True)

        # Tab 0
        tab0 = self.tabs[0]

        tl = QGridLayout()
        gb = QGroupBox(_('&Basic metadata'), self.tabs[0])
        self.tabs[0].l.addWidget(gb, 0, 0, 1, 1)
        gb.setLayout(tl)

        self.button_box_layout.insertWidget(1, self.fetch_metadata_button)
        self.button_box_layout.insertWidget(2, self.config_metadata_button)
        sto(self.button_box, self.fetch_metadata_button)
        sto(self.fetch_metadata_button, self.config_metadata_button)
        sto(self.config_metadata_button, self.title)

        def create_row(row, widget, tab_to, button=None, icon=None, span=1):
            ql = BuddyLabel(widget)
            tl.addWidget(ql, row, 1, 1, 1)
            tl.addWidget(widget, row, 2, 1, 1)
            if button is not None:
                tl.addWidget(button, row, 3, span, 1)
                if icon is not None:
                    button.setIcon(QIcon(I(icon)))
            if tab_to is not None:
                if button is not None:
                    sto(widget, button)
                    sto(button, tab_to)
                else:
                    sto(widget, tab_to)

        tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1)
        tl.addWidget(self.manage_authors_button, 2, 0, 1, 1)
        tl.addWidget(self.paste_isbn_button, 12, 0, 1, 1)
        tl.addWidget(self.tags_editor_button, 6, 0, 1, 1)

        create_row(0,
                   self.title,
                   self.title_sort,
                   button=self.deduce_title_sort_button,
                   span=2,
                   icon='auto_author_sort.png')
        create_row(1, self.title_sort, self.authors)
        create_row(2,
                   self.authors,
                   self.author_sort,
                   button=self.deduce_author_sort_button,
                   span=2,
                   icon='auto_author_sort.png')
        create_row(3, self.author_sort, self.series)
        create_row(4,
                   self.series,
                   self.series_index,
                   button=self.clear_series_button,
                   icon='trash.png')
        create_row(5, self.series_index, self.tags)
        create_row(6, self.tags, self.rating, button=self.clear_tags_button)
        create_row(7,
                   self.rating,
                   self.pubdate,
                   button=self.clear_ratings_button)
        create_row(8,
                   self.pubdate,
                   self.publisher,
                   button=self.pubdate.clear_button,
                   icon='trash.png')
        create_row(9, self.publisher, self.languages)
        create_row(10, self.languages, self.timestamp)
        create_row(11,
                   self.timestamp,
                   self.identifiers,
                   button=self.timestamp.clear_button,
                   icon='trash.png')
        create_row(12,
                   self.identifiers,
                   self.comments,
                   button=self.clear_identifiers_button,
                   icon='trash.png')
        sto(self.clear_identifiers_button, self.swap_title_author_button)
        sto(self.swap_title_author_button, self.manage_authors_button)
        sto(self.manage_authors_button, self.tags_editor_button)
        sto(self.tags_editor_button, self.paste_isbn_button)
        tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding),
                   13, 1, 1, 1)

        w = getattr(self, 'custom_metadata_widgets_parent', None)
        if w is not None:
            gb = QGroupBox(_('C&ustom metadata'), tab0)
            gbl = QVBoxLayout()
            gb.setLayout(gbl)
            sr = QScrollArea(tab0)
            sr.setWidgetResizable(True)
            sr.setFrameStyle(QFrame.NoFrame)
            sr.setWidget(w)
            gbl.addWidget(sr)
            self.tabs[0].l.addWidget(gb, 0, 1, 1, 1)
            sto(self.identifiers, gb)

        w = QGroupBox(_('&Comments'), tab0)
        sp = QSizePolicy()
        sp.setVerticalStretch(10)
        sp.setHorizontalPolicy(QSizePolicy.Expanding)
        sp.setVerticalPolicy(QSizePolicy.Expanding)
        w.setSizePolicy(sp)
        l = QHBoxLayout()
        w.setLayout(l)
        l.addWidget(self.comments)
        tab0.l.addWidget(w, 1, 0, 1, 2)

        # Tab 1
        tab1 = self.tabs[1]

        wsp = QWidget(tab1)
        wgl = QVBoxLayout()
        wsp.setLayout(wgl)

        # right-hand side of splitter
        gb = QGroupBox(_('Change cover'), tab1)
        l = QGridLayout()
        gb.setLayout(l)
        for i, b in enumerate(self.cover.buttons[:3]):
            l.addWidget(b, 0, i, 1, 1)
            sto(b, self.cover.buttons[i + 1])
        hl = QHBoxLayout()
        for b in self.cover.buttons[3:]:
            hl.addWidget(b)
        sto(self.cover.buttons[-2], self.cover.buttons[-1])
        l.addLayout(hl, 1, 0, 1, 3)
        wgl.addWidget(gb)
        wgl.addItem(
            QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Expanding))
        wgl.addItem(
            QSpacerItem(10, 10, QSizePolicy.Expanding, QSizePolicy.Expanding))
        wgl.addWidget(self.formats_manager)

        self.splitter = QSplitter(Qt.Horizontal, tab1)
        tab1.l.addWidget(self.splitter)
        self.splitter.addWidget(self.cover)
        self.splitter.addWidget(wsp)

        self.formats_manager.formats.setMaximumWidth(10000)
        self.formats_manager.formats.setIconSize(QSize(64, 64))
    def __init__(self, assy, parent):
        """
        Constructor for the part window.

        @param assy: The assembly (part)
        @type  assy: Assembly

        @param parent: The parent widget.
        @type  parent: U{B{QMainWindow}
                       <http://doc.trolltech.com/4/qmainwindow.html>}
        """
        QWidget.__init__(self, parent)
        self.parent = parent
        self.assy = assy
            # note: to support MDI, self.assy would probably need to be a
            # different assembly for each PartWindow.
            # [bruce 080216 comment]
        self.setWindowIcon(geticon("ui/border/Part.png"))
        self.updateWindowTitle()

        # Used in expanding or collapsing the Model Tree/ PM area
        self._previous_pwLeftAreaWidth = PM_DEFAULT_WIDTH

        # The main layout for the part window is a VBoxLayout <pwVBoxLayout>.
        self.pwVBoxLayout = QVBoxLayout(self)
        pwVBoxLayout = self.pwVBoxLayout
        pwVBoxLayout.setMargin(0)
        pwVBoxLayout.setSpacing(0)

        # ################################################################
        # <pwSplitter> is the horizontal splitter b/w the
        # pwProjectTabWidget and the glpane.
        self.pwSplitter = QSplitter(Qt.Horizontal)
        pwSplitter = self.pwSplitter
        pwSplitter.setObjectName("pwSplitter")
        pwSplitter.setHandleWidth(3) # 3 pixels wide.
        pwVBoxLayout.addWidget(pwSplitter)

        # ##################################################################
        # <pwLeftArea> is the container holding the pwProjectTabWidget.
        # Note: Making pwLeftArea (and pwRightArea and pwBottomArea) QFrame
        # widgets has the benefit of making it easy to draw a border around
        # each area. One purpose of this would be to help developers understand
        # (visually) how the part window is laid out. I intend to add a debug
        # pref to draw part window area borders and add "What's This" text to
        # them. Mark 2008-01-05.
        self.pwLeftArea = QFrame()
        pwLeftArea = self.pwLeftArea
        pwLeftArea.setObjectName("pwLeftArea")
        pwLeftArea.setMinimumWidth(PM_MINIMUM_WIDTH)
        pwLeftArea.setMaximumWidth(PM_MAXIMUM_WIDTH)
        pwLeftArea.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Fixed),
                        QSizePolicy.Policy(QSizePolicy.Expanding)))

        # Setting the frame style like this is nice since it clearly
        # defines the splitter at the top-left corner.
        pwLeftArea.setFrameStyle( QFrame.Panel | QFrame.Sunken )

        # This layout will contain splitter (above) and the pwBottomArea.
        leftChannelVBoxLayout = QVBoxLayout(pwLeftArea)
        leftChannelVBoxLayout.setMargin(0)
        leftChannelVBoxLayout.setSpacing(0)

        pwSplitter.addWidget(pwLeftArea)

        # Makes it so pwLeftArea is not collapsible.
        pwSplitter.setCollapsible (0, False)

        # ##################################################################
        # <pwProjectTabWidget> is a QTabWidget that contains the MT and PM
        # widgets. It lives in the "left area" of the part window.
        self.pwProjectTabWidget = _pwProjectTabWidget()
           # _pwProjectTabWidget subclasses QTabWidget
           # Note [bruce 070829]: to fix bug 2522 I need to intercept
           # self.pwProjectTabWidget.removeTab, so I made it a subclass of
           # QTabWidget. It needs to know the GLPane, but that's not created
           # yet, so we set it later using KLUGE_setGLPane (below).
           # Note: No parent supplied. Could this be the source of the
           # minor vsplitter resizing problem I was trying to resolve a few
           # months ago?  Try supplying a parent later. Mark 2008-01-01
        self.pwProjectTabWidget.setObjectName("pwProjectTabWidget")
        self.pwProjectTabWidget.setCurrentIndex(0)
        self.pwProjectTabWidget.setAutoFillBackground(True)

        # Create the model tree "tab" widget. It will contain the MT GUI widget.
        # Set the tab icon, too.
        self.modelTreeTab = QWidget()
        self.modelTreeTab.setObjectName("modelTreeTab")
        self.pwProjectTabWidget.addTab(
            self.modelTreeTab,
            geticon("ui/modeltree/Model_Tree.png"),
            "")

        modelTreeTabLayout = QVBoxLayout(self.modelTreeTab)
        modelTreeTabLayout.setMargin(0)
        modelTreeTabLayout.setSpacing(0)

        # Create the model tree (GUI) and add it to the tab layout.
        self.modelTree = modelTree(self.modelTreeTab, parent)
        self.modelTree.modelTreeGui.setObjectName("modelTreeGui")
        modelTreeTabLayout.addWidget(self.modelTree.modelTreeGui)

        # Create the property manager "tab" widget. It will contain the PropMgr
        # scroll area, which will contain the property manager and all its
        # widgets.
        self.propertyManagerTab = QWidget()
        self.propertyManagerTab.setObjectName("propertyManagerTab")

        self.propertyManagerScrollArea = QScrollArea(self.pwProjectTabWidget)
        self.propertyManagerScrollArea.setObjectName("propertyManagerScrollArea")
        self.propertyManagerScrollArea.setWidget(self.propertyManagerTab)
        self.propertyManagerScrollArea.setWidgetResizable(True)
        # Eureka!
        # setWidgetResizable(True) will resize the Property Manager (and its
        # contents) correctly when the scrollbar appears/disappears.
        # It even accounts correctly for collapsed/expanded groupboxes!
        # Mark 2007-05-29

        # Add the property manager scroll area as a "tabbed" widget.
        # Set the tab icon, too.
        self.pwProjectTabWidget.addTab(
            self.propertyManagerScrollArea,
            geticon("ui/modeltree/Property_Manager.png"),
            "")

        # Finally, add the "pwProjectTabWidget" to the left channel layout.
        leftChannelVBoxLayout.addWidget(self.pwProjectTabWidget)

        # Create the glpane and make it a child of the part splitter.
        self.glpane = GLPane(assy, self, 'glpane name', parent)
            # note: our owner (MWsemantics) assumes
            # there is just this one GLPane for assy, and stores it
            # into assy as assy.o and assy.glpane. [bruce 080216 comment]
        self.pwProjectTabWidget.KLUGE_setGLPane(self.glpane)
            # help fix bug 2522 [bruce 070829]
        qt4warnDestruction(self.glpane, 'GLPane of PartWindow')
        pwSplitter.addWidget(self.glpane)

        # ##################################################################
        # <pwBottomArea> is a container at the bottom of the part window
        # spanning its entire width. It is intended to be used as an extra
        # area for use by Property Managers (or anything else) that needs
        # a landscape oriented layout.
        # An example is the Sequence Editor, which is part of the
        # Strand Properties PM.
        self.pwBottomArea = QFrame()
            # IMHO, self is not a good parent. Mark 2008-01-04.
        pwBottomArea = self.pwBottomArea
        pwBottomArea.setObjectName("pwBottomArea")
        pwBottomArea.setMaximumHeight(50)
        pwBottomArea.setSizePolicy(
            QSizePolicy(QSizePolicy.Policy(QSizePolicy.Expanding),
                        QSizePolicy.Policy(QSizePolicy.Fixed)))

        # Add a frame border to see what it looks like.
        pwBottomArea.setFrameStyle( QFrame.Panel | QFrame.Sunken )

        self.pwVBoxLayout.addWidget(pwBottomArea)

        # Hide the bottom frame for now. Later this might be used for the
        # sequence editor.
        pwBottomArea.hide()
Beispiel #32
0
    def do_layout(self):
        self.central_widget.clear()
        self.labels = []
        sto = QWidget.setTabOrder

        self.central_widget.tabBar().setVisible(False)
        tab0 = QWidget(self)
        self.central_widget.addTab(tab0, _("&Metadata"))
        l = QGridLayout()
        tab0.setLayout(l)

        # Basic metadata in col 0
        tl = QGridLayout()
        gb = QGroupBox(_('Basic metadata'), tab0)
        l.addWidget(gb, 0, 0, 1, 1)
        gb.setLayout(tl)

        self.button_box_layout.insertWidget(1, self.fetch_metadata_button)
        self.button_box_layout.insertWidget(2, self.config_metadata_button)
        sto(self.button_box, self.fetch_metadata_button)
        sto(self.fetch_metadata_button, self.config_metadata_button)
        sto(self.config_metadata_button, self.title)

        def create_row(row, widget, tab_to, button=None, icon=None, span=1):
            ql = BuddyLabel(widget)
            tl.addWidget(ql, row, 1, 1, 1)
            tl.addWidget(widget, row, 2, 1, 1)
            if button is not None:
                tl.addWidget(button, row, 3, span, 1)
                if icon is not None:
                    button.setIcon(QIcon(I(icon)))
            if tab_to is not None:
                if button is not None:
                    sto(widget, button)
                    sto(button, tab_to)
                else:
                    sto(widget, tab_to)

        tl.addWidget(self.swap_title_author_button, 0, 0, 2, 1)
        tl.addWidget(self.manage_authors_button, 2, 0, 2, 1)
        tl.addWidget(self.paste_isbn_button, 12, 0, 1, 1)
        tl.addWidget(self.tags_editor_button, 6, 0, 1, 1)

        create_row(0,
                   self.title,
                   self.title_sort,
                   button=self.deduce_title_sort_button,
                   span=2,
                   icon='auto_author_sort.png')
        create_row(1, self.title_sort, self.authors)
        create_row(2,
                   self.authors,
                   self.author_sort,
                   button=self.deduce_author_sort_button,
                   span=2,
                   icon='auto_author_sort.png')
        create_row(3, self.author_sort, self.series)
        create_row(4,
                   self.series,
                   self.series_index,
                   button=self.clear_series_button,
                   icon='trash.png')
        create_row(5, self.series_index, self.tags)
        create_row(6, self.tags, self.rating, button=self.clear_tags_button)
        create_row(7,
                   self.rating,
                   self.pubdate,
                   button=self.clear_ratings_button)
        create_row(8,
                   self.pubdate,
                   self.publisher,
                   button=self.pubdate.clear_button,
                   icon='trash.png')
        create_row(9, self.publisher, self.languages)
        create_row(10, self.languages, self.timestamp)
        create_row(11,
                   self.timestamp,
                   self.identifiers,
                   button=self.timestamp.clear_button,
                   icon='trash.png')
        create_row(12,
                   self.identifiers,
                   self.comments,
                   button=self.clear_identifiers_button,
                   icon='trash.png')
        sto(self.clear_identifiers_button, self.swap_title_author_button)
        sto(self.swap_title_author_button, self.manage_authors_button)
        sto(self.manage_authors_button, self.tags_editor_button)
        sto(self.tags_editor_button, self.paste_isbn_button)
        tl.addItem(QSpacerItem(1, 1, QSizePolicy.Fixed, QSizePolicy.Expanding),
                   13, 1, 1, 1)

        # Custom metadata in col 1
        w = getattr(self, 'custom_metadata_widgets_parent', None)
        if w is not None:
            gb = QGroupBox(_('Custom metadata'), tab0)
            gbl = QVBoxLayout()
            gb.setLayout(gbl)
            sr = QScrollArea(gb)
            sr.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
            sr.setWidgetResizable(True)
            sr.setFrameStyle(QFrame.NoFrame)
            sr.setWidget(w)
            gbl.addWidget(sr)
            l.addWidget(gb, 0, 1, 1, 1)
            sp = QSizePolicy()
            sp.setVerticalStretch(10)
            sp.setHorizontalPolicy(QSizePolicy.Minimum)
            sp.setVerticalPolicy(QSizePolicy.Expanding)
            gb.setSizePolicy(sp)
            self.set_custom_metadata_tab_order()

        # comments span col 0 & 1
        w = QGroupBox(_('Comments'), tab0)
        sp = QSizePolicy()
        sp.setVerticalStretch(10)
        sp.setHorizontalPolicy(QSizePolicy.Expanding)
        sp.setVerticalPolicy(QSizePolicy.Expanding)
        w.setSizePolicy(sp)
        lb = QHBoxLayout()
        w.setLayout(lb)
        lb.addWidget(self.comments)
        l.addWidget(w, 1, 0, 1, 2)

        # Cover & formats in col 3
        gb = QGroupBox(_('Cover'), tab0)
        lb = QGridLayout()
        gb.setLayout(lb)
        lb.addWidget(self.cover, 0, 0, 1, 3, alignment=Qt.AlignCenter)
        sto(self.manage_authors_button, self.cover.buttons[0])
        for i, b in enumerate(self.cover.buttons[:3]):
            lb.addWidget(b, 1, i, 1, 1)
            sto(b, self.cover.buttons[i + 1])
        hl = QHBoxLayout()
        for b in self.cover.buttons[3:]:
            hl.addWidget(b)
        sto(self.cover.buttons[-2], self.cover.buttons[-1])
        lb.addLayout(hl, 2, 0, 1, 3)
        l.addWidget(gb, 0, 2, 1, 1)
        l.addWidget(self.formats_manager, 1, 2, 1, 1)
        sto(self.cover.buttons[-1], self.formats_manager)

        self.formats_manager.formats.setMaximumWidth(10000)
        self.formats_manager.formats.setIconSize(QSize(32, 32))