Esempio n. 1
0
 def __init__(self, value, parent=None):
     QLineEdit.__init__(self, str(value), parent)
     self.setAlignment(Qt.AlignRight)
     if isinstance(value, int):
         self.setValidator(QIntValidator())
     elif isinstance(value, float):
         self.setValidator(QDoubleValidator())
Esempio n. 2
0
    def __init__(self, *args, **kwargs):
        super(RangeFieldWidget, self).__init__(*args, **kwargs)

        widget = QFrame(self)
        layout = layouts.HorizontalLayout(spacing=4, margins=(0, 0, 0, 0))
        widget.setLayout(layout)

        validator = QIntValidator(-50000000, 50000000, self)

        self._min_widget = lineedit.BaseLineEdit(parent=self)
        self._min_widget.setValidator(validator)
        self._min_widget.textChanged.connect(self._on_emit_value_changed)
        widget.layout().addWidget(self._min_widget)

        self._max_widget = lineedit.BaseLineEdit(parent=self)
        self._max_widget.setValidator(validator)
        self._max_widget.textChanged.connect(self._on_emit_value_changed)
        widget.layout().addWidget(self._max_widget)

        self.set_widget(widget)
Esempio n. 3
0
    def __init__(self, text='', input_mode=None, parent=None):
        super(BaseLineEdit, self).__init__(text, parent)

        self._prefix_widget = None
        self._suffix_widget = None
        self._size = self.theme_default_size()

        self._main_layout = layouts.HorizontalLayout()
        self._main_layout.setContentsMargins(0, 0, 0, 0)
        self._main_layout.addStretch()
        self.setLayout(self._main_layout)

        self.setProperty('history', self.property('text'))
        self.setTextMargins(2, 0, 2, 0)

        if input_mode == 'float':
            self.setValidator(QDoubleValidator())
        elif input_mode == 'int':
            self.setValidator(QIntValidator())

        self._delay_timer = QTimer()
        self._delay_timer.setInterval(500)
        self._delay_timer.setSingleShot(True)
        self._delay_timer.timeout.connect(self._on_delay_text_changed)
Esempio n. 4
0
    def addAttributeSlot(self):
        """ Adds a new attribute (column) to the table """

        dialog = QDialog(self)
        dialog.setModal(True)
        dialog.setWindowTitle('Add Attribute')

        layout = QVBoxLayout()
        dialog.setLayout(layout)

        form = QFormLayout()
        nameBox = QLineEdit()
        typeCombo = QComboBox()
        for attrType in _attrTypes:
            typeName = partio.TypeName(attrType)
            typeCombo.addItem(typeName)
        typeCombo.setCurrentIndex(partio.FLOAT)
        countBox = QLineEdit()
        countBox.setValidator(QIntValidator())
        countBox.setText('1')
        fixedCheckbox = QCheckBox()
        valueBox = QLineEdit()
        valueBox.setText('0')
        form.addRow('Name:', nameBox)
        form.addRow('Type:', typeCombo)
        form.addRow('Count:', countBox)
        form.addRow('Fixed:', fixedCheckbox)
        form.addRow('Default Value:', valueBox)
        layout.addLayout(form)

        buttons = QHBoxLayout()
        layout.addLayout(buttons)

        add = QPushButton('Add')
        add.clicked.connect(dialog.accept)
        buttons.addWidget(add)

        cancel = QPushButton('Cancel')
        cancel.clicked.connect(dialog.reject)
        buttons.addWidget(cancel)

        if not dialog.exec_():
            return

        name = str(nameBox.text())
        if not name:
            print('Please supply a name for the new attribute')  # TODO: prompt
            return

        attrType = typeCombo.currentIndex()
        count = int(countBox.text())
        fixed = fixedCheckbox.isChecked()
        values = list(str(valueBox.text()).strip().split())
        for i in range(count):
            if i < len(values):
                value = values[i]
            else:
                value = values[-1]
            if attrType == partio.INT or attrType == partio.INDEXEDSTR:
                values[i] = int(value)
            elif attrType == partio.FLOAT or attrType == partio.VECTOR:
                values[i] = float(value)  # pylint:disable=R0204
            else:
                values[i] = 0.0  # pylint:disable=R0204
        value = tuple(values)

        self.data.addAttribute(name, attrType, count, fixed, value)
Esempio n. 5
0
    def _init_ui(self):
        self.setWindowModality(Qt.ApplicationModal)
        self.setMinimumSize(Data.getWindowWidth() / 4.5,
                            Data.getWindowHeight() / 1.6)
        self.setMaximumSize(Data.getWindowWidth() / 4.5,
                            Data.getWindowHeight() / 1.6)

        browser_4 = MClickBrowserFolderToolButton().huge()
        self.lineEdit = MLineEdit(text='filepath')
        self.lineEdit.setReadOnly(True)

        browser_4.sig_folder_changed.connect(self.lineEdit.setText)
        lay_1 = QHBoxLayout()
        lay_1.addWidget(self.lineEdit)
        lay_1.addWidget(browser_4)

        self.tab = MLineTabWidget()
        widget = QWidget()
        widget.setLayout(QVBoxLayout())

        self.lineEdit_width = MLineEdit()
        tool_button = MLabel(text=u'宽度').mark().secondary()
        tool_button.setAlignment(Qt.AlignCenter)
        tool_button.setFixedWidth(80)
        self.lineEdit_width.set_prefix_widget(tool_button)
        self.lineEdit_width.setText("1080")
        self.lineEdit_width.setValidator(QIntValidator())

        self.lineEdit_height = MLineEdit()
        tool_button = MLabel(text=u'高度').mark().secondary()
        tool_button.setAlignment(Qt.AlignCenter)
        tool_button.setFixedWidth(80)
        self.lineEdit_height.set_prefix_widget(tool_button)
        self.lineEdit_height.setText("720")
        self.lineEdit_height.setValidator(QIntValidator())

        self.lineEdit_level = MLineEdit()
        tool_button = MLabel(text=u'精度').mark().secondary()
        tool_button.setAlignment(Qt.AlignCenter)
        tool_button.setFixedWidth(80)
        self.lineEdit_level.set_prefix_widget(tool_button)
        self.lineEdit_level.setText("50")
        self.lineEdit_level.setValidator(QIntValidator())

        widget.layout().addWidget(MLabel(u'贴图大小'))
        widget.layout().addWidget(self.lineEdit_width)
        widget.layout().addWidget(self.lineEdit_height)
        widget.layout().addSpacing(10)
        widget.layout().addWidget(MLabel(u'贴图精度'))
        widget.layout().addWidget(self.lineEdit_level)

        self.tab.add_tab(widget, u'低精度图片')

        widget2 = QWidget()
        widget2.setLayout(QVBoxLayout())
        self.MlineEdit_level = MLineEdit()
        tool_button = MLabel(text=u'精度').mark().secondary()
        tool_button.setAlignment(Qt.AlignCenter)
        tool_button.setFixedWidth(80)
        self.MlineEdit_level.set_prefix_widget(tool_button)
        self.MlineEdit_level.setText("50")
        self.MlineEdit_level.setValidator(QIntValidator())
        widget2.layout().addWidget(MLabel(u'模型精度'))
        widget2.layout().addWidget(self.MlineEdit_level)

        widget2.layout().addSpacing(100)
        self.tab.add_tab(widget2, u'低精度模型')

        btn_layout = QHBoxLayout()
        self.btn_ok = MPushButton(text=u'导出').primary()
        self.btn_ok.setFixedWidth(80)

        self.btn_cancel = MPushButton(text=u'取消').primary()
        self.btn_cancel.setFixedWidth(80)

        btn_layout.addWidget(self.btn_ok)
        btn_layout.addWidget(self.btn_cancel)

        main_lay = QVBoxLayout()
        main_lay.addSpacing(20)
        main_lay.addWidget(MDivider(u'路径选择'))
        main_lay.addLayout(lay_1)
        main_lay.addWidget(MDivider(u'操作选择'))
        main_lay.addWidget(self.tab)

        main_lay.addWidget(MDivider(u''))
        main_lay.addLayout(btn_layout)
        main_lay.addSpacing(20)

        self.setLayout(main_lay)
        dayu_theme.background_color = "#262626"
        dayu_theme.apply(self)