eric7/UI/UserInterface.py

branch
eric7
changeset 8580
e91b276e0771
parent 8571
eb2b840bbf8f
child 8583
aac629a05f8b
equal deleted inserted replaced
8579:cfd0e44ef084 8580:e91b276e0771
56 56
57 from Sessions.SessionFile import SessionFile 57 from Sessions.SessionFile import SessionFile
58 58
59 from Tasks.TasksFile import TasksFile 59 from Tasks.TasksFile import TasksFile
60 60
61 from EricNetwork.EricNetworkIcon import EricNetworkIcon
61 from EricNetwork.EricNetworkProxyFactory import ( 62 from EricNetwork.EricNetworkProxyFactory import (
62 EricNetworkProxyFactory, proxyAuthenticationRequired 63 EricNetworkProxyFactory, proxyAuthenticationRequired
63 ) 64 )
64 try: 65 try:
65 from EricNetwork.EricSslErrorHandler import ( 66 from EricNetwork.EricSslErrorHandler import (
144 @signal reloadAPIs() emitted to reload the api information 145 @signal reloadAPIs() emitted to reload the api information
145 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The 146 @signal showMenu(str, QMenu) emitted when a menu is about to be shown. The
146 name of the menu and a reference to the menu are given. 147 name of the menu and a reference to the menu are given.
147 @signal masterPasswordChanged(str, str) emitted after the master 148 @signal masterPasswordChanged(str, str) emitted after the master
148 password has been changed with the old and the new password 149 password has been changed with the old and the new password
150 @signal onlineStateChanged(online) emitted to indicate a change of the
151 network state
149 """ 152 """
150 appendStderr = pyqtSignal(str) 153 appendStderr = pyqtSignal(str)
151 appendStdout = pyqtSignal(str) 154 appendStdout = pyqtSignal(str)
152 preferencesChanged = pyqtSignal() 155 preferencesChanged = pyqtSignal()
153 reloadAPIs = pyqtSignal() 156 reloadAPIs = pyqtSignal()
154 showMenu = pyqtSignal(str, QMenu) 157 showMenu = pyqtSignal(str, QMenu)
155 masterPasswordChanged = pyqtSignal(str, str) 158 masterPasswordChanged = pyqtSignal(str, str)
159 onlineStateChanged = pyqtSignal(bool)
156 160
157 maxFilePathLen = 100 161 maxFilePathLen = 100
158 maxMenuFilePathLen = 75 162 maxMenuFilePathLen = 75
159 163
160 LeftSide = 1 164 LeftSide = 1
584 self.toolGroups, self.currentToolGroup = Preferences.readToolGroups() 588 self.toolGroups, self.currentToolGroup = Preferences.readToolGroups()
585 self.toolProcs = [] 589 self.toolProcs = []
586 self.__initExternalToolsActions() 590 self.__initExternalToolsActions()
587 591
588 # redirect handling of http and https URLs to ourselves 592 # redirect handling of http and https URLs to ourselves
589 # TODO: enable this once PyQt 6.2.0/Qt 6.2.0 is released 593 QDesktopServices.setUrlHandler("http", self.handleUrl)
590 if False: 594 QDesktopServices.setUrlHandler("https", self.handleUrl)
591 QDesktopServices.setUrlHandler("http", self.handleUrl)
592 QDesktopServices.setUrlHandler("https", self.handleUrl)
593 595
594 # register all relevant objects 596 # register all relevant objects
595 splash.showMessage(self.tr("Registering Objects...")) 597 splash.showMessage(self.tr("Registering Objects..."))
596 ericApp().registerObject("UserInterface", self) 598 ericApp().registerObject("UserInterface", self)
597 ericApp().registerObject("DebugUI", self.debuggerUI) 599 ericApp().registerObject("DebugUI", self.debuggerUI)
3604 3606
3605 from VCS.StatusMonitorLed import StatusMonitorLedWidget 3607 from VCS.StatusMonitorLed import StatusMonitorLedWidget
3606 self.sbVcsMonitorLed = StatusMonitorLedWidget( 3608 self.sbVcsMonitorLed = StatusMonitorLedWidget(
3607 self.project, self.__statusBar) 3609 self.project, self.__statusBar)
3608 self.__statusBar.addPermanentWidget(self.sbVcsMonitorLed) 3610 self.__statusBar.addPermanentWidget(self.sbVcsMonitorLed)
3611
3612 self.networkIcon = EricNetworkIcon(self.__statusBar)
3613 self.__statusBar.addPermanentWidget(self.networkIcon)
3614 self.networkIcon.onlineStateChanged.connect(self.onlineStateChanged)
3615 self.networkIcon.onlineStateChanged.connect(self.__onlineStateChanged)
3609 3616
3610 def __initExternalToolsActions(self): 3617 def __initExternalToolsActions(self):
3611 """ 3618 """
3612 Private slot to create actions for the configured external tools. 3619 Private slot to create actions for the configured external tools.
3613 """ 3620 """
6874 6881
6875 def checkPluginUpdatesAvailable(self): 6882 def checkPluginUpdatesAvailable(self):
6876 """ 6883 """
6877 Public method to check the availability of updates of plug-ins. 6884 Public method to check the availability of updates of plug-ins.
6878 """ 6885 """
6879 self.pluginManager.checkPluginUpdatesAvailable() 6886 if self.isOnline():
6887 self.pluginManager.checkPluginUpdatesAvailable()
6880 6888
6881 ################################################################# 6889 #################################################################
6882 ## Drag and Drop Support 6890 ## Drag and Drop Support
6883 ################################################################# 6891 #################################################################
6884 6892
7034 self.__saveCurrentViewProfile(True) 7042 self.__saveCurrentViewProfile(True)
7035 Preferences.saveToolGroups(self.toolGroups, self.currentToolGroup) 7043 Preferences.saveToolGroups(self.toolGroups, self.currentToolGroup)
7036 Preferences.syncPreferences() 7044 Preferences.syncPreferences()
7037 self.shutdownCalled = True 7045 self.shutdownCalled = True
7038 return True 7046 return True
7047
7048 def isOnline(self):
7049 """
7050 Public method to get the online state.
7051
7052 @return online state
7053 @rtype bool
7054 """
7055 return self.networkIcon.isOnline()
7056
7057 def __onlineStateChanged(self, online):
7058 """
7059 Private slot handling changes in online state.
7060
7061 @param online flag indicating the online state
7062 @type bool
7063 """
7064 if online:
7065 self.performVersionCheck(False)
7039 7066
7040 ############################################## 7067 ##############################################
7041 ## Below are methods to check for new versions 7068 ## Below are methods to check for new versions
7042 ############################################## 7069 ##############################################
7043 7070
7055 7082
7056 @param manual flag indicating an invocation via the menu (boolean) 7083 @param manual flag indicating an invocation via the menu (boolean)
7057 @param alternative index of server to download from (integer) 7084 @param alternative index of server to download from (integer)
7058 @param showVersions flag indicating the show versions mode (boolean) 7085 @param showVersions flag indicating the show versions mode (boolean)
7059 """ 7086 """
7060 if not manual: 7087 if self.isOnline():
7061 if VersionOnly.startswith("@@"): 7088 if not manual:
7062 return 7089 if VersionOnly.startswith("@@"):
7063 else:
7064 period = Preferences.getUI("PerformVersionCheck")
7065 if period == 0:
7066 return 7090 return
7067 elif period in [2, 3, 4]: 7091 else:
7068 lastCheck = Preferences.Prefs.settings.value( 7092 period = Preferences.getUI("PerformVersionCheck")
7069 "Updates/LastCheckDate", QDate(1970, 1, 1)) 7093 if period == 0:
7070 if lastCheck.isValid(): 7094 return
7071 now = QDate.currentDate() 7095 elif period in [2, 3, 4]:
7072 if ( 7096 lastCheck = Preferences.Prefs.settings.value(
7073 (period == 2 and lastCheck.day() == now.day()) or 7097 "Updates/LastCheckDate", QDate(1970, 1, 1))
7074 (period == 3 and lastCheck.daysTo(now) < 7) or 7098 if lastCheck.isValid():
7075 (period == 4 and (lastCheck.daysTo(now) < 7099 now = QDate.currentDate()
7076 lastCheck.daysInMonth())) 7100 if (
7077 ): 7101 (period == 2 and
7078 # daily, weekly, monthly 7102 lastCheck.day() == now.day()) or
7079 return 7103 (period == 3 and lastCheck.daysTo(now) < 7) or
7080 7104 (period == 4 and (lastCheck.daysTo(now) <
7081 self.__inVersionCheck = True 7105 lastCheck.daysInMonth()))
7082 self.manualUpdatesCheck = manual 7106 ):
7083 self.showAvailableVersions = showVersions 7107 # daily, weekly, monthly
7084 self.httpAlternative = alternative 7108 return
7085 url = QUrl(self.__httpAlternatives[alternative]) 7109
7086 self.__versionCheckCanceled = False 7110 self.__inVersionCheck = True
7087 if manual: 7111 self.manualUpdatesCheck = manual
7088 if self.__versionCheckProgress is None: 7112 self.showAvailableVersions = showVersions
7089 self.__versionCheckProgress = EricProgressDialog( 7113 self.httpAlternative = alternative
7090 "", self.tr("&Cancel"), 7114 url = QUrl(self.__httpAlternatives[alternative])
7091 0, len(self.__httpAlternatives), 7115 self.__versionCheckCanceled = False
7092 self.tr("%v/%m"), self) 7116 if manual:
7093 self.__versionCheckProgress.setWindowTitle( 7117 if self.__versionCheckProgress is None:
7094 self.tr("Version Check")) 7118 self.__versionCheckProgress = EricProgressDialog(
7095 self.__versionCheckProgress.setMinimumDuration(0) 7119 "", self.tr("&Cancel"),
7096 self.__versionCheckProgress.canceled.connect( 7120 0, len(self.__httpAlternatives),
7097 self.__versionsDownloadCanceled) 7121 self.tr("%v/%m"), self)
7098 self.__versionCheckProgress.setLabelText( 7122 self.__versionCheckProgress.setWindowTitle(
7099 self.tr("Trying host {0}").format(url.host())) 7123 self.tr("Version Check"))
7100 self.__versionCheckProgress.setValue(alternative) 7124 self.__versionCheckProgress.setMinimumDuration(0)
7101 request = QNetworkRequest(url) 7125 self.__versionCheckProgress.canceled.connect(
7102 request.setAttribute( 7126 self.__versionsDownloadCanceled)
7103 QNetworkRequest.Attribute.CacheLoadControlAttribute, 7127 self.__versionCheckProgress.setLabelText(
7104 QNetworkRequest.CacheLoadControl.AlwaysNetwork) 7128 self.tr("Trying host {0}").format(url.host()))
7105 reply = self.__networkManager.get(request) 7129 self.__versionCheckProgress.setValue(alternative)
7106 reply.finished.connect(lambda: self.__versionsDownloadDone(reply)) 7130 request = QNetworkRequest(url)
7107 self.__replies.append(reply) 7131 request.setAttribute(
7132 QNetworkRequest.Attribute.CacheLoadControlAttribute,
7133 QNetworkRequest.CacheLoadControl.AlwaysNetwork)
7134 reply = self.__networkManager.get(request)
7135 reply.finished.connect(lambda: self.__versionsDownloadDone(reply))
7136 self.__replies.append(reply)
7137 else:
7138 if manual:
7139 EricMessageBox.warning(
7140 self,
7141 self.tr("Error getting versions information"),
7142 self.tr("The versions information cannot not be"
7143 " downloaded because the Internet is"
7144 " <b>not reachable</b>. Please try again later.")
7145 )
7108 7146
7109 @pyqtSlot() 7147 @pyqtSlot()
7110 def __versionsDownloadDone(self, reply): 7148 def __versionsDownloadDone(self, reply):
7111 """ 7149 """
7112 Private slot called, after the versions file has been downloaded 7150 Private slot called, after the versions file has been downloaded

eric ide

mercurial