diff -r 4c2cace2263a -r fe4d62e23908 WebBrowser/SafeBrowsing/SafeBrowsingDialog.py --- a/WebBrowser/SafeBrowsing/SafeBrowsingDialog.py Tue Aug 08 10:53:10 2017 +0200 +++ b/WebBrowser/SafeBrowsing/SafeBrowsingDialog.py Tue Aug 08 17:20:28 2017 +0200 @@ -9,7 +9,7 @@ from __future__ import unicode_literals -from PyQt5.QtCore import pyqtSlot, Qt, QUrl +from PyQt5.QtCore import pyqtSlot, Qt, QUrl, QDateTime from PyQt5.QtWidgets import QDialog, QDialogButtonBox, QAbstractButton, \ QApplication @@ -51,6 +51,8 @@ self.__apiKey = Preferences.getWebBrowser("SafeBrowsingApiKey") self.__filterPlatform = Preferences.getWebBrowser( "SafeBrowsingFilterPlatform") + self.__automaticUpdate = Preferences.getWebBrowser( + "SafeBrowsingAutoUpdate") self.buttonBox.setFocus() @@ -64,6 +66,7 @@ self.gsbGroupBox.setChecked(self.__enabled) self.gsbApiKeyEdit.setText(self.__apiKey) self.gsbFilterPlatformCheckBox.setChecked(self.__filterPlatform) + self.gsbAutoUpdateCheckBox.setChecked(self.__automaticUpdate) self.__updateCacheButtons() @@ -107,11 +110,14 @@ self.__enabled = self.gsbGroupBox.isChecked() self.__apiKey = self.gsbApiKeyEdit.text() self.__filterPlatform = self.gsbFilterPlatformCheckBox.isChecked() + self.__automaticUpdate = self.gsbAutoUpdateCheckBox.isChecked() Preferences.setWebBrowser("SafeBrowsingEnabled", self.__enabled) Preferences.setWebBrowser("SafeBrowsingApiKey", self.__apiKey) Preferences.setWebBrowser("SafeBrowsingFilterPlatform", self.__filterPlatform) + Preferences.setWebBrowser("SafeBrowsingAutoUpdate", + self.__automaticUpdate) self.__manager.configurationChanged() @@ -139,9 +145,11 @@ @rtype bool """ return ( - self.__enabled != self.gsbGroupBox.isChecked() or - self.__apiKey != self.gsbApiKeyEdit.text() or - self.__filterPlatform != self.gsbFilterPlatformCheckBox.isChecked() + (self.__enabled != self.gsbGroupBox.isChecked()) or + (self.__apiKey != self.gsbApiKeyEdit.text()) or + (self.__filterPlatform != + self.gsbFilterPlatformCheckBox.isChecked()) or + (self.__automaticUpdate != self.gsbAutoUpdateCheckBox.isChecked()) ) def __okToClose(self): @@ -170,6 +178,8 @@ self.updateCacheButton.setEnabled(enable) self.clearCacheButton.setEnabled(enable) + + self.showUpdateTimeButton.setEnabled(enable and self.__automaticUpdate) @pyqtSlot() def on_updateCacheButton_clicked(self): @@ -237,7 +247,8 @@ @param value progress value to be set @type int """ - self.progressBar.setValue(value) + if bool(self.progressLabel.text()): + self.progressBar.setValue(value) def __resetProgress(self): """ @@ -300,3 +311,24 @@ Private slot to save the configuration data. """ self.__save() + + @pyqtSlot() + def on_showUpdateTimeButton_clicked(self): + """ + Private slot to show the time of the next automatic threat list update. + """ + nextUpdateDateTime = Preferences.getWebBrowser( + "SafeBrowsingUpdateDateTime") + if not nextUpdateDateTime.isValid() or \ + nextUpdateDateTime <= QDateTime.currentDateTime(): + message = self.tr("The next automatic threat list update will be" + " done now.") + else: + message = self.tr("<p>The next automatic threat list update will" + " be done at <b>{0}</b>.</p>").format( + nextUpdateDateTime.toString("yyyy-MM-dd, HH:mm:ss")) + + E5MessageBox.information( + self, + self.tr("Update Time"), + message)