Пример #1
0
    def newConfigurationBox(self, info, iconName, title, alternative_type):

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

        icon = QLabel()
        box_image = self.core.rsrc_dir + iconName
        #pixmap=QtGui.QPixmap(box_image).scaled(70,70)
        pixmap = QPixmap(box_image)
        icon.setPixmap(pixmap)
        icon.setAlignment(Qt.AlignCenter | Qt.AlignVCenter)
        icon.setMinimumSize(90, 100)
        icon.setMaximumSize(90, 100)
        icon.current = False
        icon.alternative_type = alternative_type
        hbox.addWidget(icon)

        name = QLabel()
        name.setText(title)
        name.setAlignment(Qt.AlignLeft | Qt.AlignVCenter)

        if self.count < self.num_separators:
            name.setStyleSheet(
                "font:10pt;border:3px solid silver;border-top:0px;border-right:0px;border-left:0px;margin-top:0px;"
            )
        else:
            name.setStyleSheet("font:10pt")
        name.current = False
        name.alternative_type = alternative_type
        hbox.addWidget(name, -1)

        try:
            default = QLabel()
            for item in info:
                if info[item]["default"]:
                    text = item
        except:
            text = ""

        default.setText(text)
        default.setAlignment(Qt.AlignRight | Qt.AlignVCenter)

        if self.count < self.num_separators:
            default.setStyleSheet(
                "font:10pt;padding:15px;border:3px solid silver;border-top:0px;border-right:0px;border-left:0px;margin-top:0px;"
            )
        else:
            default.setStyleSheet("font:10pt;padding:15px")

        default.setMinimumHeight(100)
        default.setMaximumHeight(100)
        default.current = True
        default.alternative_type = alternative_type
        hbox.addWidget(default)

        menu = QMenu()
        for item in info:
            action = menu.addAction(item)
            action.triggered.connect(lambda chk, item=item: self.itemClicked(
                item, info[item]["cmd"], alternative_type))

        pushbutton = QToolButton()
        icn = QIcon.fromTheme(os.path.join(settings.ICONS_THEME, "editor.svg"))
        pushbutton.setIcon(icn)
        pushbutton.setIconSize(QSize(16, 16))
        pushbutton.setToolTip(_("Click to select an option"))
        pushbutton.clicked.connect(lambda: self.buttonPress(alternative_type))
        pushbutton.current = False
        pushbutton.alternative_type = alternative_type
        pushbutton.setPopupMode(QToolButton.InstantPopup)
        pushbutton.setStyleSheet("margin-right:15px;background-color:#efefef")
        pushbutton.setMaximumSize(40, 30)
        self.setStyleSheet("""QToolTip { 
                           background-color:#efefef; 
                           color: black; 
                           border: #efefef solid 1px;
                           }""")

        self.setMenu(menu, alternative_type)
        hbox.addWidget(pushbutton)

        self.boxConfigurations.addLayout(hbox)