UI/UserInterface.py

branch
maintenance
changeset 5863
0752bdd8db77
parent 5773
899700885725
parent 5842
c3f41b959a65
child 5948
6f958d5765f4
equal deleted inserted replaced
5826:ea0f0f066b1d 5863:0752bdd8db77
6504 @param versions contents of the downloaded versions file (list of 6504 @param versions contents of the downloaded versions file (list of
6505 strings) 6505 strings)
6506 """ 6506 """
6507 url = "" 6507 url = ""
6508 try: 6508 try:
6509 if "-snapshot-" in VersionOnly: 6509 if "snapshot-" in VersionOnly:
6510 # check snapshot version 6510 # check snapshot version like snapshot-20170810
6511 if versions[2][0] == "6" and versions[2] > VersionOnly: 6511 if "snapshot-" in versions[2]:
6512 res = E5MessageBox.yesNo( 6512 installedSnapshotDate = VersionOnly.rsplit("-", 1)[-1]
6513 self, 6513 availableSnapshotDate = versions[2].rsplit("-", 1)[-1]
6514 self.tr("Update available"), 6514 if availableSnapshotDate > installedSnapshotDate:
6515 self.tr( 6515 res = E5MessageBox.yesNo(
6516 """The update to <b>{0}</b> of eric6 is""" 6516 self,
6517 """ available at <b>{1}</b>. Would you like to""" 6517 self.tr("Update available"),
6518 """ get it?""") 6518 self.tr(
6519 .format(versions[2], versions[3]), 6519 """The update to <b>{0}</b> of eric6 is"""
6520 yesDefault=True) 6520 """ available at <b>{1}</b>. Would you like"""
6521 url = res and versions[3] or '' 6521 """ to get it?""")
6522 elif versions[0] > VersionOnly: 6522 .format(versions[2], versions[3]),
6523 res = E5MessageBox.yesNo( 6523 yesDefault=True)
6524 self, 6524 url = res and versions[3] or ''
6525 self.tr("Update available"),
6526 self.tr(
6527 """The update to <b>{0}</b> of eric6 is"""
6528 """ available at <b>{1}</b>. Would you like to"""
6529 """ get it?""")
6530 .format(versions[0], versions[1]),
6531 yesDefault=True)
6532 url = res and versions[1] or ''
6533 else: 6525 else:
6534 if self.manualUpdatesCheck: 6526 if self.manualUpdatesCheck:
6535 E5MessageBox.information( 6527 E5MessageBox.information(
6536 self, 6528 self,
6537 self.tr("Eric6 is up to date"), 6529 self.tr("Update Check"),
6538 self.tr( 6530 self.tr(
6539 """You are using the latest version of""" 6531 """You are using a snapshot release of"""
6540 """ eric6""")) 6532 """ eric6. A more up-to-date stable release"""
6533 """ might be available."""))
6541 elif VersionOnly.startswith(("rev_", "@@")): 6534 elif VersionOnly.startswith(("rev_", "@@")):
6535 # check installation from source
6542 if self.manualUpdatesCheck: 6536 if self.manualUpdatesCheck:
6543 E5MessageBox.information( 6537 E5MessageBox.information(
6544 self, 6538 self,
6545 self.tr("Update Check"), 6539 self.tr("Update Check"),
6546 self.tr( 6540 self.tr(
6568 self, 6562 self,
6569 self.tr("Eric6 is up to date"), 6563 self.tr("Eric6 is up to date"),
6570 self.tr( 6564 self.tr(
6571 """You are using the latest version of""" 6565 """You are using the latest version of"""
6572 """ eric6""")) 6566 """ eric6"""))
6573 except IndexError: 6567 except (IndexError, TypeError):
6574 E5MessageBox.warning( 6568 E5MessageBox.warning(
6575 self, 6569 self,
6576 self.tr("Error during updates check"), 6570 self.tr("Error during updates check"),
6577 self.tr("""Could not perform updates check.""")) 6571 self.tr("""Could not perform updates check."""))
6578 6572
6703 Private method to convert a version string into a tuple. 6697 Private method to convert a version string into a tuple.
6704 6698
6705 @param version version string 6699 @param version version string
6706 @type str 6700 @type str
6707 @return version tuple 6701 @return version tuple
6708 @rtype tuple of int and str 6702 @rtype tuple of int
6709 """ 6703 """
6710 versionParts = [] 6704 versionParts = []
6711 for part in version.split("."): 6705 for part in version.split("."):
6712 part = part.strip() 6706 part = part.strip()
6713 if part: 6707 if part:
6714 try: 6708 try:
6715 part = int(part) 6709 part = int(part)
6716 except ValueError: 6710 except ValueError:
6717 # not an integer 6711 # not an integer, ignore
6718 pass 6712 continue
6719 versionParts.append(part) 6713 versionParts.append(part)
6720 return tuple(versionParts) 6714 return tuple(versionParts)
6721 6715
6722 ################################# 6716 #################################
6723 ## Below are some utility methods 6717 ## Below are some utility methods
6751 6745
6752 ########################################## 6746 ##########################################
6753 ## Support for desktop notifications below 6747 ## Support for desktop notifications below
6754 ########################################## 6748 ##########################################
6755 6749
6756 def showNotification(self, icon, heading, text): 6750 def showNotification(self, icon, heading, text, timeout=None):
6757 """ 6751 """
6758 Public method to show a desktop notification. 6752 Public method to show a desktop notification.
6759 6753
6760 @param icon icon to be shown in the notification (QPixmap) 6754 @param icon icon to be shown in the notification
6761 @param heading heading of the notification (string) 6755 @type QPixmap
6762 @param text text of the notification (string) 6756 @param heading heading of the notification
6757 @type str
6758 @param text text of the notification
6759 @type str
6760 @param timeout time in seconds the notification should be shown
6761 (None = use configured timeout, 0 = indefinitely)
6762 @type int
6763 """ 6763 """
6764 if Preferences.getUI("NotificationsEnabled"): 6764 if Preferences.getUI("NotificationsEnabled"):
6765 if self.__notification is None: 6765 if self.__notification is None:
6766 from .NotificationWidget import NotificationWidget 6766 from .NotificationWidget import NotificationWidget
6767 self.__notification = NotificationWidget(parent=self) 6767 self.__notification = NotificationWidget(parent=self)
6768 self.__notification.setPixmap(icon) 6768 self.__notification.setPixmap(icon)
6769 self.__notification.setHeading(heading) 6769 self.__notification.setHeading(heading)
6770 self.__notification.setText(text) 6770 self.__notification.setText(text)
6771 self.__notification.setTimeout( 6771 if timeout is None:
6772 Preferences.getUI("NotificationTimeout")) 6772 timeout = Preferences.getUI("NotificationTimeout")
6773 self.__notification.setTimeout(timeout)
6773 self.__notification.move(Preferences.getUI("NotificationPosition")) 6774 self.__notification.move(Preferences.getUI("NotificationPosition"))
6774 self.__notification.show() 6775 self.__notification.show()
6775 6776
6776 def notificationsEnabled(self): 6777 def notificationsEnabled(self):
6777 """ 6778 """

eric ide

mercurial