diff --git a/TODO.mkdn b/TODO.mkdn index 92961c2..42f5e6d 100644 --- a/TODO.mkdn +++ b/TODO.mkdn @@ -12,6 +12,8 @@ Features * "someone has friended you" notifier * MSPA update notifier option * Don't animate emotes not in current tab +* Humanify times > 24 hours +* Show true bans? Bugs ---- diff --git a/menus.py b/menus.py index 6f4bb53..9331368 100644 --- a/menus.py +++ b/menus.py @@ -1020,8 +1020,17 @@ class PesterOptions(QtGui.QDialog): layout_5.addWidget(QtGui.QLabel("Minutes before Idle:")) layout_5.addWidget(self.idleBox) - self.updatecheck = QtGui.QCheckBox("Check for Updates on Start", self) - self.updatecheck.setChecked(self.config.checkForUpdates()) + self.updateBox = QtGui.QComboBox(self) + self.updateBox.addItem("Once a Day") + self.updateBox.addItem("Once a Week") + self.updateBox.addItem("Only on Start") + self.updateBox.addItem("Never") + check = self.config.checkForUpdates() + if check >= 0 and check < self.updateBox.count(): + self.updateBox.setCurrentIndex(check) + layout_6 = QtGui.QHBoxLayout() + layout_6.addWidget(QtGui.QLabel("Check for\nPesterchum Updates:")) + layout_6.addWidget(self.updateBox) if parent.randhandler.running: self.randomscheck = QtGui.QCheckBox("Receive Random Encounters") @@ -1131,7 +1140,7 @@ class PesterOptions(QtGui.QDialog): layout_idle = QtGui.QVBoxLayout(widget) layout_idle.setAlignment(QtCore.Qt.AlignTop) layout_idle.addLayout(layout_5) - layout_idle.addWidget(self.updatecheck) + layout_idle.addLayout(layout_6) self.pages.addWidget(widget) # Theme diff --git a/pesterchum.py b/pesterchum.py index 53bac1b..b29de1b 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -12,7 +12,7 @@ import codecs import re import socket import platform -from time import strftime +from time import strftime, time missing = [] try: @@ -408,7 +408,17 @@ class userConfig(object): def animations(self): return self.config.get('animations', True) def checkForUpdates(self): - return self.config.get('checkUpdates', True) + u = self.config.get('checkUpdates', 0) + if type(u) == type(bool()): + if u: u = 2 + else: u = 3 + return u + # Once a day + # Once a week + # Only on start + # Never + def lastUCheck(self): + return self.config.get('lastUCheck', 0) def addChum(self, chum): if chum.handle not in self.chums(): fp = open(self.filename) # what if we have two clients open?? @@ -2629,7 +2639,7 @@ class PesterWindow(MovingWindow): self.config.set('animations', animatesetting) self.animationSetting.emit(animatesetting) # update checked - updatechecksetting = self.optionmenu.updatecheck.isChecked() + updatechecksetting = self.optionmenu.updateBox.currentIndex() curupdatecheck = self.config.checkForUpdates() if updatechecksetting != curupdatecheck: self.config.set('checkUpdates', updatechecksetting) @@ -2922,14 +2932,44 @@ class MainProgram(QtCore.QObject): self.irc = PesterIRC(self.widget.config, self.widget) self.connectWidgets(self.irc, self.widget) - if self.widget.config.checkForUpdates(): - import Queue - import threading - q = Queue.Queue(1) - s = threading.Thread(target=version.updateCheck, args=(q,0)) # the 0 is to stop - w = threading.Thread(target=self.showUpdate, args=(q,0)) # stupid syntax errors - w.start() - s.start() + # 0 Once a day + # 1 Once a week + # 2 Only on start + # 3 Never + check = self.widget.config.checkForUpdates() + if check == 2: + self.runUpdateSlot() + elif check == 0: + seconds = 60 * 60 * 24 + if int(time()) - self.widget.config.lastUCheck() < seconds: + seconds -= int(time()) - self.widget.config.lastUCheck() + if seconds < 0: seconds = 0 + QtCore.QTimer.singleShot(1000*seconds, self, QtCore.SLOT('runUpdateSlot()')) + elif check == 1: + seconds = 60 * 60 * 24 * 7 + if int(time()) - self.widget.config.lastUCheck() < seconds: + seconds -= int(time()) - self.widget.config.lastUCheck() + if seconds < 0: seconds = 0 + QtCore.QTimer.singleShot(1000*seconds, self, QtCore.SLOT('runUpdateSlot()')) + + @QtCore.pyqtSlot() + def runUpdateSlot(self): + import Queue + import threading + q = Queue.Queue(1) + s = threading.Thread(target=version.updateCheck, args=(q,0)) # the 0 is to stop + w = threading.Thread(target=self.showUpdate, args=(q,0)) # stupid syntax errors + w.start() + s.start() + self.widget.config.set('lastUCheck', int(time())) + check = self.widget.config.checkForUpdates() + if check == 0: + seconds = 60 * 60 * 24 + elif check == 1: + seconds = 60 * 60 * 24 * 7 + else: + return + QtCore.QTimer.singleShot(1000*seconds, self, QtCore.SLOT('runUpdateSlot()')) widget2irc = [('sendMessage(QString, QString)', 'sendMessage(QString, QString)'),