eric7/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py

branch
eric7
changeset 9068
d5b274508a0f
parent 8881
54e42bc2437a
child 9108
19a57544f32c
diff -r abad8563ee7d -r d5b274508a0f eric7/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py
--- a/eric7/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py	Tue May 17 08:51:43 2022 +0200
+++ b/eric7/Plugins/WizardPlugins/InputDialogWizard/InputDialogWizardDialog.py	Tue May 17 12:15:38 2022 +0200
@@ -32,7 +32,7 @@
         super().__init__(parent)
         self.setupUi(self)
         
-        # set the validators for the double line edots
+        # set the validators for the double line edits
         self.eDoubleDefault.setValidator(
             QDoubleValidator(-2147483647, 2147483647, 99, self.eDoubleDefault))
         self.eDoubleFrom.setValidator(
@@ -40,21 +40,46 @@
         self.eDoubleTo.setValidator(
             QDoubleValidator(-2147483647, 2147483647, 99, self.eDoubleTo))
         
+        self.rText.toggled.connect(self.__typeSelectButtonToggled)
+        self.rMultiLineText.toggled.connect(self.__typeSelectButtonToggled)
+        self.rInteger.toggled.connect(self.__typeSelectButtonToggled)
+        self.rDouble.toggled.connect(self.__typeSelectButtonToggled)
+        self.rItem.toggled.connect(self.__typeSelectButtonToggled)
+        
         self.bTest = self.buttonBox.addButton(
             self.tr("Test"), QDialogButtonBox.ButtonRole.ActionRole)
         
+        # simulate a dialog type selection
+        self.__typeSelectButtonToggled(True)
+        
         msh = self.minimumSizeHint()
         self.resize(max(self.width(), msh.width()), msh.height())
-        
+    
     @pyqtSlot(bool)
-    def on_rItem_toggled(self, checked):
+    def __typeSelectButtonToggled(self, checked):
+        """
+        Private slot to modify the dialog according to the selected type.
+        
+        Note: This is a multiplexed slot. Therefore it just reacts upon a
+        positive check state (i.e. checked == True).
+        
+        @param checked flag indicating the checked state
+        @type bool
         """
-        Private slot to perform actions dependant on the item type selection.
-        
-        @param checked flag indicating the checked state (boolean)
-        """
-        self.bTest.setEnabled(not checked)
-        
+        self.bTest.setEnabled(True)
+        if checked:
+            if self.rText.isChecked():
+                self.specificsStack.setCurrentWidget(self.textPage)
+            elif self.rMultiLineText.isChecked():
+                self.specificsStack.setCurrentWidget(self.multiLineTextPage)
+            elif self.rInteger.isChecked():
+                self.specificsStack.setCurrentWidget(self.integerPage)
+            elif self.rDouble.isChecked():
+                self.specificsStack.setCurrentWidget(self.doublePage)
+            elif self.rItem.isChecked():
+                self.specificsStack.setCurrentWidget(self.itemPage)
+                self.bTest.setEnabled(False)
+    
     def on_buttonBox_clicked(self, button):
         """
         Private slot called by a button of the button box clicked.
@@ -82,6 +107,12 @@
                 self.eLabel.text(),
                 echomode,
                 self.eTextDefault.text())
+        elif self.rMultiLineText.isChecked():
+            QInputDialog.getMultiLineText(
+                None,
+                self.eCaption.text(),
+                self.eLabel.text(),
+                self.eMultiTextDefault.toPlainText())
         elif self.rInteger.isChecked():
             QInputDialog.getInt(
                 None,
@@ -154,8 +185,31 @@
             else:
                 code += 'QLineEdit.EchoMode.Password'
             if self.eTextDefault.text():
-                code += ',{0}{1}self.tr("{2}")'.format(
-                    os.linesep, istring, self.eTextDefault.text())
+                if self.cTranslateTextDefault.isChecked():
+                    code += ',{0}{1}self.tr("{2}")'.format(
+                        os.linesep, istring, self.eTextDefault.text())
+                else:
+                    code += ',{0}{1}"{2}"'.format(
+                        os.linesep, istring, self.eTextDefault.text())
+            code += '{0}){0}'.format(estring)
+        elif self.rMultiLineText.isChecked():
+            code +='getMultiLineText({0}{1}'.format(os.linesep, istring)
+            code += '{0},{1}{2}'.format(parent, os.linesep, istring)
+            code += 'self.tr("{0}"),{1}{2}'.format(
+                self.eCaption.text(), os.linesep, istring)
+            code += 'self.tr("{0}")'.format(self.eLabel.text())
+            if self.eMultiTextDefault.toPlainText():
+                defTxt = "\\n".join(
+                    self.eMultiTextDefault.toPlainText().splitlines()
+                )
+                if self.cTranslateMultiTextDefault.isChecked():
+                    code += ',{0}{1}self.tr("{2}")'.format(
+                        os.linesep, istring,
+                        defTxt)
+                else:
+                    code += ',{0}{1}"{2}"'.format(
+                        os.linesep, istring,
+                        defTxt)
             code += '{0}){0}'.format(estring)
         elif self.rInteger.isChecked():
             code += 'getInt({0}{1}'.format(os.linesep, istring)

eric ide

mercurial