def loadIntegerFloatList(self, font, src, dst): values = " ".join(str(val) for val in getattr(font.info, src)) setattr(self, dst + "Edit", QLineEdit(values, self)) validator = QRegularExpressionValidator(self) validator.setRegularExpression( QRegularExpression("(-?\d+(.\d+)?\s*)*")) getattr(self, dst + "Edit").setValidator(validator)
def __init__(self, parent=None): super().__init__(parent) self.setAttribute(Qt.WA_QuitOnClose, False) self.setWindowFlags(Qt.Dialog | Qt.WindowTitleHint | Qt.WindowSystemMenuHint) self.setWindowTitle(_('Base Conversions')) self.value = 0 self.numBits = 32 self.twosComplement = False layout = QVBoxLayout(self) layout.setSpacing(0) decimalLabel = QLabel(_('&Decmal')) layout.addWidget(decimalLabel) decimalEdit = QLineEdit() decimalLabel.setBuddy(decimalEdit) decimalEdit.base = 10 decRegEx = QRegularExpression('[-0-9]*') decimalEdit.setValidator(QRegularExpressionValidator(decRegEx)) layout.addWidget(decimalEdit) layout.addSpacing(8) hexLabel = QLabel(_('&Hex')) layout.addWidget(hexLabel) hexEdit = QLineEdit() hexLabel.setBuddy(hexEdit) hexEdit.base = 16 hexRegEx = QRegularExpression('[-0-9a-fA-F]*') hexEdit.setValidator(QRegularExpressionValidator(hexRegEx)) layout.addWidget(hexEdit) layout.addSpacing(8) octalLabel = QLabel(_('&Octal')) layout.addWidget(octalLabel) octalEdit = QLineEdit() octalLabel.setBuddy(octalEdit) octalEdit.base = 8 octRegEx = QRegularExpression('[-0-7]*') octalEdit.setValidator(QRegularExpressionValidator(octRegEx)) layout.addWidget(octalEdit) layout.addSpacing(8) binaryLabel = QLabel(_('&Binary')) layout.addWidget(binaryLabel) binaryEdit = QLineEdit() binaryLabel.setBuddy(binaryEdit) binaryEdit.base = 2 binRegEx = QRegularExpression('[-01]*') binaryEdit.setValidator(QRegularExpressionValidator(binRegEx)) layout.addWidget(binaryEdit) layout.addSpacing(8) self.bitsButton = QPushButton('') self.setButtonLabel() layout.addWidget(self.bitsButton) self.bitsButton.clicked.connect(self.changeBitSettings) layout.addSpacing(8) closeButton = QPushButton(_('&Close')) layout.addWidget(closeButton) closeButton.clicked.connect(self.close) self.editors = (decimalEdit, hexEdit, octalEdit, binaryEdit) for editor in self.editors: editor.textEdited.connect(self.updateValue)
def _init_line_edits(self): validator = QRegularExpressionValidator(QRegularExpression("[^ ]+")) self.name_line_edit.setValidator(validator) self.symbol_line_edit.setValidator(validator) self.unit_line_edit.setValidator(validator) self.unit_net_price_line_edit.setValidator( QRegularExpressionValidator(QRegularExpression("\d+(,\d{2})?"))) self.vat_line_edit.setValidator( QRegularExpressionValidator(QRegularExpression("\d{1,2}")))
def __setup_validators(self): positive_integer = QRegularExpression(r"\d+") positive_integer_validator = QRegularExpressionValidator(positive_integer) rational = QRegularExpression(r"-?\d+\.\d+") rational_validator = QRegularExpressionValidator(rational) self.__ui.x0_Input.setValidator(rational_validator) self.__ui.y0_Input.setValidator(rational_validator) self.__ui.x_Input.setValidator(rational_validator) self.__ui.n_Input.setValidator(positive_integer_validator) self.__ui.n0_error_Input.setValidator(positive_integer_validator) self.__ui.n_error_Input.setValidator(positive_integer_validator)
def _init_line_edits(self): self.name_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("[a-zA-ZĄąĆćĘꣳŃńÓ󌜯żŹź\\s]+"))) self.lastname_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("[a-zA-ZĄąĆćĘꣳŃńÓ󌜯żŹź\\s\\-]+"))) self.taxid_line_edit.setValidator( QRegularExpressionValidator(QRegularExpression("[\\d\\-?]+"))) self.postalcode_line_edit.setValidator( QRegularExpressionValidator(QRegularExpression("\\d{2}\\-\\d{3}"))) self.city_line_edit.setValidator( QRegularExpressionValidator( QRegularExpression("[a-zA-ZĄąĆćĘꣳŃńÓ󌜯żŹź\\s\\-]+")))
def __init__(self): super().__init__("spherical_voi.ui") self._radius = LineEdit(self.radius_lineEdit) validator = QRegularExpressionValidator(Regex.FLOAT_UNSIGNED.value) self._radius.enable_validation(validator)
def __init__(self, addon=False, parent=None): """ Constructor @param addon flag indicating an addon firmware @type bool @param parent reference to the parent widget @type QWidget """ super(EspFirmwareSelectionDialog, self).__init__(parent) self.setupUi(self) self.__addon = addon self.firmwarePicker.setMode(E5PathPickerModes.OpenFileMode) self.firmwarePicker.setFilters( self.tr("Firmware Files (*.bin);;All Files (*)")) self.espComboBox.addItems(["", "ESP32", "ESP8266"]) if addon: self.__validator = QRegularExpressionValidator( QRegularExpression(r"[0-9a-fA-F]{0,4}")) self.addressEdit.setValidator(self.__validator) else: self.addressLabel.hide() self.addressEdit.hide() msh = self.minimumSizeHint() self.resize(max(self.width(), msh.width()), msh.height())
def __init__(self, parent=None): super(ReactionAttributesDisplayWidget, self).__init__(parent) self.setupUi(self) self.model = None self.reaction = None self.default_id_border = self.idLineEdit.styleSheet() # Setup validator for SBML compliant ids self.validator = QRegularExpressionValidator() self.validator.setRegularExpression( QRegularExpression(r"^[a-zA-Z0-9_]*$")) self.idLineEdit.setValidator(self.validator) # Toggle id status self.validate_id() self.setup_connections()
def __init__(self, *, combobox_model, **kwargs): super(NewProfileDialog, self).__init__(**kwargs) self.setupUi(self) self.okbutton = self.buttonBox.button(QDialogButtonBox.Ok) self.okbutton.setDisabled(True) self.final_name = None self.copy_from = None self.comboBox.setModel(combobox_model) # according to timeit, checking if a word is in a list is # faster than checking against a RegExp--even a compiled RE, # and even if you pre-process the word to check each time # (e.g.: word.lower() in wordlist) self.name_list = [p.lower() for p in combobox_model.profiles] # self.name_list = [p.name.lower() for p in combobox_model.profiles] # this validator ensures that no spaces or invalid characters can be entered. # (only letters, numbers, underscores, hyphens, and periods) vre_str = r"[\w\d_.-]+" self.vre = QRegularExpression(vre_str) self.validator = QRegularExpressionValidator(self.vre) self.lineEdit.setValidator(self.validator) # stylesheet for invalid text self.ss_invalid = "QLineEdit { color: red }" # tooltip for invalid text self.tt_invalid = "Profile names must be unique"
def _init(self): self._ui.editAnalyzerAddr.setValidator(QRegularExpressionValidator(QRegularExpression( '^TCPIP::(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}' '([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])::INSTR$'))) self._setupSignals() self._setupControls() self._refreshView()
class URLValidator(QValidator): def __init__(self): super().__init__() regex = r"https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)" self.validator = QRegularExpressionValidator(QRegularExpression(regex)) def validate(self, input, pos): return self.validator.validate(input, pos)
def __init__(self, parent=None): super(GotoLineDialog, self).__init__(parent) self.setWindowModality(Qt.WindowModal) self.setWindowTitle(self.tr("Go to…")) self.lineEdit = QLineEdit(self) validator = QRegularExpressionValidator(self) validator.setRegularExpression( QRegularExpression("(^[1-9][0-9]*(:[1-9][0-9]*)?$)?")) self.lineEdit.setValidator(validator) self.lineEdit.returnPressed.connect(self.accept) label = QLabel(self.tr("Enter a row:column to go to"), self) layout = QVBoxLayout(self) layout.addWidget(self.lineEdit) layout.addWidget(label) self.setLayout(layout)
def __init__(self, widget_file): super().__init__() widget_path = Path(Path(__file__).parent, "widgets", widget_file).resolve() uic.loadUi(widget_path, self) self._name = LineEdit(self.name_lineEdit) self._center = [ LineEdit(self.centerX_lineEdit), LineEdit(self.centerY_lineEdit), LineEdit(self.centerZ_lineEdit) ] validator = QRegularExpressionValidator(Regex.STRING.value) self._name.enable_validation(validator) validator = QRegularExpressionValidator(Regex.FLOAT.value) enable_validation_list(validator, self._center)
def __init__(self): super().__init__("cuboidal_voi.ui") self._width = LineEdit(self.width_lineEdit) self._height = LineEdit(self.height_lineEdit) self._depth = LineEdit(self.depth_lineEdit) self._dims = [self._width, self._height, self._depth] validator = QRegularExpressionValidator(Regex.FLOAT_UNSIGNED.value) enable_validation_list(validator, self._dims)
def setupUi(self, MainWindow, app): super().setupUi(MainWindow) self.app = app self.mainWindow = MainWindow self._connect_all_signals() self._fill_in_forms() digit_regexp = QRegularExpression('^([1-9][0-9]*)*') digit_validator = QRegularExpressionValidator(digit_regexp) self.comboBox_emailPortIMAP.setValidator(digit_validator) self.comboBox_emailPortSMTP.setValidator(digit_validator)
def __generateValueWidget__(self, numeric=False): self.valueInput = QComboBox() self.valueInput.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self.valueInput.setEditable(True) self.valueInput.lineEdit().setPlaceholderText( "'service', 'motorway'...") if numeric: self.valueInput.setValidator( QRegularExpressionValidator(QRegularExpression("^[0-9]+$"))) self.keyInput.currentTextChanged.connect(self.valueInput.clear) self.layout.addRow("Value:", self.valueInput)
def _setupUi(self): self._ui.editAnalyzerAddr.setValidator( QRegularExpressionValidator( QRegularExpression('^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.' '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$'))) self._ui.widgetStats.setVisible( any([self._show_freq, self._show_amp, self._show_curr])) self._setupSignals() self._modeBeforeConnect() self._ui.btnOffset.setVisible(False)
def __init__(self, parent=None): super().__init__(parent) self.ui = self.__class__.ui[0]() self.ui.setupUi(self) self.ui.barcodes_fw.setLabel("Forward barcodes:") self.ui.barcodes_rev.setLabel("Reverse barcodes:") self.ui.named_inserts.setLabel("Named variable sequences:") style = QApplication.style() self.ui.fromFileBtn.setIcon(style.standardIcon(QStyle.SP_DirOpenIcon, None, self.ui.fromFileBtn)) if QIcon.hasThemeIcon("edit-paste"): self.ui.fromClipboardBtn.setIcon(QIcon.fromTheme("edit-paste")) else: self.ui.fromClipboardBtn.setText("Paste") cellsvalidator = QDoubleValidator(0, 1, 1000) cellsvalidator.setLocale(QLocale(QLocale.English, QLocale.UnitedStates)) self.cellsdelegate = SimpleDelegate(cellsvalidator, self) proto = QTableWidgetItem() proto.setFlags(Qt.ItemIsSelectable | Qt.ItemIsEditable | Qt.ItemIsEnabled) proto.setData(Qt.EditRole, "0.0") self.ui.sortedCellsTbl.setItemPrototype(proto) self.ui.sortedCellsTbl.setItemDelegate(self.cellsdelegate) self.ui.sortedCellsTbl.cellChanged.connect(self._validChanged) self.ui.insertSequence.setValidator(QRegularExpressionValidator(QRegularExpression("^([atcg]+)?[n]+(?(1)[atcg]*|[atcg]+)$", QRegularExpression.CaseInsensitiveOption))) self.ui.fromFileBtn.clicked.connect(self.fromFile) self.ui.fromClipboardBtn.clicked.connect(self.fromClipboard) self.ui.barcodes_fw.rowAdded.connect(self.fwCodeAdded) self.ui.barcodes_fw.rowChanged.connect(self.fwCodeChanged) self.ui.barcodes_fw.rowRemoved.connect(self.fwCodeRemoved) self.ui.barcodes_rev.rowAdded.connect(self.revCodeAdded) self.ui.barcodes_rev.rowChanged.connect(self.revCodeChanged) self.ui.barcodes_rev.rowRemoved.connect(self.revCodeRemoved) self.ui.barcodes_fw.valid.connect(self._validChanged) self.ui.barcodes_rev.valid.connect(self._validChanged) self.ui.named_inserts.valid.connect(self._validChanged) self.ui.insertSequence.textChanged.connect(self._validChanged) self.ui.dsiGrp.toggled.connect(self._validChanged) self.ui.dsiOnFw.toggled.connect(self._validChanged) self.ui.dsiOnRev.toggled.connect(self._validChanged)
def __init__(self, *args): super().__init__(BrickletPiezoBuzzer, *args) self.pb = self.device self.qtcb_beep_finished.connect(self.cb_beep) self.pb.register_callback(self.pb.CALLBACK_BEEP_FINISHED, self.qtcb_beep_finished.emit) self.qtcb_morse_finished.connect(self.cb_morse) self.pb.register_callback(self.pb.CALLBACK_MORSE_CODE_FINISHED, self.qtcb_morse_finished.emit) self.beep_edit = QLineEdit() self.beep_edit.setText(str(1000)) self.beep_label = QLabel('Duration [ms]:') self.beep_button = QPushButton('Send Beep') self.beep_layout = QHBoxLayout() self.beep_layout.addWidget(self.beep_label) self.beep_layout.addWidget(self.beep_edit) self.beep_layout.addWidget(self.beep_button) self.morse_edit = QLineEdit() self.morse_edit.setText('- .. -. -.- . .-. ..-. --- .-. --. .') self.morse_edit.setMaxLength(60) self.morse_edit.setValidator( QRegularExpressionValidator(QRegularExpression("[\\s|\\-|\\.]*"))) self.morse_label = QLabel('Morse Code:') self.morse_button = QPushButton('Send Morse Code') self.morse_layout = QHBoxLayout() self.morse_layout.addWidget(self.morse_label) self.morse_layout.addWidget(self.morse_edit) self.morse_layout.addWidget(self.morse_button) self.status_label = QLabel('Status: Idle') self.beep_button.clicked.connect(self.beep_clicked) self.morse_button.clicked.connect(self.morse_clicked) layout = QVBoxLayout(self) layout.addLayout(self.beep_layout) layout.addLayout(self.morse_layout) layout.addWidget(self.status_label) layout.addStretch()
def init_ui(self, hex_color=None): """.""" self.setMaxLength(7) self.setPlaceholderText('Hex colors. Eg.: #323232') self.setMaximumWidth(200) # attr self.default_color = hex_color if hex_color is not None else '#fff' self.button = QPushButton() self.button.setMaximumWidth(200) self.button.setStyleSheet( self.button_stylesheet_format.format(self.default_color)) self.color_dialog = QColorDialog() self.button.clicked.connect(self.button_click) regex = QRegularExpression(self.hexcolor_regex) validator = QRegularExpressionValidator(regex, parent=self.validator()) self.setValidator(validator) self.editingFinished.connect(self.update_button_color)
def __init__(self, config=None): QMainWindow.__init__(self) ApplicationSession.__init__(self, config) self.setupUi(self) self._channel = config.extra['channel'] self._subscriptions_ = [] self._controls = [ (self.bigFellaDial, self.bigFellaSlider), (self.smallBuddyDial, self.smallBuddySlider), (self.tinyLadDial, self.tinyLadSlider), (self.littlePalDial, self.littlePalSlider), ] for i, (_, slider) in enumerate(self._controls): slider.valueChanged.connect(partial(self.changeValue, i)) self.channelEdit.setValidator( QRegularExpressionValidator(CHANNEL_REGEXP)) self.channelEdit.setText(self._channel)
def _add_row(self): layout = QHBoxLayout() l_name = QLabel() le_score = QLineEdit() le_score.setAlignment(QtCore.Qt.AlignCenter) le_score.setValidator( QRegularExpressionValidator( QRegularExpression(f"[0-{config.MAX_PLAYOFF}]"), le_score)) l_fscore = QLabel() l_fscore.setAlignment(QtCore.Qt.AlignCenter) layout.addWidget(l_name) layout.addWidget(le_score) layout.addWidget(l_fscore) layout.setStretch(0, 10) layout.setStretch(1, 1) layout.setStretch(2, 1) self.rows.append(layout) self.name_labels.append(l_name) self.score_edits.append(le_score) self.fscore_labels.append(l_fscore) return layout, l_name, le_score, l_fscore
def __init__(self, items, parent=None): QWidget.__init__(self, parent) #Main Layout is a horizontal box self.setLayout(QHBoxLayout()) #Create the drop down menu and fill it with the table names self.combobox = QComboBox(self) self.combobox.addItems(items) self.layout().addWidget(self.combobox) self.le = QLineEdit(self) self.le.setValidator( QRegularExpressionValidator( QRegularExpression("^([0-9])+(,[0-9]+)*$"), self)) self.le.textChanged.connect(self.check_state) self.layout().addWidget(self.le) btnDelete = QToolButton(self) btnDelete.setIcon(QIcon.fromTheme("edit-delete")) self.layout().addWidget(btnDelete) btnDelete.clicked.connect(self.deleteLater)
def __init__(self, parent=None, aw=None, values=[0, 0]): super(pointDlg, self).__init__(parent, aw) self.values = values self.setWindowTitle( QApplication.translate("Form Caption", "Add Point", None)) self.tempEdit = QLineEdit(str(int(round(self.values[1])))) self.tempEdit.setValidator(QIntValidator(0, 999, self.tempEdit)) self.tempEdit.setFocus() self.tempEdit.setAlignment(Qt.AlignRight) templabel = QLabel(QApplication.translate("Label", "temp", None)) regextime = QRegularExpression(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$") self.timeEdit = QLineEdit( stringfromseconds(self.values[0], leadingzero=False)) self.timeEdit.setAlignment(Qt.AlignRight) self.timeEdit.setValidator(QRegularExpressionValidator( regextime, self)) timelabel = QLabel(QApplication.translate("Label", "time", None)) # connect the ArtisanDialog standard OK/Cancel buttons self.dialogbuttons.accepted.connect(self.return_values) self.dialogbuttons.rejected.connect(self.reject) buttonLayout = QHBoxLayout() buttonLayout.addStretch() buttonLayout.addWidget(self.dialogbuttons) grid = QGridLayout() grid.addWidget(timelabel, 0, 0) grid.addWidget(self.timeEdit, 0, 1) grid.addWidget(templabel, 1, 0) grid.addWidget(self.tempEdit, 1, 1) mainLayout = QVBoxLayout() mainLayout.addLayout(grid) mainLayout.addStretch() mainLayout.addLayout(buttonLayout) self.setLayout(mainLayout) self.dialogbuttons.button(QDialogButtonBox.Ok).setFocus()
def __init__(self, *args): super().__init__(BrickletPiezoSpeaker, *args) self.ps = self.device # the firmware version of a EEPROM Bricklet can (under common circumstances) # not change during the lifetime of an EEPROM Bricklet plugin. therefore, # it's okay to make final decisions based on it here self.has_stoppable_beep = self.firmware_version >= (2, 0, 2) self.qtcb_beep_finished.connect(self.cb_beep) self.ps.register_callback(self.ps.CALLBACK_BEEP_FINISHED, self.qtcb_beep_finished.emit) self.qtcb_morse_finished.connect(self.cb_morse) self.ps.register_callback(self.ps.CALLBACK_MORSE_CODE_FINISHED, self.qtcb_morse_finished.emit) self.frequency_label = QLabel('Frequency (585 - 7100 Hz):') self.frequency_box = QSpinBox() self.frequency_box.setMinimum(585) self.frequency_box.setMaximum(7100) self.frequency_box.setValue(1000) self.frequency_layout = QHBoxLayout() self.frequency_layout.addWidget(self.frequency_label) self.frequency_layout.addWidget(self.frequency_box) self.frequency_layout.addStretch() self.beep_box = QSpinBox() self.beep_box.setMinimum(0) self.beep_box.setMaximum(2147483647) self.beep_box.setValue(1000) self.beep_box.setSizePolicy(QSizePolicy.Expanding, QSizePolicy.Preferred) self.beep_label = QLabel('Duration [ms]:') self.beep_button = QPushButton('Send Beep') self.beep_layout = QHBoxLayout() self.beep_layout.addWidget(self.beep_label) self.beep_layout.addWidget(self.beep_box) self.beep_layout.addWidget(self.beep_button) self.morse_edit = QLineEdit() self.morse_edit.setText('- .. -. -.- . .-. ..-. --- .-. --. .') self.morse_edit.setMaxLength(60) self.morse_edit.setValidator( QRegularExpressionValidator(QRegularExpression("[\\s|\\-|\\.]*"))) self.morse_label = QLabel('Morse Code:') self.morse_button = QPushButton('Send Morse Code') self.morse_layout = QHBoxLayout() self.morse_layout.addWidget(self.morse_label) self.morse_layout.addWidget(self.morse_edit) self.morse_layout.addWidget(self.morse_button) self.calibrate_button = QPushButton('Calibrate') self.scale_button = QPushButton('Play Scale') self.scale_layout = QHBoxLayout() self.scale_layout.addWidget(self.scale_button) self.scale_layout.addWidget(self.calibrate_button) self.scale_layout.addStretch() self.scale_timer = QTimer(self) self.scale_timer.setInterval(25) self.scale_time = 585 self.status_label = QLabel('Status: Idle') self.beep_button.clicked.connect(self.beep_clicked) self.morse_button.clicked.connect(self.morse_clicked) self.scale_button.clicked.connect(self.scale_clicked) self.scale_timer.timeout.connect(self.scale_timeout) self.calibrate_button.clicked.connect(self.calibrate_clicked) layout = QVBoxLayout(self) layout.addLayout(self.frequency_layout) layout.addLayout(self.beep_layout) layout.addLayout(self.morse_layout) layout.addLayout(self.scale_layout) layout.addWidget(self.status_label) layout.addStretch()
def __init__(self, parent=None, aw=None): super(WindowsDlg, self).__init__(parent, aw) self.setWindowTitle( QApplication.translate("Form Caption", "Axes", None)) self.setModal(True) xlimitLabel = QLabel(QApplication.translate("Label", "Max", None)) xlimitLabel_min = QLabel(QApplication.translate("Label", "Min", None)) ylimitLabel = QLabel(QApplication.translate("Label", "Max", None)) ylimitLabel_min = QLabel(QApplication.translate("Label", "Min", None)) zlimitLabel = QLabel(QApplication.translate("Label", "Max", None)) zlimitLabel_min = QLabel(QApplication.translate("Label", "Min", None)) step100Label = QLabel( QApplication.translate("Label", "100% Event Step", None)) self.step100Edit = QLineEdit() self.step100Edit.setMaximumWidth(55) self.step100Edit.setValidator( QIntValidator(self.aw.qmc.ylimit_min_max, 999999, self.step100Edit)) self.step100Edit.setAlignment(Qt.AlignRight) self.step100Edit.setToolTip( QApplication.translate( "Tooltip", "100% event values in step mode are aligned with the given y-axis value or the lowest phases limit if left empty", None)) self.xlimitEdit = QLineEdit() self.xlimitEdit.setMaximumWidth(50) self.xlimitEdit.setMinimumWidth(50) self.xlimitEdit.setAlignment(Qt.AlignRight) self.xlimitEdit_min = QLineEdit() self.xlimitEdit_min.setMaximumWidth(55) self.xlimitEdit_min.setMinimumWidth(55) self.xlimitEdit_min.setAlignment(Qt.AlignRight) regextime = QRegularExpression(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$") self.xlimitEdit.setValidator( QRegularExpressionValidator(regextime, self)) self.xlimitEdit_min.setValidator( QRegularExpressionValidator(regextime, self)) self.ylimitEdit = QLineEdit() self.ylimitEdit.setMaximumWidth(60) self.ylimitEdit_min = QLineEdit() self.ylimitEdit_min.setMaximumWidth(60) self.ylimitEdit.setValidator( QIntValidator(self.aw.qmc.ylimit_min_max, self.aw.qmc.ylimit_max, self.ylimitEdit)) self.ylimitEdit_min.setValidator( QIntValidator(self.aw.qmc.ylimit_min_max, self.aw.qmc.ylimit_max, self.ylimitEdit_min)) self.ylimitEdit.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.ylimitEdit_min.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.zlimitEdit = QLineEdit() self.zlimitEdit.setMaximumWidth(60) self.zlimitEdit_min = QLineEdit() self.zlimitEdit_min.setMaximumWidth(60) self.zlimitEdit.setValidator( QIntValidator(self.aw.qmc.zlimit_min_max, self.aw.qmc.zlimit_max, self.zlimitEdit)) self.zlimitEdit_min.setValidator( QIntValidator(self.aw.qmc.zlimit_min_max, self.aw.qmc.zlimit_max, self.zlimitEdit_min)) self.zlimitEdit.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.zlimitEdit_min.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.xlimitEdit.setText(stringfromseconds(self.aw.qmc.endofx)) if self.aw.qmc.timeindex[0] != -1: self.xlimitEdit_min.setText( stringfromseconds(self.aw.qmc.startofx - self.aw.qmc.timex[self.aw.qmc.timeindex[0]])) else: self.xlimitEdit_min.setText(stringfromseconds( self.aw.qmc.startofx)) self.ylimitEdit.setText(str(self.aw.qmc.ylimit)) self.ylimitEdit_min.setText(str(self.aw.qmc.ylimit_min)) if self.aw.qmc.step100temp is not None: self.step100Edit.setText(str(self.aw.qmc.step100temp)) else: self.step100Edit.setText("") self.zlimitEdit.setText(str(self.aw.qmc.zlimit)) self.zlimitEdit_min.setText(str(self.aw.qmc.zlimit_min)) self.legendComboBox = QComboBox() self.legendComboBox.setMaximumWidth(160) legendlocs = [ "", #QApplication.translate("ComboBox", "none",None), QApplication.translate("ComboBox", "upper right", None), QApplication.translate("ComboBox", "upper left", None), QApplication.translate("ComboBox", "lower left", None), QApplication.translate("ComboBox", "lower right", None), QApplication.translate("ComboBox", "right", None), QApplication.translate("ComboBox", "center left", None), QApplication.translate("ComboBox", "center right", None), QApplication.translate("ComboBox", "lower center", None), QApplication.translate("ComboBox", "upper center", None), QApplication.translate("ComboBox", "center", None) ] self.legendComboBox.addItems(legendlocs) self.legendComboBox.setCurrentIndex(self.aw.qmc.legendloc) self.legendComboBox.currentIndexChanged.connect(self.changelegendloc) resettimelabel = QLabel(QApplication.translate("Label", "Max", None)) self.resetEdit = QLineEdit() self.resetEdit.setMaximumWidth(50) self.resetEdit.setMinimumWidth(50) self.resetEdit.setAlignment(Qt.AlignRight) regextime = QRegularExpression(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$") self.resetEdit.setValidator( QRegularExpressionValidator(regextime, self)) self.resetEdit.setText(stringfromseconds(self.aw.qmc.resetmaxtime)) self.resetEdit.setToolTip( QApplication.translate("Tooltip", "Time axis max on RESET", None)) # CHARGE min chargeminlabel = QLabel( QApplication.translate("Label", "RESET", None) + " " + QApplication.translate("Label", "Min", None)) self.chargeminEdit = QLineEdit() self.chargeminEdit.setMaximumWidth(50) self.chargeminEdit.setMinimumWidth(50) self.chargeminEdit.setAlignment(Qt.AlignRight) self.chargeminEdit.setValidator( QRegularExpressionValidator(regextime, self)) self.chargeminEdit.setText(stringfromseconds( self.aw.qmc.chargemintime)) self.chargeminEdit.setToolTip( QApplication.translate("Tooltip", "Time axis min on RESET", None)) # fixmaxtime flag self.fixmaxtimeFlag = QCheckBox( QApplication.translate("CheckBox", "Expand", None)) self.fixmaxtimeFlag.setChecked(not self.aw.qmc.fixmaxtime) self.fixmaxtimeFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically extend the time axis by 3min on need", None)) # locktimex flag self.locktimexFlag = QCheckBox( QApplication.translate("CheckBox", "Lock", None)) self.locktimexFlag.setChecked(self.aw.qmc.locktimex) self.locktimexFlag.stateChanged.connect(self.lockTimexFlagChanged) self.locktimexFlag.setToolTip( QApplication.translate( "Tooltip", "Do not set time axis min and max from profile on load", None)) # autotimex flag self.autotimexFlag = QCheckBox( QApplication.translate("CheckBox", "Auto", None)) self.autotimexFlag.setChecked(self.aw.qmc.autotimex) self.autotimexFlag.stateChanged.connect(self.autoTimexFlagChanged) self.autotimexFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically set time axis min and max from profile CHARGE/DROP events", None)) autoButton = QPushButton(QApplication.translate( "Button", "Calc", None)) autoButton.setFocusPolicy(Qt.NoFocus) autoButton.clicked.connect(self.autoAxis) # time axis steps timegridlabel = QLabel(QApplication.translate("Label", "Step", None)) self.xaxislencombobox = QComboBox() timelocs = [ #QApplication.translate("ComboBox", "30 seconds",None), QApplication.translate("ComboBox", "1 minute", None), QApplication.translate("ComboBox", "2 minutes", None), QApplication.translate("ComboBox", "3 minutes", None), QApplication.translate("ComboBox", "4 minutes", None), QApplication.translate("ComboBox", "5 minutes", None), QApplication.translate("ComboBox", "10 minutes", None), QApplication.translate("ComboBox", "30 minutes", None), QApplication.translate("ComboBox", "1 hour", None) ] self.xaxislencombobox.addItems(timelocs) self.xaxislencombobox.setMinimumContentsLength(6) width = self.xaxislencombobox.minimumSizeHint().width() self.xaxislencombobox.setMinimumWidth(width) if platform.system() == 'Darwin': self.xaxislencombobox.setMaximumWidth(width) # self.xaxislencombobox.setMaximumWidth(120) self.timeconversion = [60, 120, 180, 240, 300, 600, 1800, 3600] try: self.xaxislencombobox.setCurrentIndex( self.timeconversion.index(self.aw.qmc.xgrid)) except Exception: self.xaxislencombobox.setCurrentIndex(0) self.xaxislencombobox.currentIndexChanged.connect(self.xaxislenloc) self.timeGridCheckBox = QCheckBox( QApplication.translate("CheckBox", "Time", None)) self.timeGridCheckBox.setChecked(self.aw.qmc.time_grid) self.timeGridCheckBox.setToolTip( QApplication.translate("Tooltip", "Show time grid", None)) self.timeGridCheckBox.setFocusPolicy(Qt.NoFocus) self.tempGridCheckBox = QCheckBox( QApplication.translate("CheckBox", "Temp", None)) self.tempGridCheckBox.setToolTip( QApplication.translate("Tooltip", "Show temperature grid", None)) self.tempGridCheckBox.setChecked(self.aw.qmc.temp_grid) self.tempGridCheckBox.setFocusPolicy(Qt.NoFocus) ygridlabel = QLabel(QApplication.translate("Label", "Step", None)) self.ygridSpinBox = QSpinBox() self.ygridSpinBox.setRange(10, 500) self.ygridSpinBox.setSingleStep(5) self.ygridSpinBox.setValue(self.aw.qmc.ygrid) self.ygridSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.ygridSpinBox.valueChanged.connect(self.changeygrid) self.ygridSpinBox.setMaximumWidth(60) zgridlabel = QLabel(QApplication.translate("Label", "Step", None)) self.zgridSpinBox = QSpinBox() self.zgridSpinBox.setRange(1, 100) self.zgridSpinBox.setSingleStep(5) self.zgridSpinBox.setValue(self.aw.qmc.zgrid) self.zgridSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) self.zgridSpinBox.valueChanged.connect(self.changezgrid) self.zgridSpinBox.setMaximumWidth(60) self.autodeltaxLabel = QLabel( QApplication.translate("CheckBox", "Auto", None)) self.autodeltaxETFlag = QCheckBox( deltaLabelUTF8 + QApplication.translate("CheckBox", "ET", None)) self.autodeltaxETFlag.setChecked(self.aw.qmc.autodeltaxET) self.autodeltaxBTFlag = QCheckBox( deltaLabelUTF8 + QApplication.translate("CheckBox", "BT", None)) self.autodeltaxBTFlag.setChecked(self.aw.qmc.autodeltaxBT) self.autodeltaxETFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically set delta axis max from DeltaET", None)) self.autodeltaxBTFlag.setToolTip( QApplication.translate( "Tooltip", "Automatically set delta axis max from DeltaBT", None)) autoDeltaButton = QPushButton( QApplication.translate("Button", "Calc", None)) autoDeltaButton.setFocusPolicy(Qt.NoFocus) autoDeltaButton.clicked.connect(self.autoDeltaAxis) linestylegridlabel = QLabel( QApplication.translate("Label", "Style", None)) self.gridstylecombobox = QComboBox() gridstyles = [ QApplication.translate("ComboBox", "solid", None), QApplication.translate("ComboBox", "dashed", None), QApplication.translate("ComboBox", "dashed-dot", None), QApplication.translate("ComboBox", "dotted", None), QApplication.translate("ComboBox", "None", None) ] self.gridstylecombobox.addItems(gridstyles) self.gridstylecombobox.setCurrentIndex(self.aw.qmc.gridlinestyle) self.gridstylecombobox.currentIndexChanged.connect( self.changegridstyle) gridthicknesslabel = QLabel( QApplication.translate("Label", "Width", None)) self.gridwidthSpinBox = QSpinBox() self.gridwidthSpinBox.setRange(1, 5) self.gridwidthSpinBox.setValue(self.aw.qmc.gridthickness) self.gridwidthSpinBox.valueChanged.connect(self.changegridwidth) self.gridwidthSpinBox.setMaximumWidth(40) self.gridwidthSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) gridalphalabel = QLabel( QApplication.translate("Label", "Opaqueness", None)) self.gridalphaSpinBox = QSpinBox() self.gridalphaSpinBox.setRange(1, 10) self.gridalphaSpinBox.setValue(int(self.aw.qmc.gridalpha * 10)) self.gridalphaSpinBox.valueChanged.connect(self.changegridalpha) self.gridalphaSpinBox.setMaximumWidth(40) self.gridalphaSpinBox.setAlignment(Qt.AlignRight | Qt.AlignTrailing | Qt.AlignVCenter) # connect the ArtisanDialog standard OK/Cancel buttons self.dialogbuttons.accepted.connect(self.updatewindow) self.dialogbuttons.rejected.connect(self.close) resetButton = self.dialogbuttons.addButton( QDialogButtonBox.RestoreDefaults) resetButton.clicked.connect(self.reset) if self.aw.locale not in self.aw.qtbase_locales: resetButton.setText( QApplication.translate("Button", "Defaults", None)) self.loadAxisFromProfile = QCheckBox( QApplication.translate("CheckBox", "Load from profile", None)) self.loadAxisFromProfile.setChecked(self.aw.qmc.loadaxisfromprofile) hline = QFrame() hline.setFrameShape(QFrame.HLine) hline.setFrameShadow(QFrame.Sunken) hline2 = QFrame() hline2.setFrameShape(QFrame.HLine) hline2.setFrameShadow(QFrame.Sunken) xlayout1 = QHBoxLayout() xlayout1.addWidget(self.autotimexFlag) xlayout1.addWidget(autoButton) xlayout1.addStretch() xlayout1.addWidget(self.locktimexFlag) xlayout2 = QHBoxLayout() xlayout2.addWidget(xlimitLabel_min) xlayout2.addWidget(self.xlimitEdit_min) xlayout2.addSpacing(10) xlayout2.addWidget(xlimitLabel) xlayout2.addWidget(self.xlimitEdit) xlayout2.addStretch() xlayout2.addWidget(timegridlabel) xlayout2.addWidget(self.xaxislencombobox) xlayout3 = QHBoxLayout() xlayout3.addWidget(chargeminlabel) xlayout3.addWidget(self.chargeminEdit) xlayout3.addSpacing(7) xlayout3.addWidget(resettimelabel) xlayout3.addWidget(self.resetEdit) xlayout3.addSpacing(7) xlayout3.addStretch() xlayout3.addWidget(self.fixmaxtimeFlag) xlayout = QVBoxLayout() xlayout.addLayout(xlayout1) xlayout.addLayout(xlayout2) xlayout.addWidget(hline) xlayout.addLayout(xlayout3) ylayout = QGridLayout() ylayout.addWidget(ylimitLabel_min, 0, 0, Qt.AlignRight) ylayout.addWidget(self.ylimitEdit_min, 0, 1) ylayout.addWidget(ylimitLabel, 0, 3, Qt.AlignRight) ylayout.addWidget(self.ylimitEdit, 0, 4) ylayout.addWidget(ygridlabel, 0, 6, Qt.AlignRight) ylayout.addWidget(self.ygridSpinBox, 0, 7) ylayout.setColumnMinimumWidth(2, 10) ylayout.setColumnMinimumWidth(5, 10) ylayoutHbox = QHBoxLayout() ylayoutHbox.addStretch() ylayoutHbox.addLayout(ylayout) ylayoutHbox.addStretch() steplayoutHbox = QHBoxLayout() steplayoutHbox.addWidget(step100Label) steplayoutHbox.addWidget(self.step100Edit) steplayoutHbox.addStretch() ylayoutVbox = QVBoxLayout() ylayoutVbox.addLayout(ylayoutHbox) ylayoutVbox.addWidget(hline) ylayoutVbox.addLayout(steplayoutHbox) ylayoutVbox.addStretch() zlayout1 = QHBoxLayout() zlayout1.addWidget(self.autodeltaxLabel) zlayout1.addSpacing(5) zlayout1.addWidget(self.autodeltaxETFlag) zlayout1.addSpacing(5) zlayout1.addWidget(self.autodeltaxBTFlag) zlayout1.addSpacing(5) zlayout1.addWidget(autoDeltaButton) zlayout1.addStretch() zlayout = QGridLayout() zlayout.addWidget(zlimitLabel_min, 0, 0, Qt.AlignRight) zlayout.addWidget(self.zlimitEdit_min, 0, 1) zlayout.addWidget(zlimitLabel, 0, 3, Qt.AlignRight) zlayout.addWidget(self.zlimitEdit, 0, 4) zlayout.addWidget(zgridlabel, 0, 6, Qt.AlignRight) zlayout.addWidget(self.zgridSpinBox, 0, 7) zlayout.setColumnMinimumWidth(2, 10) zlayout.setColumnMinimumWidth(5, 10) zlayoutHbox = QHBoxLayout() zlayoutHbox.addStretch() zlayoutHbox.addLayout(zlayout) zlayoutHbox.addStretch() zlayoutVbox = QVBoxLayout() zlayoutVbox.addLayout(zlayout1) zlayoutVbox.addLayout(zlayoutHbox) zlayoutVbox.addStretch() legentlayout = QHBoxLayout() legentlayout.addStretch() legentlayout.addWidget(self.legendComboBox, 0, Qt.AlignLeft) legentlayout.addStretch() graphgridlayout = QGridLayout() graphgridlayout.addWidget(linestylegridlabel, 1, 0, Qt.AlignRight) graphgridlayout.addWidget(self.gridstylecombobox, 1, 1, Qt.AlignLeft) graphgridlayout.addWidget(gridthicknesslabel, 1, 2, Qt.AlignRight) graphgridlayout.addWidget(self.gridwidthSpinBox, 1, 3, Qt.AlignLeft) graphgridlayout.addWidget(self.timeGridCheckBox, 2, 0, Qt.AlignLeft) graphgridlayout.addWidget(self.tempGridCheckBox, 2, 1, Qt.AlignLeft) graphgridlayout.addWidget(gridalphalabel, 2, 2, Qt.AlignRight) graphgridlayout.addWidget(self.gridalphaSpinBox, 2, 3, Qt.AlignLeft) xGroupLayout = QGroupBox( QApplication.translate("GroupBox", "Time Axis", None)) xGroupLayout.setLayout(xlayout) yGroupLayout = QGroupBox( QApplication.translate("GroupBox", "Temperature Axis", None)) yGroupLayout.setLayout(ylayoutVbox) zGroupLayout = QGroupBox( deltaLabelUTF8 + " " + QApplication.translate("GroupBox", "Axis", None)) zGroupLayout.setLayout(zlayoutVbox) legendLayout = QGroupBox( QApplication.translate("GroupBox", "Legend Location", None)) legendLayout.setLayout(legentlayout) GridGroupLayout = QGroupBox( QApplication.translate("GroupBox", "Grid", None)) GridGroupLayout.setLayout(graphgridlayout) buttonLayout = QHBoxLayout() buttonLayout.addWidget(self.loadAxisFromProfile) buttonLayout.addSpacing(10) buttonLayout.addWidget(self.dialogbuttons) mainLayout1 = QVBoxLayout() mainLayout1.addWidget(xGroupLayout) mainLayout1.addWidget(yGroupLayout) mainLayout1.addStretch() mainLayout2 = QVBoxLayout() mainLayout2.addWidget(legendLayout) mainLayout2.addWidget(GridGroupLayout) mainLayout2.addWidget(zGroupLayout) mainLayout2.addStretch() mainHLayout = QHBoxLayout() mainHLayout.addLayout(mainLayout1) mainHLayout.addLayout(mainLayout2) mainLayout = QVBoxLayout() mainLayout.addLayout(mainHLayout) mainLayout.addStretch() mainLayout.addLayout(buttonLayout) self.setLayout(mainLayout) self.dialogbuttons.button(QDialogButtonBox.Ok).setFocus() if self.aw.qmc.locktimex: self.disableXAxisControls() else: self.enableXAxisControls() settings = QSettings() if settings.contains("AxisPosition"): self.move(settings.value("AxisPosition")) mainLayout.setSizeConstraint(QLayout.SetFixedSize)
def VersionValidator(parent): validator = QRegularExpressionValidator(parent) validator.setRegularExpression(QRegularExpression("([0-9]+\\.[0-9]+\\.[0-9]+)?")) return validator
def __init__(self, parent, on_download: bool, job_codes: List[str]) -> None: """ Prompt user to enter a Job Code, either at the time a download starts, or to zero or more selected files before the download begins. :param parent: rapidApp main window :param on_download: if True, dialog is being prompted for before a download starts. :param job_codes: """ super().__init__(parent) self.rapidApp = parent # type: 'RapidWindow' self.prefs = self.rapidApp.prefs # type: Preferences thumbnailModel = self.rapidApp.thumbnailModel # Whether the user has opened this dialog before a download starts without # having selected any files first no_selection_made = None # type: Optional[bool] if on_download: directive = _("Enter a new Job Code, or select a previous one") file_types = thumbnailModel.getNoFilesJobCodeNeeded() details = file_types.file_types_present_details(title_case=False) if sum(file_types.values()) == 1: # Translators: the value substituted will be something like '1 photo'. file_details = (_( "The Job Code will be applied to %s that does not yet have a " "Job Code.") % details) else: # Translators: the value substituted will be something like # '85 photos and 5 videos'. file_details = (_( "The Job Code will be applied to %s that do not yet have a " "Job Code.") % details) hint = ( "<b>Hint:</b> To assign Job Codes before the download begins, select " "photos or videos and apply a new or existing Job Code to them via the " "Job Code panel.") file_details = "{}<br><br><i>{}</i>".format(file_details, hint) title = _("Apply Job Code to Download") else: directive = _("Enter a new Job Code") file_types = thumbnailModel.getNoFilesSelected() no_selection_made = sum(file_types.values()) == 0 if no_selection_made: file_details = ("<i>" + _( "<b>Hint:</b> Select photos or videos before entering a new " "Job Code to have the Job Code applied to them.") + "</i>") _("") else: details = file_types.file_types_present_details( title_case=False) # Translators: the value substituted will be something like # '100 photos and 5 videos'. file_details = ( "<i>" + _("The new Job Code will be applied to %s.") % details + "</i>") title = _("New Job Code") instructionLabel = QLabel("<b>%s</b><br><br>%s<br>" % (directive, file_details)) instructionLabel.setWordWrap(True) self.jobCodeComboBox = QComboBox() self.jobCodeComboBox.addItems(job_codes) self.jobCodeComboBox.setEditable(True) if not self.prefs.strip_characters: exp = "[^/\\0]+" else: exp = '[^\\:\*\?"<>|\\0/]+' self.jobCodeExp = QRegularExpression() self.jobCodeExp.setPattern(exp) self.jobCodeValidator = QRegularExpressionValidator( self.jobCodeExp, self.jobCodeComboBox) self.jobCodeComboBox.setValidator(self.jobCodeValidator) if not on_download: self.jobCodeComboBox.clearEditText() if self.prefs.job_code_sort_key == 0: if self.prefs.job_code_sort_order == 0: self.jobCodeComboBox.setInsertPolicy(QComboBox.InsertAtTop) else: self.jobCodeComboBox.setInsertPolicy(QComboBox.InsertAtBottom) else: self.jobCodeComboBox.setInsertPolicy( QComboBox.InsertAlphabetically) icon = QIcon(":/rapid-photo-downloader.svg").pixmap(standardIconSize()) iconLabel = QLabel() iconLabel.setPixmap(icon) iconLabel.setAlignment(Qt.AlignTop | Qt.AlignLeft) iconLabel.setSizePolicy(QSizePolicy.Minimum, QSizePolicy.Minimum) jobCodeLabel = QLabel(_("&Job Code:")) jobCodeLabel.setBuddy(self.jobCodeComboBox) if on_download or not no_selection_made: self.rememberCheckBox = QCheckBox(_("&Remember this Job Code")) self.rememberCheckBox.setChecked(parent.prefs.remember_job_code) buttonBox = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) translateDialogBoxButtons(buttonBox) grid = QGridLayout() grid.addWidget(iconLabel, 0, 0, 4, 1) grid.addWidget(instructionLabel, 0, 1, 1, 2) grid.addWidget(jobCodeLabel, 1, 1) grid.addWidget(self.jobCodeComboBox, 1, 2) if hasattr(self, "rememberCheckBox"): grid.addWidget(self.rememberCheckBox, 2, 1, 1, 2) grid.addWidget(buttonBox, 3, 0, 1, 3) else: grid.addWidget(buttonBox, 2, 0, 1, 3) grid.setColumnStretch(2, 1) self.setLayout(grid) self.setWindowTitle(title) buttonBox.accepted.connect(self.accept) buttonBox.rejected.connect(self.reject)
def __init__(self, parent=None, aw=None): super(designerconfigDlg, self).__init__(parent, aw) self.setWindowTitle( QApplication.translate("Form Caption", "Designer Config", None)) self.setModal(True) #landmarks charge = QLabel(QApplication.translate("Label", "CHARGE", None)) charge.setAlignment(Qt.AlignRight) charge.setStyleSheet("background-color: #f07800") self.dryend = QCheckBox( QApplication.translate("CheckBox", "DRY END", None)) self.dryend.setStyleSheet("background-color: orange") self.fcs = QCheckBox( QApplication.translate("CheckBox", "FC START", None)) self.fcs.setStyleSheet("background-color: orange") self.fce = QCheckBox(QApplication.translate("CheckBox", "FC END", None)) self.fce.setStyleSheet("background-color: orange") self.scs = QCheckBox( QApplication.translate("CheckBox", "SC START", None)) self.scs.setStyleSheet("background-color: orange") self.sce = QCheckBox(QApplication.translate("CheckBox", "SC END", None)) self.sce.setStyleSheet("background-color: orange") drop = QLabel(QApplication.translate("Label", "DROP", None)) drop.setAlignment(Qt.AlignRight) drop.setStyleSheet("background-color: #f07800") self.loadconfigflags() self.dryend.clicked.connect(self.changeflags) self.fcs.clicked.connect(self.changeflags) self.fce.clicked.connect(self.changeflags) self.scs.clicked.connect(self.changeflags) self.sce.clicked.connect(self.changeflags) if self.aw.qmc.timeindex[0] != -1: start = self.aw.qmc.timex[self.aw.qmc.timeindex[0]] else: start = 0 markersettinglabel = QLabel( QApplication.translate("Label", "Marker", None)) markersettinglabel.setAlignment(Qt.AlignCenter) timesettinglabel = QLabel(QApplication.translate( "Label", "Time", None)) timesettinglabel.setAlignment(Qt.AlignCenter) btsettinglabel = QLabel(QApplication.translate("Label", "BT", None)) btsettinglabel.setAlignment(Qt.AlignCenter) etsettinglabel = QLabel(QApplication.translate("Label", "ET", None)) etsettinglabel.setAlignment(Qt.AlignCenter) self.Edit0 = QLineEdit(stringfromseconds(0)) self.Edit0.setEnabled(False) self.Edit0bt = QLineEdit("%.1f" % self.aw.qmc.temp2[self.aw.qmc.timeindex[0]]) self.Edit0et = QLineEdit("%.1f" % self.aw.qmc.temp1[self.aw.qmc.timeindex[0]]) self.Edit0.setAlignment(Qt.AlignRight) self.Edit0bt.setAlignment(Qt.AlignRight) self.Edit0et.setAlignment(Qt.AlignRight) if self.aw.qmc.timeindex[1]: self.Edit1 = QLineEdit( stringfromseconds(self.aw.qmc.timex[self.aw.qmc.timeindex[1]] - start)) self.Edit1bt = QLineEdit( "%.1f" % self.aw.qmc.temp2[self.aw.qmc.timeindex[1]]) self.Edit1et = QLineEdit( "%.1f" % self.aw.qmc.temp1[self.aw.qmc.timeindex[1]]) else: self.Edit1 = QLineEdit(stringfromseconds(0)) self.Edit1bt = QLineEdit("0.0") self.Edit1et = QLineEdit("0.0") self.Edit1.setAlignment(Qt.AlignRight) self.Edit1bt.setAlignment(Qt.AlignRight) self.Edit1et.setAlignment(Qt.AlignRight) if self.aw.qmc.timeindex[2]: self.Edit2 = QLineEdit( stringfromseconds(self.aw.qmc.timex[self.aw.qmc.timeindex[2]] - start)) self.Edit2bt = QLineEdit( "%.1f" % self.aw.qmc.temp2[self.aw.qmc.timeindex[2]]) self.Edit2et = QLineEdit( "%.1f" % self.aw.qmc.temp1[self.aw.qmc.timeindex[2]]) else: self.Edit2 = QLineEdit(stringfromseconds(0)) self.Edit2bt = QLineEdit("0.0") self.Edit2et = QLineEdit("0.0") self.Edit2.setAlignment(Qt.AlignRight) self.Edit2bt.setAlignment(Qt.AlignRight) self.Edit2et.setAlignment(Qt.AlignRight) if self.aw.qmc.timeindex[3]: self.Edit3 = QLineEdit( stringfromseconds(self.aw.qmc.timex[self.aw.qmc.timeindex[3]] - start)) self.Edit3bt = QLineEdit( "%.1f" % self.aw.qmc.temp2[self.aw.qmc.timeindex[3]]) self.Edit3et = QLineEdit( "%.1f" % self.aw.qmc.temp1[self.aw.qmc.timeindex[3]]) else: self.Edit3 = QLineEdit(stringfromseconds(0)) self.Edit3bt = QLineEdit("0.0") self.Edit3et = QLineEdit("0.0") self.Edit3.setAlignment(Qt.AlignRight) self.Edit3bt.setAlignment(Qt.AlignRight) self.Edit3et.setAlignment(Qt.AlignRight) if self.aw.qmc.timeindex[4]: self.Edit4 = QLineEdit( stringfromseconds(self.aw.qmc.timex[self.aw.qmc.timeindex[4]] - start)) self.Edit4bt = QLineEdit( "%.1f" % self.aw.qmc.temp2[self.aw.qmc.timeindex[4]]) self.Edit4et = QLineEdit( "%.1f" % self.aw.qmc.temp1[self.aw.qmc.timeindex[4]]) else: self.Edit4 = QLineEdit(stringfromseconds(0)) self.Edit4bt = QLineEdit("0.0") self.Edit4et = QLineEdit("0.0") self.Edit4.setAlignment(Qt.AlignRight) self.Edit4bt.setAlignment(Qt.AlignRight) self.Edit4et.setAlignment(Qt.AlignRight) if self.aw.qmc.timeindex[5]: self.Edit5 = QLineEdit( stringfromseconds(self.aw.qmc.timex[self.aw.qmc.timeindex[5]] - start)) self.Edit5bt = QLineEdit( "%.1f" % self.aw.qmc.temp2[self.aw.qmc.timeindex[5]]) self.Edit5et = QLineEdit( "%.1f" % self.aw.qmc.temp1[self.aw.qmc.timeindex[5]]) else: self.Edit5 = QLineEdit(stringfromseconds(0)) self.Edit5bt = QLineEdit("0.0") self.Edit5et = QLineEdit("0.0") self.Edit5.setAlignment(Qt.AlignRight) self.Edit5bt.setAlignment(Qt.AlignRight) self.Edit5et.setAlignment(Qt.AlignRight) if self.aw.qmc.timeindex[6]: self.Edit6 = QLineEdit( stringfromseconds(self.aw.qmc.timex[self.aw.qmc.timeindex[6]] - start)) self.Edit6bt = QLineEdit( "%.1f" % self.aw.qmc.temp2[self.aw.qmc.timeindex[6]]) self.Edit6et = QLineEdit( "%.1f" % self.aw.qmc.temp1[self.aw.qmc.timeindex[6]]) else: self.Edit6 = QLineEdit(stringfromseconds(0)) self.Edit6bt = QLineEdit("0.0") self.Edit6et = QLineEdit("0.0") self.Edit6.setAlignment(Qt.AlignRight) self.Edit6bt.setAlignment(Qt.AlignRight) self.Edit6et.setAlignment(Qt.AlignRight) maxwidth = 70 self.Edit0.setMaximumWidth(maxwidth) self.Edit1.setMaximumWidth(maxwidth) self.Edit2.setMaximumWidth(maxwidth) self.Edit3.setMaximumWidth(maxwidth) self.Edit4.setMaximumWidth(maxwidth) self.Edit5.setMaximumWidth(maxwidth) self.Edit6.setMaximumWidth(maxwidth) self.Edit0bt.setMaximumWidth(maxwidth) self.Edit1bt.setMaximumWidth(maxwidth) self.Edit2bt.setMaximumWidth(maxwidth) self.Edit3bt.setMaximumWidth(maxwidth) self.Edit4bt.setMaximumWidth(maxwidth) self.Edit5bt.setMaximumWidth(maxwidth) self.Edit6bt.setMaximumWidth(maxwidth) self.Edit0et.setMaximumWidth(maxwidth) self.Edit1et.setMaximumWidth(maxwidth) self.Edit2et.setMaximumWidth(maxwidth) self.Edit3et.setMaximumWidth(maxwidth) self.Edit4et.setMaximumWidth(maxwidth) self.Edit5et.setMaximumWidth(maxwidth) self.Edit6et.setMaximumWidth(maxwidth) self.Edit1copy = self.Edit1.text() self.Edit2copy = self.Edit2.text() self.Edit3copy = self.Edit3.text() self.Edit4copy = self.Edit4.text() self.Edit5copy = self.Edit5.text() self.Edit6copy = self.Edit6.text() self.Edit0btcopy = self.Edit0bt.text() self.Edit1btcopy = self.Edit1bt.text() self.Edit2btcopy = self.Edit2bt.text() self.Edit3btcopy = self.Edit3bt.text() self.Edit4btcopy = self.Edit4bt.text() self.Edit5btcopy = self.Edit5bt.text() self.Edit6btcopy = self.Edit6bt.text() self.Edit0etcopy = self.Edit0et.text() self.Edit1etcopy = self.Edit1et.text() self.Edit2etcopy = self.Edit2et.text() self.Edit3etcopy = self.Edit3et.text() self.Edit4etcopy = self.Edit4et.text() self.Edit5etcopy = self.Edit5et.text() self.Edit6etcopy = self.Edit6et.text() regextime = QRegularExpression(r"^-?[0-9]?[0-9]?[0-9]:[0-5][0-9]$") self.Edit0.setValidator(QRegularExpressionValidator(regextime, self)) self.Edit1.setValidator(QRegularExpressionValidator(regextime, self)) self.Edit2.setValidator(QRegularExpressionValidator(regextime, self)) self.Edit3.setValidator(QRegularExpressionValidator(regextime, self)) self.Edit4.setValidator(QRegularExpressionValidator(regextime, self)) self.Edit5.setValidator(QRegularExpressionValidator(regextime, self)) self.Edit6.setValidator(QRegularExpressionValidator(regextime, self)) regextemp = QRegularExpression(r"^-?[0-9]?[0-9]?[0-9]?\.?[0-9]?$") self.Edit0bt.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit1bt.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit2bt.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit3bt.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit4bt.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit5bt.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit6bt.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit0et.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit1et.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit2et.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit3et.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit4et.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit5et.setValidator(QRegularExpressionValidator(regextemp, self)) self.Edit6et.setValidator(QRegularExpressionValidator(regextemp, self)) curvinesslabel = QLabel( QApplication.translate("Label", "Curviness", None)) etcurviness = QLabel(QApplication.translate("Label", "ET", None)) btcurviness = QLabel(QApplication.translate("Label", "BT", None)) etcurviness.setAlignment(Qt.AlignRight) btcurviness.setAlignment(Qt.AlignRight) self.ETsplineComboBox = QComboBox() self.ETsplineComboBox.addItems(["1", "2", "3", "4", "5"]) self.ETsplineComboBox.setCurrentIndex(self.aw.qmc.ETsplinedegree - 1) self.ETsplineComboBox.currentIndexChanged.connect(self.redrawcurviness) self.BTsplineComboBox = QComboBox() self.BTsplineComboBox.addItems(["1", "2", "3", "4", "5"]) self.BTsplineComboBox.setCurrentIndex(self.aw.qmc.BTsplinedegree - 1) self.BTsplineComboBox.currentIndexChanged.connect(self.redrawcurviness) # connect the ArtisanDialog standard OK/Cancel buttons self.dialogbuttons.removeButton( self.dialogbuttons.button(QDialogButtonBox.Ok)) self.dialogbuttons.removeButton( self.dialogbuttons.button(QDialogButtonBox.Cancel)) self.dialogbuttons.addButton(QDialogButtonBox.Close) self.dialogbuttons.addButton(QDialogButtonBox.Apply) self.dialogbuttons.addButton(QDialogButtonBox.RestoreDefaults) if self.aw.locale not in self.aw.qtbase_locales: self.dialogbuttons.button( QDialogButtonBox.RestoreDefaults).setText( QApplication.translate("Button", "Reset", None)) self.dialogbuttons.rejected.connect(self.accept) self.dialogbuttons.button( QDialogButtonBox.RestoreDefaults).clicked.connect(self.reset) self.dialogbuttons.button(QDialogButtonBox.Apply).clicked.connect( self.settimes) buttonLayout = QHBoxLayout() buttonLayout.addStretch() buttonLayout.addWidget(self.dialogbuttons) marksLayout = QGridLayout() marksLayout.addWidget(markersettinglabel, 0, 0) marksLayout.addWidget(timesettinglabel, 0, 1) marksLayout.addWidget(btsettinglabel, 0, 2) marksLayout.addWidget(etsettinglabel, 0, 3) marksLayout.addWidget(charge, 1, 0) marksLayout.addWidget(self.Edit0, 1, 1) marksLayout.addWidget(self.Edit0bt, 1, 2) marksLayout.addWidget(self.Edit0et, 1, 3) marksLayout.addWidget(self.dryend, 2, 0) marksLayout.addWidget(self.Edit1, 2, 1) marksLayout.addWidget(self.Edit1bt, 2, 2) marksLayout.addWidget(self.Edit1et, 2, 3) marksLayout.addWidget(self.fcs, 3, 0) marksLayout.addWidget(self.Edit2, 3, 1) marksLayout.addWidget(self.Edit2bt, 3, 2) marksLayout.addWidget(self.Edit2et, 3, 3) marksLayout.addWidget(self.fce, 4, 0) marksLayout.addWidget(self.Edit3, 4, 1) marksLayout.addWidget(self.Edit3bt, 4, 2) marksLayout.addWidget(self.Edit3et, 4, 3) marksLayout.addWidget(self.scs, 5, 0) marksLayout.addWidget(self.Edit4, 5, 1) marksLayout.addWidget(self.Edit4bt, 5, 2) marksLayout.addWidget(self.Edit4et, 5, 3) marksLayout.addWidget(self.sce, 6, 0) marksLayout.addWidget(self.Edit5, 6, 1) marksLayout.addWidget(self.Edit5bt, 6, 2) marksLayout.addWidget(self.Edit5et, 6, 3) marksLayout.addWidget(drop, 7, 0) marksLayout.addWidget(self.Edit6, 7, 1) marksLayout.addWidget(self.Edit6bt, 7, 2) marksLayout.addWidget(self.Edit6et, 7, 3) settingsLayout = QVBoxLayout() settingsLayout.addLayout(marksLayout) curvinessLayout = QHBoxLayout() curvinessLayout.addWidget(curvinesslabel) curvinessLayout.addWidget(etcurviness) curvinessLayout.addWidget(self.ETsplineComboBox) curvinessLayout.addWidget(btcurviness) curvinessLayout.addWidget(self.BTsplineComboBox) modLayout = QVBoxLayout() modLayout.addLayout(curvinessLayout) marksGroupLayout = QGroupBox( QApplication.translate("GroupBox", "Initial Settings", None)) marksGroupLayout.setLayout(settingsLayout) mainLayout = QVBoxLayout() mainLayout.addWidget(marksGroupLayout) mainLayout.addLayout(modLayout) mainLayout.addLayout(buttonLayout) self.setLayout(mainLayout) self.dialogbuttons.button(QDialogButtonBox.Close).setFocus() settings = QSettings() if settings.contains("DesignerPosition"): self.move(settings.value("DesignerPosition")) mainLayout.setSizeConstraint(QLayout.SetFixedSize)
def VersionValidator(parent): validator = QRegularExpressionValidator(parent) validator.setRegularExpression( QRegularExpression("([0-9]+\\.[0-9]+\\.[0-9]+)?")) return validator
def __init__(self, target_path, src_is_dir=False, same_file=False, in_merge_op=False, *args, **kwargs): super().__init__(*args, **kwargs) self.setupUi(self) self.overwrite = OverwriteMode.PROMPT self.apply_to_all = False # self.allow_overwrite = True self.path = self.new_dest = PureCIPath(target_path) self._oname = self.new_name = self.path.name self.merging = in_merge_op ## just thinking about the possible permutations... # dir2dir = src_is_dir and target_path.is_dir # file2dir = target_path.is_dir and not src_is_dir # tofile = not target_path.is_dir # # self.btn_overwrite.setVisible(not same_file and not file2dir) # self.btn_merge.setVisible(not same_file and dir2dir) self.btn_skip.setVisible(self.merging) self.cbox_sticky.setVisible(self.merging) self.btn_overwrite.setVisible(False) self.btn_merge.setVisible(False) ## Set title, tweak button setup based on arguments ## if same_file: self.setWindowTitle("File exists.") # self.allow_overwrite = False # self.btn_overwrite.setVisible(False) # self.btn_merge.setVisible(False) self.label.setText( f"This operation would overwrite '{self.path}' with itself; please enter a new name:" ) elif target_path.is_dir: if src_is_dir: self.setWindowTitle("Destination directory exists.") # offer merge self.btn_overwrite.setVisible(True) self.btn_merge.setVisible(True) self.label.setText( f"This operation will overwrite '{self.path}'. How would you like to proceed?" ) else: self.setWindowTitle("Destination exists as directory.") # self.btn_overwrite.setVisible(False) # self.btn_merge.setVisible(False) self.label.setText( f"A directory with the name '{self.path.name}' already exists. Please enter a new name:" ) else: # target is a file, src is whatever self.setWindowTitle("File exists.") self.btn_overwrite.setVisible(True) # self.btn_merge.setVisible(False) self.label.setText( f"This operation will overwrite '{self.path}'. How would you like to proceed?" ) # self.label.setText(self.label.text().format(path=self.path)) ## Change 'OK' text ## self.okbutton: QPushButton = self.btnbox.button(QDialogButtonBox.Ok) self.okbutton.setText("Rename") self.okbutton.setEnabled(False) ## Setup Button actions ## self.btn_new_name.clicked.connect(self.on_suggest_new_name) self.btn_overwrite.clicked.connect(self.on_overwrite_clicked) self.btn_merge.clicked.connect(self.on_merge_clicked) self.btn_skip.clicked.connect(self.on_skip_clicked) # status msg for cbox if self.btn_overwrite.isVisible(): self.cbox_sticky.stateChanged.connect(self.on_cbox_changed) ## Set Default text for name field ## self.name_edit.setText(self._oname) self.name_edit.textChanged.connect(self.on_name_changed) ## list of current filenames in the destination ## self._dirnames = target_path.sparent.ls(conv=str.lower) # any char other than / or : or NUL (not sure how to specify that one...) # ; also exclude \ vre_str = r"[^/:\\]+" self.vre = QRegularExpression(vre_str) self.validator = QRegularExpressionValidator(self.vre) self.name_edit.setValidator(self.validator) # Also can't start with - or be . or .. # This one doesn't prevent entry, but disables the buttons # if the entered string matches self.reinvalid = re.compile(r"^(-.*|\.\.?$)")