Check for PC updates: Daily, weekly, on start, never
This commit is contained in:
parent
820d4f846d
commit
070b785bdb
3 changed files with 65 additions and 14 deletions
|
@ -12,6 +12,8 @@ Features
|
||||||
* "someone has friended you" notifier
|
* "someone has friended you" notifier
|
||||||
* MSPA update notifier option
|
* MSPA update notifier option
|
||||||
* Don't animate emotes not in current tab
|
* Don't animate emotes not in current tab
|
||||||
|
* Humanify times > 24 hours
|
||||||
|
* Show true bans?
|
||||||
|
|
||||||
Bugs
|
Bugs
|
||||||
----
|
----
|
||||||
|
|
15
menus.py
15
menus.py
|
@ -1020,8 +1020,17 @@ class PesterOptions(QtGui.QDialog):
|
||||||
layout_5.addWidget(QtGui.QLabel("Minutes before Idle:"))
|
layout_5.addWidget(QtGui.QLabel("Minutes before Idle:"))
|
||||||
layout_5.addWidget(self.idleBox)
|
layout_5.addWidget(self.idleBox)
|
||||||
|
|
||||||
self.updatecheck = QtGui.QCheckBox("Check for Updates on Start", self)
|
self.updateBox = QtGui.QComboBox(self)
|
||||||
self.updatecheck.setChecked(self.config.checkForUpdates())
|
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:
|
if parent.randhandler.running:
|
||||||
self.randomscheck = QtGui.QCheckBox("Receive Random Encounters")
|
self.randomscheck = QtGui.QCheckBox("Receive Random Encounters")
|
||||||
|
@ -1131,7 +1140,7 @@ class PesterOptions(QtGui.QDialog):
|
||||||
layout_idle = QtGui.QVBoxLayout(widget)
|
layout_idle = QtGui.QVBoxLayout(widget)
|
||||||
layout_idle.setAlignment(QtCore.Qt.AlignTop)
|
layout_idle.setAlignment(QtCore.Qt.AlignTop)
|
||||||
layout_idle.addLayout(layout_5)
|
layout_idle.addLayout(layout_5)
|
||||||
layout_idle.addWidget(self.updatecheck)
|
layout_idle.addLayout(layout_6)
|
||||||
self.pages.addWidget(widget)
|
self.pages.addWidget(widget)
|
||||||
|
|
||||||
# Theme
|
# Theme
|
||||||
|
|
|
@ -12,7 +12,7 @@ import codecs
|
||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import platform
|
import platform
|
||||||
from time import strftime
|
from time import strftime, time
|
||||||
|
|
||||||
missing = []
|
missing = []
|
||||||
try:
|
try:
|
||||||
|
@ -408,7 +408,17 @@ class userConfig(object):
|
||||||
def animations(self):
|
def animations(self):
|
||||||
return self.config.get('animations', True)
|
return self.config.get('animations', True)
|
||||||
def checkForUpdates(self):
|
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):
|
def addChum(self, chum):
|
||||||
if chum.handle not in self.chums():
|
if chum.handle not in self.chums():
|
||||||
fp = open(self.filename) # what if we have two clients open??
|
fp = open(self.filename) # what if we have two clients open??
|
||||||
|
@ -2629,7 +2639,7 @@ class PesterWindow(MovingWindow):
|
||||||
self.config.set('animations', animatesetting)
|
self.config.set('animations', animatesetting)
|
||||||
self.animationSetting.emit(animatesetting)
|
self.animationSetting.emit(animatesetting)
|
||||||
# update checked
|
# update checked
|
||||||
updatechecksetting = self.optionmenu.updatecheck.isChecked()
|
updatechecksetting = self.optionmenu.updateBox.currentIndex()
|
||||||
curupdatecheck = self.config.checkForUpdates()
|
curupdatecheck = self.config.checkForUpdates()
|
||||||
if updatechecksetting != curupdatecheck:
|
if updatechecksetting != curupdatecheck:
|
||||||
self.config.set('checkUpdates', updatechecksetting)
|
self.config.set('checkUpdates', updatechecksetting)
|
||||||
|
@ -2922,7 +2932,28 @@ class MainProgram(QtCore.QObject):
|
||||||
self.irc = PesterIRC(self.widget.config, self.widget)
|
self.irc = PesterIRC(self.widget.config, self.widget)
|
||||||
self.connectWidgets(self.irc, self.widget)
|
self.connectWidgets(self.irc, self.widget)
|
||||||
|
|
||||||
if self.widget.config.checkForUpdates():
|
# 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 Queue
|
||||||
import threading
|
import threading
|
||||||
q = Queue.Queue(1)
|
q = Queue.Queue(1)
|
||||||
|
@ -2930,6 +2961,15 @@ class MainProgram(QtCore.QObject):
|
||||||
w = threading.Thread(target=self.showUpdate, args=(q,0)) # stupid syntax errors
|
w = threading.Thread(target=self.showUpdate, args=(q,0)) # stupid syntax errors
|
||||||
w.start()
|
w.start()
|
||||||
s.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)',
|
widget2irc = [('sendMessage(QString, QString)',
|
||||||
'sendMessage(QString, QString)'),
|
'sendMessage(QString, QString)'),
|
||||||
|
|
Loading…
Reference in a new issue