Timestamps for conversations and logs.

Options for turning timestamps on/off, 12/24 hour time, seconds/no seconds.
This commit is contained in:
Kiooeht 2011-03-11 23:44:59 -08:00
parent b2e5841469
commit 06bcad0ca0
3 changed files with 114 additions and 59 deletions

View file

@ -2,6 +2,7 @@ from string import Template
import re import re
import platform import platform
import httplib, urllib import httplib, urllib
from time import strftime
from copy import copy from copy import copy
from datetime import datetime, timedelta from datetime import datetime, timedelta
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
@ -221,6 +222,17 @@ class PesterText(QtGui.QTextEdit):
parent = self.parent() parent = self.parent()
window = parent.mainwindow window = parent.mainwindow
me = window.profile() me = window.profile()
if self.parent().mainwindow.config.showTimeStamps():
if self.parent().mainwindow.config.time12Format():
time = strftime("[%I:%M")
else:
time = strftime("[%H:%M")
if self.parent().mainwindow.config.showSeconds():
time += strftime(":%S] ")
else:
time += "] "
else:
time = ""
if lexmsg[0] == "PESTERCHUM:BEGIN": if lexmsg[0] == "PESTERCHUM:BEGIN":
parent.setChumOpen(True) parent.setChumOpen(True)
pmsg = chum.pestermsg(me, systemColor, window.theme["convo/text/beganpester"]) pmsg = chum.pestermsg(me, systemColor, window.theme["convo/text/beganpester"])
@ -253,7 +265,7 @@ class PesterText(QtGui.QTextEdit):
window.chatlog.log(parent.chum.handle, memsg) window.chatlog.log(parent.chum.handle, memsg)
else: else:
window.chatlog.log(chum.handle, memsg) window.chatlog.log(chum.handle, memsg)
self.append(convertTags(memsg)) self.append(time + convertTags(memsg))
else: else:
if not parent.chumopen and chum is not me: if not parent.chumopen and chum is not me:
beginmsg = chum.pestermsg(me, systemColor, window.theme["convo/text/beganpester"]) beginmsg = chum.pestermsg(me, systemColor, window.theme["convo/text/beganpester"])
@ -264,7 +276,7 @@ class PesterText(QtGui.QTextEdit):
lexmsg[0:0] = [colorBegin("<c=%s>" % (color), color), lexmsg[0:0] = [colorBegin("<c=%s>" % (color), color),
"%s: " % (initials)] "%s: " % (initials)]
lexmsg.append(colorEnd("</c>")) lexmsg.append(colorEnd("</c>"))
self.append(convertTags(lexmsg)) self.append(time + convertTags(lexmsg))
if chum is me: if chum is me:
window.chatlog.log(parent.chum.handle, lexmsg) window.chatlog.log(parent.chum.handle, lexmsg)
else: else:

View file

@ -517,6 +517,22 @@ class PesterOptions(QtGui.QDialog):
self.soundcheck = QtGui.QCheckBox("Sounds On", self) self.soundcheck = QtGui.QCheckBox("Sounds On", self)
if self.config.soundOn(): if self.config.soundOn():
self.soundcheck.setChecked(True) self.soundcheck.setChecked(True)
self.timestampcheck = QtGui.QCheckBox("Time Stamps", self)
if self.config.showTimeStamps():
self.timestampcheck.setChecked(True)
self.timestampBox = QtGui.QComboBox(self)
self.timestampBox.addItem("12 hour")
self.timestampBox.addItem("24 hour")
if self.config.time12Format():
self.timestampBox.setCurrentIndex(0)
else:
self.timestampBox.setCurrentIndex(1)
self.secondscheck = QtGui.QCheckBox("Show Seconds", self)
if self.config.showSeconds():
self.secondscheck.setChecked(True)
self.ok = QtGui.QPushButton("OK", self) self.ok = QtGui.QPushButton("OK", self)
self.ok.setDefault(True) self.ok.setDefault(True)
self.connect(self.ok, QtCore.SIGNAL('clicked()'), self.connect(self.ok, QtCore.SIGNAL('clicked()'),
@ -532,6 +548,9 @@ class PesterOptions(QtGui.QDialog):
layout_0.addWidget(self.tabcheck) layout_0.addWidget(self.tabcheck)
layout_0.addWidget(self.soundcheck) layout_0.addWidget(self.soundcheck)
layout_0.addWidget(self.hideOffline) layout_0.addWidget(self.hideOffline)
layout_0.addWidget(self.timestampcheck)
layout_0.addWidget(self.timestampBox)
layout_0.addWidget(self.secondscheck)
layout_0.addLayout(layout_2) layout_0.addLayout(layout_2)
self.setLayout(layout_0) self.setLayout(layout_0)

View file

@ -12,6 +12,7 @@ import socket
import platform import platform
from PyQt4 import QtGui, QtCore from PyQt4 import QtGui, QtCore
import pygame import pygame
from time import strftime
from menus import PesterChooseQuirks, PesterChooseTheme, \ from menus import PesterChooseQuirks, PesterChooseTheme, \
PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \ PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \
@ -76,9 +77,10 @@ class PesterLog(object):
self.logpath = _datadir+"logs" self.logpath = _datadir+"logs"
def log(self, handle, msg): def log(self, handle, msg):
bbcodemsg = convertTags(msg, "bbcode") time = strftime("[%H:%M:%S] ")
html = convertTags(msg, "html")+"<br />" bbcodemsg = time + convertTags(msg, "bbcode")
msg = convertTags(msg, "text") html = time + convertTags(msg, "html")+"<br />"
msg = time + convertTags(msg, "text")
modes = {"bbcode": bbcodemsg, "html": html, "text": msg} modes = {"bbcode": bbcodemsg, "html": html, "text": msg}
if not self.convos.has_key(handle): if not self.convos.has_key(handle):
time = datetime.now().strftime("%Y-%m-%d.%H.%M") time = datetime.now().strftime("%Y-%m-%d.%H.%M")
@ -249,6 +251,18 @@ class userConfig(object):
return None return None
def tabs(self): def tabs(self):
return self.config.get("tabs", True) return self.config.get("tabs", True)
def showTimeStamps(self):
if not self.config.has_key('showTimeStamps'):
self.set("showTimeStamps", True)
return self.config.get('showTimeStamps', True)
def time12Format(self):
if not self.config.has_key('time12Format'):
self.set("time12Format", True)
return self.config.get('time12Format', True)
def showSeconds(self):
if not self.config.has_key('showSeconds'):
self.set("showSeconds", False)
return self.config.get('showSeconds', False)
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??
@ -1655,6 +1669,16 @@ class PesterWindow(MovingWindow):
# sound # sound
soundsetting = self.optionmenu.soundcheck.isChecked() soundsetting = self.optionmenu.soundcheck.isChecked()
self.config.set("soundon", soundsetting) self.config.set("soundon", soundsetting)
# timestamps
timestampsetting = self.optionmenu.timestampcheck.isChecked()
self.config.set("showTimeStamps", timestampsetting)
timeformatsetting = unicode(self.optionmenu.timestampBox.currentText())
if timeformatsetting == "12 hour":
self.config.set("time12Format", True)
else:
self.config.set("time12Format", False)
secondssetting = self.optionmenu.secondscheck.isChecked()
self.config.set("showSeconds", secondssetting)
self.optionmenu = None self.optionmenu = None
@QtCore.pyqtSlot() @QtCore.pyqtSlot()