ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py

branch
eric7
changeset 55
5390ef66c327
parent 52
c264091162a2
child 60
85d3931419d3
--- a/ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py	Sat May 29 15:04:13 2021 +0200
+++ b/ProjectDjangoTagsMenu/DjangoTagsMenuHandler.py	Sun May 30 11:51:44 2021 +0200
@@ -10,11 +10,11 @@
 import os
 import datetime
 
-from PyQt5.QtCore import QObject
-from PyQt5.QtWidgets import QMenu, QInputDialog, QDialog, QApplication
+from PyQt6.QtCore import QObject
+from PyQt6.QtWidgets import QMenu, QInputDialog, QDialog, QApplication
 
-from E5Gui.E5Application import e5App
-from E5Gui import E5FileDialog, E5MessageBox
+from EricWidgets.EricApplication import ericApp
+from EricWidgets import EricFileDialog, EricMessageBox
 
 from .DjangoTagInputDialog import DjangoTagInputDialog
 
@@ -29,8 +29,10 @@
         """
         Constructor
         
-        @param ui reference to the user interface object (UI.UserInterface)
-        @param parent reference to the parent object (QObject)
+        @param ui reference to the user interface object
+        @type UserInterface
+        @param parent reference to the parent object
+        @type QObject
         """
         super().__init__(parent)
         self.__ui = ui
@@ -48,7 +50,8 @@
         """
         Public method to initialize the various menus.
         
-        @param mainMenu reference to the main tags menu (QMenu)
+        @param mainMenu reference to the main tags menu
+        @type QMenu
         """
         mainMenu.addAction(self.tr("Django Template Tags Locator"),
                            self.__findTemplateTag)
@@ -67,7 +70,8 @@
         """
         Private method to initialize the tags menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         menu = QMenu(self.tr("Tags"))
         menu.addAction(
@@ -185,7 +189,8 @@
         """
         Private method to initialize the filters menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         mainMenu = QMenu(self.tr("Filters"))
         
@@ -392,7 +397,8 @@
         """
         Private method to initialize the humanize menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         menu = QMenu(self.tr("Humanize"))
         menu.addAction(
@@ -428,7 +434,8 @@
         """
         Private method to initialize the web design menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         menu = QMenu(self.tr("Web Design"))
         menu.addAction(
@@ -446,7 +453,8 @@
         """
         Private method to initialize the static menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         menu = QMenu(self.tr("Static"))
         menu.addAction(
@@ -473,7 +481,8 @@
         """
         Private method to initialize the comments menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         menu = QMenu(self.tr("Comment"))
         menu.addAction(
@@ -519,7 +528,8 @@
         """
         Private method to initialize the static menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         mainMenu = QMenu(self.tr("Internationalization (i18n)"))
         mainMenu.addAction(
@@ -586,7 +596,8 @@
         """
         Private method to initialize the static menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         mainMenu = QMenu(self.tr("Localization (l10n)"))
         mainMenu.addAction(
@@ -619,7 +630,8 @@
         """
         Private method to initialize the static menu.
         
-        @return generated menu (QMenu)
+        @return generated menu
+        @rtype QMenu
         """
         mainMenu = QMenu(self.tr("Timezone (tz)"))
         mainMenu.addAction(
@@ -677,9 +689,10 @@
         """
         Private slot to generate and insert the template text.
         
-        @param tag name of the tag to insert (string)
+        @param tag name of the tag to insert
+        @type str
         """
-        editor = e5App().getObject("ViewManager").activeWindow()
+        editor = ericApp().getObject("ViewManager").activeWindow()
         if editor is None:
             return
         
@@ -698,10 +711,13 @@
         """
         Private slot to generate the template text.
         
-        @param tag name of the tag to insert (string)
-        @param selectedText selected text of the current editor (string)
-        @return tuple of generated template text (string), a flag indicating
-            to perform a replace operation (boolean)
+        @param tag name of the tag to insert
+        @type str
+        @param selectedText selected text of the current editor
+        @type str
+        @return tuple of generated template text, a flag indicating to perform
+            a replace operation
+        @rtype tuple of (str, bool)
         """
         replace = False         # safe value
         ok = True
@@ -807,7 +823,7 @@
         elif tag == "if":
             from .IfTagInputDialog import IfTagInputDialog
             dlg = IfTagInputDialog()
-            if dlg.exec() == QDialog.Accepted:
+            if dlg.exec() == QDialog.DialogCode.Accepted:
                 templateText = dlg.getTag()
         elif tag == "ifchanged":
             data, ok = DjangoTagInputDialog.getText(
@@ -901,7 +917,7 @@
             if ok:
                 templateText = '{{% ssi "{0}" parsed %}}'.format(data[0])
         elif tag == "ssifile":
-            ssi = E5FileDialog.getOpenFileName(
+            ssi = EricFileDialog.getOpenFileName(
                 None,
                 self.tr("SSI"),
                 os.path.expanduser("~"),
@@ -1307,7 +1323,7 @@
         elif tag == "lorem":
             from .LoremTagInputDialog import LoremTagInputDialog
             dlg = LoremTagInputDialog()
-            if dlg.exec() == QDialog.Accepted:
+            if dlg.exec() == QDialog.DialogCode.Accepted:
                 templateText = "{{% {0} %}}".format(dlg.getTag())
         
         ####################################################
@@ -1372,7 +1388,7 @@
             templateText = '{{% comment %}} {0} {{% endcomment %}}'.format(
                 QApplication.clipboard().text().strip())
         elif tag == "multilinecommentfile":
-            filename = E5FileDialog.getOpenFileName(
+            filename = EricFileDialog.getOpenFileName(
                 None,
                 self.tr("Comment File"),
                 Utilities.getHomeDir(),
@@ -1385,7 +1401,7 @@
                         '{{% comment %}} {0} {{% endcomment %}}'.format(
                             comment))
                 except (IOError, OSError) as err:
-                    E5MessageBox.critical(
+                    EricMessageBox.critical(
                         None,
                         self.tr("Comment File"),
                         self.tr("""<p>The file <b>{0}</b> could not be"""

eric ide

mercurial