eric7/Plugins/PluginWizardSetup.py

branch
eric7
changeset 9202
81388c6065e8
parent 9201
2f1ccadee231
--- a/eric7/Plugins/PluginWizardSetup.py	Sat Jul 02 18:53:56 2022 +0200
+++ b/eric7/Plugins/PluginWizardSetup.py	Sun Jul 03 13:52:59 2022 +0200
@@ -10,7 +10,6 @@
 import functools
 
 from PyQt6.QtCore import QObject
-from PyQt6.QtWidgets import QDialog
 
 from EricWidgets.EricApplication import ericApp
 from EricGui.EricAction import EricAction
@@ -140,32 +139,6 @@
         if menu:
             menu.addActions(self.__actions)
     
-    def __callForm(self, editor, category):
-        """
-        Private method to display a dialog and get the code.
-        
-        @param editor reference to the current editor
-        @type Editor
-        @param category category of setup file to create
-        @type str
-        @return tuple containing the generated code and a flag indicating an error
-        @rtype tuple of (str, bool)
-        """
-        from WizardPlugins.SetupWizard.SetupWizardDialog import (
-            SetupWizardDialog
-        )
-        dlg = SetupWizardDialog(category, self.__ui)
-        if dlg.exec() == QDialog.DialogCode.Accepted:
-            line, index = editor.getCursorPosition()
-            indLevel = editor.indentation(line) // editor.indentationWidth()
-            if editor.indentationsUseTabs():
-                indString = '\t'
-            else:
-                indString = editor.indentationWidth() * ' '
-            return (dlg.getCode(indLevel, indString), True)
-        else:
-            return ("", False)
-        
     def __handle(self, category):
         """
         Private method to handle the wizards action.
@@ -173,6 +146,10 @@
         @param category category of setup file to create
         @type str
         """
+        from WizardPlugins.SetupWizard.SetupWizardDialog import (
+            SetupWizardDialog
+        )
+        
         editor = ericApp().getObject("ViewManager").activeWindow()
         
         if editor is None:
@@ -181,13 +158,8 @@
                 self.tr('No current editor'),
                 self.tr('Please open or create a file first.'))
         else:
-            sourceCode, ok = self.__callForm(editor, category)
-            if ok:
-                line, index = editor.getCursorPosition()
-                # It should be done this way to allow undo
-                editor.beginUndoAction()
-                editor.insertAt(sourceCode, line, index)
-                editor.endUndoAction()
+            dlg = SetupWizardDialog(category, editor, self.__ui)
+            dlg.show()
 
 #
 # eflag: noqa = M801

eric ide

mercurial