eric6/WebBrowser/UrlBar/UrlBar.py

changeset 8143
2c730d5fd177
parent 7923
91e843545d9a
child 8205
4a0f1f896341
--- a/eric6/WebBrowser/UrlBar/UrlBar.py	Mon Mar 01 17:48:43 2021 +0100
+++ b/eric6/WebBrowser/UrlBar/UrlBar.py	Tue Mar 02 17:17:09 2021 +0100
@@ -52,7 +52,7 @@
         
         self.__bmActiveIcon = UI.PixmapCache.getIcon("bookmark16")
         self.__bmInactiveIcon = QIcon(
-            self.__bmActiveIcon.pixmap(16, 16, QIcon.Disabled))
+            self.__bmActiveIcon.pixmap(16, 16, QIcon.Mode.Disabled))
         
         self.__safeBrowsingLabel = SafeBrowsingLabel(self)
         self.addWidget(self.__safeBrowsingLabel, E5LineEdit.LeftSide)
@@ -205,7 +205,7 @@
         )
         url = self.__browser.url()
         dlg = BookmarkActionSelectionDialog(url)
-        if dlg.exec() == QDialog.Accepted:
+        if dlg.exec() == QDialog.DialogCode.Accepted:
             action = dlg.getAction()
             if action == BookmarkActionSelectionDialog.AddBookmark:
                 self.__browser.addBookmark()
@@ -235,12 +235,13 @@
         
         @param evt reference to the paint event (QPaintEvent)
         """
-        foregroundColor = QApplication.palette().color(QPalette.Text)
+        foregroundColor = QApplication.palette().color(QPalette.ColorRole.Text)
         
         if self.__privateMode:
             backgroundColor = Preferences.getWebBrowser("PrivateModeUrlColor")
         else:
-            backgroundColor = QApplication.palette().color(QPalette.Base)
+            backgroundColor = QApplication.palette().color(
+                QPalette.ColorRole.Base)
         
         if self.__browser is not None:
             p = self.palette()
@@ -261,10 +262,11 @@
                         "SecureUrlColor")
             
             if progress == 0 or progress == 100:
-                p.setBrush(QPalette.Base, backgroundColor)
-                p.setBrush(QPalette.Text, foregroundColor)
+                p.setBrush(QPalette.ColorRole.Base, backgroundColor)
+                p.setBrush(QPalette.ColorRole.Text, foregroundColor)
             else:
-                highlight = QApplication.palette().color(QPalette.Highlight)
+                highlight = QApplication.palette().color(
+                    QPalette.ColorRole.Highlight)
                 r = (highlight.red() + 2 * backgroundColor.red()) // 3
                 g = (highlight.green() + 2 * backgroundColor.green()) // 3
                 b = (highlight.blue() + 2 * backgroundColor.blue()) // 3
@@ -283,7 +285,7 @@
                 gradient.setColorAt(0, loadingColor)
                 gradient.setColorAt(progress / 100.0 - 0.000001, loadingColor)
                 gradient.setColorAt(progress / 100.0, backgroundColor)
-                p.setBrush(QPalette.Base, gradient)
+                p.setBrush(QPalette.ColorRole.Base, gradient)
             
             self.setPalette(p)
         
@@ -305,12 +307,12 @@
         
         @param evt reference to the mouse event (QMouseEvent)
         """
-        if evt.button() == Qt.XButton1:
+        if evt.button() == Qt.MouseButton.XButton1:
             self.__mw.currentBrowser().triggerPageAction(
-                QWebEnginePage.Back)
-        elif evt.button() == Qt.XButton2:
+                QWebEnginePage.WebAction.Back)
+        elif evt.button() == Qt.MouseButton.XButton2:
             self.__mw.currentBrowser().triggerPageAction(
-                QWebEnginePage.Forward)
+                QWebEnginePage.WebAction.Forward)
         else:
             super(UrlBar, self).mousePressEvent(evt)
     
@@ -320,7 +322,7 @@
         
         @param evt reference to the mouse event (QMouseEvent)
         """
-        if evt.button() == Qt.LeftButton:
+        if evt.button() == Qt.MouseButton.LeftButton:
             self.selectAll()
         else:
             E5LineEdit.mouseDoubleClickEvent(self, evt)
@@ -331,7 +333,7 @@
         
         @param evt reference to the key press event (QKeyEvent)
         """
-        if evt.key() == Qt.Key_Escape:
+        if evt.key() == Qt.Key.Key_Escape:
             if self.__browser is not None:
                 self.setText(
                     str(self.__browser.url().toEncoded(), encoding="utf-8"))
@@ -343,16 +345,24 @@
         
         currentText = self.text().strip()
         if (
-            evt.key() in [Qt.Key_Enter, Qt.Key_Return] and
+            evt.key() in [Qt.Key.Key_Enter, Qt.Key.Key_Return] and
             not currentText.lower().startswith(("http://", "https://"))
         ):
             append = ""
-            if evt.modifiers() == Qt.KeyboardModifiers(Qt.ControlModifier):
+            if evt.modifiers() == Qt.KeyboardModifiers(
+                Qt.KeyboardModifier.ControlModifier
+            ):
                 append = ".com"
+            elif (
+                evt.modifiers() == Qt.KeyboardModifiers(
+                    Qt.KeyboardModifier.ControlModifier |
+                    Qt.KeyboardModifier.ShiftModifier
+                )
+            ):
+                append = ".org"
             elif evt.modifiers() == Qt.KeyboardModifiers(
-                    Qt.ControlModifier | Qt.ShiftModifier):
-                append = ".org"
-            elif evt.modifiers() == Qt.KeyboardModifiers(Qt.ShiftModifier):
+                Qt.KeyboardModifier.ShiftModifier
+            ):
                 append = ".net"
             
             if append != "":
@@ -390,7 +400,7 @@
             url = mimeData.urls()[0]
         elif mimeData.hasText():
             url = QUrl.fromEncoded(mimeData.text().encode("utf-8"),
-                                   QUrl.TolerantMode)
+                                   QUrl.ParsingMode.TolerantMode)
         
         if url.isEmpty() or not url.isValid():
             E5LineEdit.dropEvent(self, evt)
@@ -443,11 +453,12 @@
             sslCertificate = self.__browser.page().getSslCertificate()
             if sslCertificate is not None:
                 org = Utilities.decodeString(", ".join(
-                    sslCertificate.subjectInfo(QSslCertificate.Organization)))
+                    sslCertificate.subjectInfo(
+                        QSslCertificate.SubjectInfo.Organization)))
                 if org == "":
                     cn = Utilities.decodeString(", ".join(
                         sslCertificate.subjectInfo(
-                            QSslCertificate.CommonName)))
+                            QSslCertificate.SubjectInfo.CommonName)))
                     if cn != "":
                         org = cn.split(".", 1)[1]
                     if org == "":

eric ide

mercurial