UI/UserInterface.py

branch
Py2 comp.
changeset 3142
55030c09e142
parent 3080
6c0a430b19df
parent 3116
ee0a183cec81
child 3145
a9de05d4a22f
--- a/UI/UserInterface.py	Fri Dec 13 22:45:47 2013 +0100
+++ b/UI/UserInterface.py	Fri Dec 13 23:39:14 2013 +0100
@@ -141,6 +141,8 @@
     BottomSide = 2
     RightSide = 3
     
+    ErrorLogFileName = "eric5_error.log"
+    
     def __init__(self, app, locale, splash, plugin, noOpenAtStartup,
                  restartArguments):
         """
@@ -1624,6 +1626,18 @@
             self.showAvailableVersionsInfo)
         self.actions.append(self.showVersionsAct)
 
+        self.showErrorLogAct = E5Action(
+            self.trUtf8('Show Error Log'),
+            self.trUtf8('Show Error &Log...'),
+            0, 0, self, 'show_error_log')
+        self.showErrorLogAct.setStatusTip(self.trUtf8('Show Error Log'))
+        self.showErrorLogAct.setWhatsThis(self.trUtf8(
+            """<b>Show Error Log...</b>"""
+            """<p>Opens a dialog showing the most recent error log.</p>"""
+        ))
+        self.showErrorLogAct.triggered[()].connect(self.__showErrorLog)
+        self.actions.append(self.showErrorLogAct)
+        
         self.reportBugAct = E5Action(
             self.trUtf8('Report Bug'),
             self.trUtf8('Report &Bug...'),
@@ -2171,7 +2185,7 @@
             """<p>This opens a dialog, that shows a list of plugins """
             """available on the Internet.</p>"""
         ))
-        self.pluginRepoAct.triggered[()].connect(self.__showPluginsAvailable)
+        self.pluginRepoAct.triggered[()].connect(self.showPluginsAvailable)
         self.actions.append(self.pluginRepoAct)
         
         # initialize viewmanager actions
@@ -2498,6 +2512,7 @@
         self.__menus["help"].addAction(self.checkUpdateAct)
         self.__menus["help"].addAction(self.showVersionsAct)
         self.__menus["help"].addSeparator()
+        self.__menus["help"].addAction(self.showErrorLogAct)
         self.__menus["help"].addAction(self.reportBugAct)
         self.__menus["help"].addAction(self.requestFeatureAct)
         self.__menus["help"].addSeparator()
@@ -2841,6 +2856,7 @@
         """
         self.checkUpdateAct.setEnabled(not self.__inVersionCheck)
         self.showVersionsAct.setEnabled(not self.__inVersionCheck)
+        self.showErrorLogAct.setEnabled(self.__hasErrorLog())
         
         self.showMenu.emit("Help", self.__menus["help"])
     
@@ -3006,12 +3022,34 @@
         user, what to do with it.
         """
         if Preferences.getUI("CheckErrorLog"):
-            logFile = os.path.join(Utilities.getConfigDir(), "eric5_error.log")
+            logFile = os.path.join(Utilities.getConfigDir(),
+                                   self.ErrorLogFileName)
             if os.path.exists(logFile):
                 from .ErrorLogDialog import ErrorLogDialog
-                dlg = ErrorLogDialog(logFile, self)
+                dlg = ErrorLogDialog(logFile, False, self)
                 dlg.exec_()
         
+    def __hasErrorLog(self):
+        """
+        Private method to check, if an error log file exists.
+        
+        @return flag indicating the existence of an error log file (boolean)
+        """
+        logFile = os.path.join(Utilities.getConfigDir(),
+                               self.ErrorLogFileName)
+        return os.path.exists(logFile)
+        
+    def __showErrorLog(self):
+        """
+        Private slot to show the most recent error log message.
+        """
+        logFile = os.path.join(Utilities.getConfigDir(),
+                               self.ErrorLogFileName)
+        if os.path.exists(logFile):
+            from .ErrorLogDialog import ErrorLogDialog
+            dlg = ErrorLogDialog(logFile, True, self)
+            dlg.show()
+        
     def __compareFiles(self):
         """
         Private slot to handle the Compare Files dialog.
@@ -5569,9 +5607,9 @@
         dlg = PluginUninstallDialog(self.pluginManager, self)
         dlg.exec_()
         
-    def __showPluginsAvailable(self):
-        """
-        Private slot to show the plugins available for download.
+    def showPluginsAvailable(self):
+        """
+        Public slot to show the plugins available for download.
         """
         from PluginManager.PluginRepositoryDialog import PluginRepositoryDialog
         dlg = PluginRepositoryDialog(self)
@@ -5584,6 +5622,12 @@
         Private slot to show the plugin manager configuration page.
         """
         self.showPreferences("pluginManagerPage")
+        
+    def checkPluginUpdatesAvailable(self):
+        """
+        Public method to check the availability of updates of plug-ins.
+        """
+        self.pluginManager.checkPluginUpdatesAvailable()
     
     #################################################################
     ## Drag and Drop Support
@@ -5757,7 +5801,8 @@
                         if period == 2 and lastCheck.day() == now.day():
                             # daily
                             return
-                        elif period == 3 and lastCheck.daysTo(now) < 7:
+                        elif (period == 3 and
+                              lastCheck.weekNumber() == now.weekNumber()):
                             # weekly
                             return
                         elif period == 4 and lastCheck.month() == now.month():
@@ -5774,8 +5819,8 @@
             if self.__versionCheckProgress is None:
                 self.__versionCheckProgress = E5ProgressDialog(
                     "", self.trUtf8("&Cancel"),
-                    0,  len(self.__httpAlternatives),
-                    self.trUtf8("%v/%m"),  self)
+                    0, len(self.__httpAlternatives),
+                    self.trUtf8("%v/%m"), self)
                 self.__versionCheckProgress.setMinimumDuration(0)
                 self.__versionCheckProgress.canceled.connect(
                     self.__versionsDownloadCanceled)

eric ide

mercurial