sounds, idle, etc

This commit is contained in:
Stephen Dranger 2011-02-10 19:55:45 -06:00
parent 87cbeca5dd
commit 2dbd124c2d
22 changed files with 92 additions and 13 deletions

11
TODO
View file

@ -1,22 +1,19 @@
Features: Features:
* Tray doesn't disappear on windows after close * Tray doesn't disappear on windows after close
* Idling
* PESTERCHUM:BLOCKED
* new sound on CEASE and BEGIN?
* scroll bar style? * scroll bar style?
* flashing??
* More complex quirks: random, spelling, by-sound * More complex quirks: random, spelling, by-sound
* change profile only once we have confirmation from server
* convert hex tags (<GFFFFFF> or <GFF0000>) * convert hex tags (<GFFFFFF> or <GFF0000>)
* convo backgrounds -- make them more like http://www.mspaintadventures.com/storyfiles/hs2/02546_2.gif
* help button on quirks menu?
* help menu -- about and forum * help menu -- about and forum
* dropped messages when chatting ?
-- release alpha -- release alpha
* shared buddy lists - changes to the buddy list should refresh it? * shared buddy lists - changes to the buddy list should refresh it?
multiple clients share buddy list??? multiple clients share buddy list???
* chumList not scaling -- QListView + delegate? * chumList not scaling -- QListView + delegate?
* spell check? * spell check?
* convo backgrounds -- make them more like http://www.mspaintadventures.com/storyfiles/hs2/02546_2.gif
* help button on quirks menu?
-- release beta -- release beta
* change profile only once we have confirmation from server
* log viewer * log viewer
* pick your own icon * pick your own icon
* time codes * time codes

View file

@ -1,5 +1,6 @@
from string import Template from string import Template
import re import re
from datetime import datetime, timedelta
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
from dataobjs import PesterProfile, Mood, PesterHistory from dataobjs import PesterProfile, Mood, PesterHistory
@ -223,6 +224,14 @@ class PesterText(QtGui.QTextEdit):
msg = chum.pestermsg(me, systemColor, window.theme['convo/text/unblocked']) msg = chum.pestermsg(me, systemColor, window.theme['convo/text/unblocked'])
window.chatlog.log(chum.handle, convertTags(msg, "bbcode")) window.chatlog.log(chum.handle, convertTags(msg, "bbcode"))
self.append(convertTags(msg)) self.append(convertTags(msg))
elif msg == "PESTERCHUM:BLOCKED":
msg = chum.pestermsg(me, systemColor, window.theme['convo/text/blockedmsg'])
window.chatlog.log(chum.handle, convertTags(msg, "bbcode"))
self.append(convertTags(msg))
elif msg == "PESTERCHUM:IDLE":
msg = chum.idlemsg(systemColor, window.theme['convo/text/idle'])
window.chatlog.log(chum.handle, convertTags(msg, "bbcode"))
self.append(convertTags(msg))
elif msg[0:3] == "/me" or msg[0:13] == "PESTERCHUM:ME": elif msg[0:3] == "/me" or msg[0:13] == "PESTERCHUM:ME":
if msg[0:3] == "/me": if msg[0:3] == "/me":
start = 3 start = 3
@ -248,6 +257,12 @@ class PesterText(QtGui.QTextEdit):
if chum is me: if chum is me:
window.chatlog.log(parent.chum.handle, convertTags(msg, "bbcode")) window.chatlog.log(parent.chum.handle, convertTags(msg, "bbcode"))
else: else:
if window.idle:
idlethreshhold = 60
if (not hasattr(self, 'lastmsg')) or \
datetime.now() - self.lastmsg > timedelta(0,60):
parent.messageSent.emit("PESTERCHUM:IDLE", parent.title())
self.lastmsg = datetime.now()
window.chatlog.log(chum.handle, convertTags(msg, "bbcode")) window.chatlog.log(chum.handle, convertTags(msg, "bbcode"))
def changeTheme(self, theme): def changeTheme(self, theme):
self.setStyleSheet(theme["convo/textarea/style"]) self.setStyleSheet(theme["convo/textarea/style"])
@ -295,6 +310,7 @@ class PesterInput(QtGui.QLineEdit):
self.setText(prev) self.setText(prev)
elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]: elif event.key() in [QtCore.Qt.Key_PageUp, QtCore.Qt.Key_PageDown]:
self.parent().textArea.keyPressEvent(event) self.parent().textArea.keyPressEvent(event)
self.parent().mainwindow.idletime = 0
QtGui.QLineEdit.keyPressEvent(self, event) QtGui.QLineEdit.keyPressEvent(self, event)
@ -348,6 +364,10 @@ class PesterConvo(QtGui.QFrame):
self.quirksOff.setCheckable(True) self.quirksOff.setCheckable(True)
self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'), self.connect(self.quirksOff, QtCore.SIGNAL('toggled(bool)'),
self, QtCore.SLOT('toggleQuirks(bool)')) self, QtCore.SLOT('toggleQuirks(bool)'))
self.unblockchum = QtGui.QAction(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
self.connect(self.unblockchum, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('unblockChumSlot()'))
self.optionsMenu.addAction(self.quirksOff) self.optionsMenu.addAction(self.quirksOff)
self.optionsMenu.addAction(self.addChumAction) self.optionsMenu.addAction(self.addChumAction)
self.optionsMenu.addAction(self.blockAction) self.optionsMenu.addAction(self.blockAction)
@ -373,6 +393,7 @@ class PesterConvo(QtGui.QFrame):
def updateMood(self, mood, unblocked=False, old=None): def updateMood(self, mood, unblocked=False, old=None):
syscolor = QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"]) syscolor = QtGui.QColor(self.mainwindow.theme["convo/systemMsgColor"])
if mood.name() == "offline" and self.chumopen == True and not unblocked: if mood.name() == "offline" and self.chumopen == True and not unblocked:
self.mainwindow.ceasesound.play()
msg = self.chum.pestermsg(self.mainwindow.profile(), syscolor, self.mainwindow.theme["convo/text/ceasepester"]) msg = self.chum.pestermsg(self.mainwindow.profile(), syscolor, self.mainwindow.theme["convo/text/ceasepester"])
self.textArea.append(convertTags(msg)) self.textArea.append(convertTags(msg))
self.mainwindow.chatlog.log(self.title(), convertTags(msg, "bbcode")) self.mainwindow.chatlog.log(self.title(), convertTags(msg, "bbcode"))
@ -386,14 +407,21 @@ class PesterConvo(QtGui.QFrame):
else: else:
if self.chum.blocked(self.mainwindow.config) and not unblocked: if self.chum.blocked(self.mainwindow.config) and not unblocked:
self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"])) self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"]))
self.optionsMenu.addAction(self.unblockchum)
self.optionsMenu.removeAction(self.blockAction)
else: else:
self.setWindowIcon(mood.icon(self.mainwindow.theme)) self.setWindowIcon(mood.icon(self.mainwindow.theme))
self.optionsMenu.removeAction(self.unblockchum)
self.optionsMenu.addAction(self.blockAction)
# print mood update? # print mood update?
def updateBlocked(self): def updateBlocked(self):
if self.parent(): if self.parent():
self.parent().updateBlocked(self.title()) self.parent().updateBlocked(self.title())
else: else:
self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"])) self.setWindowIcon(QtGui.QIcon(self.mainwindow.theme["main/chums/moods/blocked/icon"]))
self.optionsMenu.addAction(self.unblockchum)
self.optionsMenu.removeAction(self.blockAction)
def updateColor(self, color): def updateColor(self, color):
self.chum.color = color self.chum.color = color
def addMessage(self, text, me=True): def addMessage(self, text, me=True):
@ -468,6 +496,7 @@ class PesterConvo(QtGui.QFrame):
self.quirksOff.setText(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"]) self.quirksOff.setText(self.mainwindow.theme["main/menus/rclickchumlist/quirksoff"])
self.addChumAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/addchum"]) self.addChumAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/addchum"])
self.blockAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"]) self.blockAction.setText(self.mainwindow.theme["main/menus/rclickchumlist/blockchum"])
self.unblockchum.setText(self.mainwindow.theme["main/menus/rclickchumlist/unblockchum"], self)
self.textArea.changeTheme(theme) self.textArea.changeTheme(theme)
self.textInput.changeTheme(theme) self.textInput.changeTheme(theme)
@ -498,11 +527,13 @@ class PesterConvo(QtGui.QFrame):
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def blockThisChum(self): def blockThisChum(self):
self.mainwindow.blockChum(self.chum.handle) self.mainwindow.blockChum(self.chum.handle)
@QtCore.pyqtSlot()
def unblockChumSlot(self):
self.mainwindow.unblockChum(self.chum.handle)
@QtCore.pyqtSlot(bool) @QtCore.pyqtSlot(bool)
def toggleQuirks(self, toggled): def toggleQuirks(self, toggled):
self.applyquirks = not toggled self.applyquirks = not toggled
messageSent = QtCore.pyqtSignal(QtCore.QString, QtCore.QString) messageSent = QtCore.pyqtSignal(QtCore.QString, QtCore.QString)
windowClosed = QtCore.pyqtSignal(QtCore.QString) windowClosed = QtCore.pyqtSignal(QtCore.QString)

BIN
convo.pyc

Binary file not shown.

View file

@ -140,6 +140,8 @@ class PesterProfile(object):
return "<c=%s>-- %s <c=%s>[%s]</c> %s %s <c=%s>[%s]</c> at %s --</c>" % (syscolor.name(), self.handle, self.colorhtml(), self.initials(), verb, otherchum.handle, otherchum.colorhtml(), otherchum.initials(), datetime.now().strftime("%H:%M")) return "<c=%s>-- %s <c=%s>[%s]</c> %s %s <c=%s>[%s]</c> at %s --</c>" % (syscolor.name(), self.handle, self.colorhtml(), self.initials(), verb, otherchum.handle, otherchum.colorhtml(), otherchum.initials(), datetime.now().strftime("%H:%M"))
def moodmsg(self, mood, syscolor, theme): def moodmsg(self, mood, syscolor, theme):
return "<c=%s>-- %s <c=%s>[%s]</c> changed their mood to %s <img src='%s' /> --</c>" % (syscolor.name(), self.handle, self.colorhtml(), self.initials(), mood.name().upper(), theme["main/chums/moods"][mood.name()]["icon"]) return "<c=%s>-- %s <c=%s>[%s]</c> changed their mood to %s <img src='%s' /> --</c>" % (syscolor.name(), self.handle, self.colorhtml(), self.initials(), mood.name().upper(), theme["main/chums/moods"][mood.name()]["icon"])
def idlemsg(self, syscolor, verb):
return "<c=%s>-- %s <c=%s>[%s]</c> %s --" % (syscolor.name(), self.handle, self.colorhtml(), self.initials(), verb)
def memoclosemsg(self, syscolor, timeGrammar, verb): def memoclosemsg(self, syscolor, timeGrammar, verb):
return "<c=%s><c=%s>%s%s%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), timeGrammar.pcf, self.initials(), timeGrammar.number, verb) return "<c=%s><c=%s>%s%s%s</c> %s.</c>" % (syscolor.name(), self.colorhtml(), timeGrammar.pcf, self.initials(), timeGrammar.number, verb)
def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel): def memoopenmsg(self, syscolor, td, timeGrammar, verb, channel):

Binary file not shown.

Binary file not shown.

BIN
irc.pyc

Binary file not shown.

BIN
memos.pyc

Binary file not shown.

BIN
menus.pyc

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"tabs": true, "soundon": true, "chums": ["marineAquist", "unknownTraveler", "tentacleTherapist", "macruralAlchemist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "adiosToreador", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "maxiumumFatness", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "acapellaWaterfall", "anguillaNuntia", "oilslickOrchid", "confusedTransient", "pretentiousFantasia", "aquaticMarinist", "ardentAbettor"], "defaultprofile": "ghostDunk", "block": []} {"tabs": true, "soundon": true, "chums": ["unknownTraveler", "tentacleTherapist", "vaginalEngineer", "mechanicalSpectacle", "carcinoGeneticist", "schlagzeugGator", "gamblingGenocider", "gardenGnostic", "superGhost", "centaursTesticle", "arachnidsGrip", "grimAuxiliatrix", "remoteBloodbath", "nitroZealist", "greenZephyr", "arsenicCatnip", "adiosToreador", "cuttlefishCuller", "rageInducer", "gallowsCalibrator", "caligulasAquarium", "terminallyCapricious", "illuminatedWax", "aquaMarinist", "maxiumumFatness", "elegantDiversion", "moirailBunp", "uroborosUnbound", "androidTechnician", "midnightSparrow", "apocalypseArisen", "anguillaNuntia", "oilslickOrchid", "confusedTransient", "pretentiousFantasia", "aquaticMarinist"], "defaultprofile": "ghostDunk", "block": []}

View file

@ -662,6 +662,7 @@ class PesterWindow(MovingWindow):
self.importaction = QtGui.QAction(self.theme["main/menus/client/import"], self) self.importaction = QtGui.QAction(self.theme["main/menus/client/import"], self)
self.connect(self.importaction, QtCore.SIGNAL('triggered()'), self.connect(self.importaction, QtCore.SIGNAL('triggered()'),
self, QtCore.SLOT('importExternalConfig()')) self, QtCore.SLOT('importExternalConfig()'))
self.menu = QtGui.QMenuBar(self) self.menu = QtGui.QMenuBar(self)
filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"]) filemenu = self.menu.addMenu(self.theme["main/menus/client/_name"])
@ -762,6 +763,15 @@ class PesterWindow(MovingWindow):
self.waitingMessages = waitingMessageHolder(self) self.waitingMessages = waitingMessageHolder(self)
self.idle = False
self.idlethreshold = 600
self.idletimer = QtCore.QTimer(self)
self.idleposition = QtGui.QCursor.pos()
self.idletime = 0
self.connect(self.idletimer, QtCore.SIGNAL('timeout()'),
self, QtCore.SLOT('checkIdle()'))
self.idletimer.start(1000)
if not self.config.defaultprofile(): if not self.config.defaultprofile():
self.changeProfile() self.changeProfile()
self.loadingscreen = LoadingScreen(self) self.loadingscreen = LoadingScreen(self)
@ -800,6 +810,7 @@ class PesterWindow(MovingWindow):
def newMessage(self, handle, msg): def newMessage(self, handle, msg):
if handle in self.config.getBlocklist(): if handle in self.config.getBlocklist():
#yeah suck on this #yeah suck on this
self.sendMessage.emit("PESTERCHUM:BLOCKED", handle)
return return
if not self.convos.has_key(handle): if not self.convos.has_key(handle):
if msg == "PESTERCHUM:CEASE": # ignore cease after we hang up if msg == "PESTERCHUM:CEASE": # ignore cease after we hang up
@ -817,7 +828,10 @@ class PesterWindow(MovingWindow):
convo.addMessage(msg, False) convo.addMessage(msg, False)
# play sound here # play sound here
if self.config.soundOn(): if self.config.soundOn():
self.alarm.play() if msg in ["PESTERCHUM:CEASE", "PESTERCHUM:BLOCK"]:
self.ceasesound.play()
else:
self.alarm.play()
def newMemoMsg(self, chan, handle, msg): def newMemoMsg(self, chan, handle, msg):
if not self.memos.has_key(chan): if not self.memos.has_key(chan):
# silently ignore in case we forgot to /part # silently ignore in case we forgot to /part
@ -1016,8 +1030,10 @@ class PesterWindow(MovingWindow):
# sounds # sounds
if not pygame.mixer: if not pygame.mixer:
self.alarm = NoneSound() self.alarm = NoneSound()
self.ceasesound = NoneSound()
else: else:
self.alarm = pygame.mixer.Sound(theme["main/sounds/alertsound"]) self.alarm = pygame.mixer.Sound(theme["main/sounds/alertsound"])
self.ceasesound = pygame.mixer.Sound(theme["main/sounds/ceasesound"])
def changeTheme(self, theme): def changeTheme(self, theme):
self.theme = theme self.theme = theme
@ -1247,6 +1263,32 @@ class PesterWindow(MovingWindow):
self.moodRequest.emit(chum) self.moodRequest.emit(chum)
self.unblockedChum.emit(handle) self.unblockedChum.emit(handle)
@QtCore.pyqtSlot(bool)
def toggleIdle(self, idle):
if self.idle and not idle:
self.idle = False
elif idle and not self.idle:
self.idle = True
sysColor = QtGui.QColor(self.theme["convo/systemMsgColor"])
verb = self.theme["convo/text/idle"]
for (h, convo) in self.convos.iteritems():
msg = self.profile().idlemsg(sysColor, verb)
convo.textArea.append(convertTags(msg))
self.chatlog.log(h, convertTags(msg, "bbcode"))
self.sendMessage.emit("PESTERCHUM:IDLE", h)
@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:
self.toggleIdle(True)
else:
self.toggleIdle(False)
self.idleposition = newpos
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
def importExternalConfig(self): def importExternalConfig(self):
f = QtGui.QFileDialog.getOpenFileName(self) f = QtGui.QFileDialog.getOpenFileName(self)
@ -1695,7 +1737,6 @@ class MainProgram(QtCore.QObject):
irc, irc,
QtCore.SLOT('setChannelMode(QString, QString, QString)')) QtCore.SLOT('setChannelMode(QString, QString, QString)'))
# IRC --> Main window # IRC --> Main window
irc.connect(irc, QtCore.SIGNAL('connected()'), irc.connect(irc, QtCore.SIGNAL('connected()'),
widget, QtCore.SLOT('connected()')) widget, QtCore.SLOT('connected()'))
@ -1752,6 +1793,9 @@ class MainProgram(QtCore.QObject):
def run(self): def run(self):
self.ircapp.start() self.ircapp.start()
self.widget.loadingscreen = LoadingScreen(self.widget)
self.connect(self.widget.loadingscreen, QtCore.SIGNAL('rejected()'),
self.widget, QtCore.SLOT('close()'))
status = self.widget.loadingscreen.exec_() status = self.widget.loadingscreen.exec_()
if status == QtGui.QDialog.Rejected: if status == QtGui.QDialog.Rejected:
sys.exit(0) sys.exit(0)

BIN
themes/pesterchum/cease.wav Normal file

Binary file not shown.

View file

@ -15,12 +15,14 @@
"selected": "background-color: #ffff00", "selected": "background-color: #ffff00",
"loc": [10,0] "loc": [10,0]
}, },
"sounds": { "alertsound": "$path/alarm.wav" }, "sounds": { "alertsound": "$path/alarm.wav",
"ceasesound": "$path/cease.wav" },
"menus": {"client": {"_name": "CLIENT", "menus": {"client": {"_name": "CLIENT",
"options": "OPTIONS", "options": "OPTIONS",
"memos": "MEMOS", "memos": "MEMOS",
"userlist": "USERLIST", "userlist": "USERLIST",
"import": "IMPORT", "import": "IMPORT",
"idle": "IDLE",
"exit": "EXIT"}, "exit": "EXIT"},
"profile": {"_name": "PROFILE", "profile": {"_name": "PROFILE",
"switch": "SWITCH", "switch": "SWITCH",
@ -220,10 +222,12 @@
"ceasepester": "ceased pestering", "ceasepester": "ceased pestering",
"blocked": "blocked", "blocked": "blocked",
"unblocked": "unblocked", "unblocked": "unblocked",
"blockedmsg": "did not receive message from",
"openmemo": "opened memo on board", "openmemo": "opened memo on board",
"joinmemo": "responded to memo", "joinmemo": "responded to memo",
"closememo": "ceased responding to memo", "closememo": "ceased responding to memo",
"kickedmemo": "You have been banned from this memo!" "kickedmemo": "You have been banned from this memo!",
"idle": "is now an idle chum!"
}, },
"systemMsgColor": "#646464" "systemMsgColor": "#646464"
}, },

BIN
themes/trollian/cease.wav Normal file

Binary file not shown.

View file

@ -21,6 +21,7 @@
"memos": "Memos", "memos": "Memos",
"userlist": "Fresh Targets", "userlist": "Fresh Targets",
"import": "import U2;", "import": "import U2;",
"idle":, "Idle",
"exit": "Abscond"}, "exit": "Abscond"},
"profile": {"_name": "View", "profile": {"_name": "View",
"switch": "Trolltag", "switch": "Trolltag",