Separated the idle timer from the idle checkbox. Having the latter active doesn't break the former, and the former won't deactivate the latter when you come back.
This commit is contained in:
parent
daeaa74f61
commit
6efac5cd07
3 changed files with 76 additions and 39 deletions
|
@ -63,7 +63,6 @@ Features
|
|||
* Right-click Time entry field to see those used? (Replace left/right buttons?)
|
||||
* Make the memo name entry box accept a comma-separated list
|
||||
* Make right-clicking on a tab open up the right-click menu one would get on right-clicking the title (frame??)
|
||||
* Separate auto-idle and checkbox idle so they don't share a state
|
||||
|
||||
Todo/Done
|
||||
----
|
||||
|
@ -73,6 +72,7 @@ Todo/Done
|
|||
* Toggle individual tab flash / alert sounds (from the same right-click memo that lets us toggle OOC)
|
||||
* Make CTRL+PGUP/PGDN switch memo/pester tabs
|
||||
* Color tags are now posted as their shorter hexadecimal forms, if applicable (255,255,255 -> #FFFFFF, for example)
|
||||
* Separate auto-idle and checkbox idle so they don't share a state (and make the first send set the timer for additional idle responses)
|
||||
|
||||
Debugging
|
||||
----
|
||||
|
|
4
convo.py
4
convo.py
|
@ -405,7 +405,7 @@ class PesterText(QtGui.QTextEdit):
|
|||
if chum is me:
|
||||
window.chatlog.log(parent.chum.handle, lexmsg)
|
||||
else:
|
||||
if window.idleaction.isChecked() and parent.chumopen:
|
||||
if (window.idler.auto or window.idler.manual) and parent.chumopen:
|
||||
idlethreshhold = 60
|
||||
if (not hasattr(self, 'lastmsg')) or \
|
||||
datetime.now() - self.lastmsg > timedelta(0,idlethreshhold):
|
||||
|
@ -532,7 +532,7 @@ class PesterInput(QtGui.QLineEdit):
|
|||
self.setText(prev)
|
||||
elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]:
|
||||
self.parent().textArea.keyPressEvent(event)
|
||||
self.parent().mainwindow.idletime = 0
|
||||
self.parent().mainwindow.idler.time = 0
|
||||
super(PesterInput, self).keyPressEvent(event)
|
||||
|
||||
class PesterConvo(QtGui.QFrame):
|
||||
|
|
|
@ -10,6 +10,7 @@ import random
|
|||
import re
|
||||
from time import time
|
||||
import threading, Queue
|
||||
from pnc.dep.attrdict import AttrDict
|
||||
|
||||
reqmissing = []
|
||||
optmissing = []
|
||||
|
@ -1205,14 +1206,25 @@ class PesterWindow(MovingWindow):
|
|||
|
||||
self.waitingMessages = waitingMessageHolder(self)
|
||||
|
||||
self.autoidle = False
|
||||
self.idlethreshold = 60*self.config.idleTime()
|
||||
self.idletimer = QtCore.QTimer(self)
|
||||
self.idleposition = QtGui.QCursor.pos()
|
||||
self.idletime = 0
|
||||
self.connect(self.idletimer, QtCore.SIGNAL('timeout()'),
|
||||
self.idler = AttrDict(dict(
|
||||
# autoidle
|
||||
auto = False,
|
||||
# setidle
|
||||
manual = False,
|
||||
# idlethreshold
|
||||
threshold = 60*self.config.idleTime(),
|
||||
# idleaction
|
||||
action = self.idleaction,
|
||||
# idletimer
|
||||
timer = QtCore.QTimer(self),
|
||||
# idleposition
|
||||
pos = QtGui.QCursor.pos(),
|
||||
# idletime
|
||||
time = 0
|
||||
))
|
||||
self.connect(self.idler.timer, QtCore.SIGNAL('timeout()'),
|
||||
self, QtCore.SLOT('checkIdle()'))
|
||||
self.idletimer.start(1000)
|
||||
self.idler.timer.start(1000)
|
||||
|
||||
if not self.config.defaultprofile():
|
||||
self.changeProfile()
|
||||
|
@ -2026,8 +2038,49 @@ class PesterWindow(MovingWindow):
|
|||
@QtCore.pyqtSlot(bool)
|
||||
def toggleIdle(self, idle):
|
||||
if idle:
|
||||
# We checked the box to go idle.
|
||||
self.idler.manual = True
|
||||
self.setAway.emit(True)
|
||||
self.randhandler.setIdle(True)
|
||||
self._sendIdleMsgs()
|
||||
else:
|
||||
self.idler.manual = False
|
||||
self.setAway.emit(False)
|
||||
self.randhandler.setIdle(False)
|
||||
self.idler.time = 0
|
||||
# karxi: TODO: Need to consider sticking an idle-setter here.
|
||||
@QtCore.pyqtSlot()
|
||||
def checkIdle(self):
|
||||
# TODO: Streamline this later, because ew.
|
||||
newpos = QtGui.QCursor.pos()
|
||||
if self.idler.manual:
|
||||
# We're already idle - because the user said to be.
|
||||
self.idler.pos = newpos
|
||||
return
|
||||
|
||||
if newpos == self.idler.pos:
|
||||
if not self.idler.auto:
|
||||
# We're not already automatically idle.
|
||||
# The cursor hasn't moved; we're that much closer to being idle.
|
||||
self.idler.time += 1
|
||||
else:
|
||||
# The cursor moved; reset the idle timer.
|
||||
self.idler.time = 0
|
||||
|
||||
if self.idler.time >= self.idler.threshold:
|
||||
# We've been idle for long enough to fall automatically idle.
|
||||
self.idler.auto = True
|
||||
# We don't need this anymore.
|
||||
self.idler.time = 0
|
||||
self._sendIdleMsgs()
|
||||
else:
|
||||
# The mouse moved, and we were auto-away'd.
|
||||
if self.idler.auto:
|
||||
# ...so un-idle us.
|
||||
self.idler.auto = False
|
||||
self.idler.pos = newpos
|
||||
def _sendIdleMsgs(self):
|
||||
# Tell everyone we're in a chat with that we just went idle.
|
||||
sysColor = QtGui.QColor(self.theme["convo/systemMsgColor"])
|
||||
verb = self.theme["convo/text/idle"]
|
||||
for (h, convo) in self.convos.iteritems():
|
||||
|
@ -2043,27 +2096,6 @@ class PesterWindow(MovingWindow):
|
|||
convo.textArea.append(convertTags(msg))
|
||||
self.chatlog.log(handle, msg)
|
||||
self.sendMessage.emit("PESTERCHUM:IDLE", handle)
|
||||
else:
|
||||
self.setAway.emit(False)
|
||||
self.randhandler.setIdle(False)
|
||||
self.idletime = 0
|
||||
@QtCore.pyqtSlot()
|
||||
def checkIdle(self):
|
||||
newpos = QtGui.QCursor.pos()
|
||||
if newpos == self.idleposition:
|
||||
self.idletime += 1
|
||||
else:
|
||||
self.idletime = 0
|
||||
if self.idletime >= self.idlethreshold:
|
||||
if not self.idleaction.isChecked():
|
||||
self.idleaction.toggle()
|
||||
self.autoidle = True
|
||||
else:
|
||||
if self.autoidle:
|
||||
if self.idleaction.isChecked():
|
||||
self.idleaction.toggle()
|
||||
self.autoidle = False
|
||||
self.idleposition = newpos
|
||||
@QtCore.pyqtSlot()
|
||||
def importExternalConfig(self):
|
||||
f = QtGui.QFileDialog.getOpenFileName(self)
|
||||
|
@ -2428,7 +2460,7 @@ class PesterWindow(MovingWindow):
|
|||
curidle = self.config.idleTime()
|
||||
if idlesetting != curidle:
|
||||
self.config.set('idleTime', idlesetting)
|
||||
self.idlethreshold = 60*idlesetting
|
||||
self.idler.threshold = 60*idlesetting
|
||||
# theme
|
||||
ghostchumsetting = self.optionmenu.ghostchum.isChecked()
|
||||
curghostchum = self.config.ghostchum()
|
||||
|
@ -3120,6 +3152,11 @@ Click this message to never see this again.")
|
|||
self.showLoading(self.widget)
|
||||
sys.exit(self.app.exec_())
|
||||
|
||||
def _retrieveGlobals():
|
||||
# NOTE: Yes, this is a terrible kludge so that the console can work
|
||||
# properly. I'm open to alternatives.
|
||||
return globals()
|
||||
|
||||
if __name__ == "__main__":
|
||||
# We're being run as a script - not being imported.
|
||||
pesterchum = MainProgram()
|
||||
|
|
Loading…
Reference in a new issue