85 self.__pyqt5Server.start( |
85 self.__pyqt5Server.start( |
86 sys.executable, [os.path.join( |
86 sys.executable, [os.path.join( |
87 os.path.dirname(__file__), "QRegularExpressionWizardServer.py") |
87 os.path.dirname(__file__), "QRegularExpressionWizardServer.py") |
88 ]) |
88 ]) |
89 if self.__pyqt5Server.waitForStarted(5000): |
89 if self.__pyqt5Server.waitForStarted(5000): |
90 self.__pyqt5Server.setReadChannel(QProcess.StandardOutput) |
90 self.__pyqt5Server.setReadChannel( |
|
91 QProcess.ProcessChannel.StandardOutput) |
91 if self.__sendCommand("available"): |
92 if self.__sendCommand("available"): |
92 response = self.__receiveResponse() |
93 response = self.__receiveResponse() |
93 if response and response["available"]: |
94 if response and response["available"]: |
94 self.__pyqt5Available = True |
95 self.__pyqt5Available = True |
95 |
96 |
96 self.saveButton = self.buttonBox.addButton( |
97 self.saveButton = self.buttonBox.addButton( |
97 self.tr("Save"), QDialogButtonBox.ActionRole) |
98 self.tr("Save"), QDialogButtonBox.ButtonRole.ActionRole) |
98 self.saveButton.setToolTip( |
99 self.saveButton.setToolTip( |
99 self.tr("Save the regular expression to a file")) |
100 self.tr("Save the regular expression to a file")) |
100 self.loadButton = self.buttonBox.addButton( |
101 self.loadButton = self.buttonBox.addButton( |
101 self.tr("Load"), QDialogButtonBox.ActionRole) |
102 self.tr("Load"), QDialogButtonBox.ButtonRole.ActionRole) |
102 self.loadButton.setToolTip( |
103 self.loadButton.setToolTip( |
103 self.tr("Load a regular expression from a file")) |
104 self.tr("Load a regular expression from a file")) |
104 if self.__pyqt5Available: |
105 if self.__pyqt5Available: |
105 self.validateButton = self.buttonBox.addButton( |
106 self.validateButton = self.buttonBox.addButton( |
106 self.tr("Validate"), QDialogButtonBox.ActionRole) |
107 self.tr("Validate"), QDialogButtonBox.ButtonRole.ActionRole) |
107 self.validateButton.setToolTip( |
108 self.validateButton.setToolTip( |
108 self.tr("Validate the regular expression")) |
109 self.tr("Validate the regular expression")) |
109 self.executeButton = self.buttonBox.addButton( |
110 self.executeButton = self.buttonBox.addButton( |
110 self.tr("Execute"), QDialogButtonBox.ActionRole) |
111 self.tr("Execute"), QDialogButtonBox.ButtonRole.ActionRole) |
111 self.executeButton.setToolTip( |
112 self.executeButton.setToolTip( |
112 self.tr("Execute the regular expression")) |
113 self.tr("Execute the regular expression")) |
113 self.nextButton = self.buttonBox.addButton( |
114 self.nextButton = self.buttonBox.addButton( |
114 self.tr("Next match"), QDialogButtonBox.ActionRole) |
115 self.tr("Next match"), QDialogButtonBox.ButtonRole.ActionRole) |
115 self.nextButton.setToolTip( |
116 self.nextButton.setToolTip( |
116 self.tr("Show the next match of the regular expression")) |
117 self.tr("Show the next match of the regular expression")) |
117 self.nextButton.setEnabled(False) |
118 self.nextButton.setEnabled(False) |
118 else: |
119 else: |
119 self.validateButton = None |
120 self.validateButton = None |
120 self.executeButton = None |
121 self.executeButton = None |
121 self.nextButton = None |
122 self.nextButton = None |
122 |
123 |
123 if fromEric: |
124 if fromEric: |
124 self.buttonBox.setStandardButtons( |
125 self.buttonBox.setStandardButtons( |
125 QDialogButtonBox.Cancel | QDialogButtonBox.Ok) |
126 QDialogButtonBox.StandardButton.Cancel | |
|
127 QDialogButtonBox.StandardButton.Ok) |
126 self.copyButton = None |
128 self.copyButton = None |
127 else: |
129 else: |
128 self.copyButton = self.buttonBox.addButton( |
130 self.copyButton = self.buttonBox.addButton( |
129 self.tr("Copy"), QDialogButtonBox.ActionRole) |
131 self.tr("Copy"), QDialogButtonBox.ButtonRole.ActionRole) |
130 self.copyButton.setToolTip( |
132 self.copyButton.setToolTip( |
131 self.tr("Copy the regular expression to the clipboard")) |
133 self.tr("Copy the regular expression to the clipboard")) |
132 self.buttonBox.setStandardButtons(QDialogButtonBox.Close) |
134 self.buttonBox.setStandardButtons( |
|
135 QDialogButtonBox.StandardButton.Close) |
133 self.variableLabel.hide() |
136 self.variableLabel.hide() |
134 self.variableLineEdit.hide() |
137 self.variableLineEdit.hide() |
135 self.variableLine.hide() |
138 self.variableLine.hide() |
136 self.regexpTextEdit.setFocus() |
139 self.regexpTextEdit.setFocus() |
137 |
140 |
745 |
749 |
746 regexp = self.regexpTextEdit.toPlainText() |
750 regexp = self.regexpTextEdit.toPlainText() |
747 |
751 |
748 options = [] |
752 options = [] |
749 if self.caseInsensitiveCheckBox.isChecked(): |
753 if self.caseInsensitiveCheckBox.isChecked(): |
750 options.append("QRegularExpression.CaseInsensitiveOption") |
754 options.append( |
|
755 "QRegularExpression.PatternOption.CaseInsensitiveOption") |
751 if self.multilineCheckBox.isChecked(): |
756 if self.multilineCheckBox.isChecked(): |
752 options.append("QRegularExpression.MultilineOption") |
757 options.append( |
|
758 "QRegularExpression.PatternOption.MultilineOption") |
753 if self.dotallCheckBox.isChecked(): |
759 if self.dotallCheckBox.isChecked(): |
754 options.append("QRegularExpression.DotMatchesEverythingOption") |
760 options.append( |
|
761 "QRegularExpression.PatternOption.DotMatchesEverythingOption") |
755 if self.extendedCheckBox.isChecked(): |
762 if self.extendedCheckBox.isChecked(): |
756 options.append("QRegularExpression.ExtendedPatternSyntaxOption") |
763 options.append( |
|
764 "QRegularExpression.PatternOption.ExtendedPatternSyntaxOption") |
757 if self.greedinessCheckBox.isChecked(): |
765 if self.greedinessCheckBox.isChecked(): |
758 options.append("QRegularExpression.InvertedGreedinessOption") |
766 options.append( |
|
767 "QRegularExpression.PatternOption.InvertedGreedinessOption") |
759 if self.unicodeCheckBox.isChecked(): |
768 if self.unicodeCheckBox.isChecked(): |
760 options.append("QRegularExpression.UseUnicodePropertiesOption") |
769 options.append( |
|
770 "QRegularExpression.PatternOption.UseUnicodePropertiesOption") |
761 if self.captureCheckBox.isChecked(): |
771 if self.captureCheckBox.isChecked(): |
762 options.append("QRegularExpression.DontCaptureOption") |
772 options.append( |
|
773 "QRegularExpression.PatternOption.DontCaptureOption") |
763 options = " |{0}{1}".format(os.linesep, i1string).join(options) |
774 options = " |{0}{1}".format(os.linesep, i1string).join(options) |
764 |
775 |
765 code = '{0} = QRegularExpression('.format(reVar) |
776 code = '{0} = QRegularExpression('.format(reVar) |
766 if options: |
777 if options: |
767 code += '{0}{1}r"""{2}""",'.format( |
778 code += '{0}{1}r"""{2}""",'.format( |