Timestamps for conversations and logs.
Options for turning timestamps on/off, 12/24 hour time, seconds/no seconds.
This commit is contained in:
parent
b2e5841469
commit
06bcad0ca0
3 changed files with 114 additions and 59 deletions
16
convo.py
16
convo.py
|
@ -2,6 +2,7 @@ from string import Template
|
|||
import re
|
||||
import platform
|
||||
import httplib, urllib
|
||||
from time import strftime
|
||||
from copy import copy
|
||||
from datetime import datetime, timedelta
|
||||
from PyQt4 import QtGui, QtCore
|
||||
|
@ -221,6 +222,17 @@ class PesterText(QtGui.QTextEdit):
|
|||
parent = self.parent()
|
||||
window = parent.mainwindow
|
||||
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":
|
||||
parent.setChumOpen(True)
|
||||
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)
|
||||
else:
|
||||
window.chatlog.log(chum.handle, memsg)
|
||||
self.append(convertTags(memsg))
|
||||
self.append(time + convertTags(memsg))
|
||||
else:
|
||||
if not parent.chumopen and chum is not me:
|
||||
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),
|
||||
"%s: " % (initials)]
|
||||
lexmsg.append(colorEnd("</c>"))
|
||||
self.append(convertTags(lexmsg))
|
||||
self.append(time + convertTags(lexmsg))
|
||||
if chum is me:
|
||||
window.chatlog.log(parent.chum.handle, lexmsg)
|
||||
else:
|
||||
|
|
19
menus.py
19
menus.py
|
@ -517,6 +517,22 @@ class PesterOptions(QtGui.QDialog):
|
|||
self.soundcheck = QtGui.QCheckBox("Sounds On", self)
|
||||
if self.config.soundOn():
|
||||
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.setDefault(True)
|
||||
self.connect(self.ok, QtCore.SIGNAL('clicked()'),
|
||||
|
@ -532,6 +548,9 @@ class PesterOptions(QtGui.QDialog):
|
|||
layout_0.addWidget(self.tabcheck)
|
||||
layout_0.addWidget(self.soundcheck)
|
||||
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)
|
||||
|
||||
self.setLayout(layout_0)
|
||||
|
|
|
@ -12,6 +12,7 @@ import socket
|
|||
import platform
|
||||
from PyQt4 import QtGui, QtCore
|
||||
import pygame
|
||||
from time import strftime
|
||||
|
||||
from menus import PesterChooseQuirks, PesterChooseTheme, \
|
||||
PesterChooseProfile, PesterOptions, PesterUserlist, PesterMemoList, \
|
||||
|
@ -76,9 +77,10 @@ class PesterLog(object):
|
|||
self.logpath = _datadir+"logs"
|
||||
|
||||
def log(self, handle, msg):
|
||||
bbcodemsg = convertTags(msg, "bbcode")
|
||||
html = convertTags(msg, "html")+"<br />"
|
||||
msg = convertTags(msg, "text")
|
||||
time = strftime("[%H:%M:%S] ")
|
||||
bbcodemsg = time + convertTags(msg, "bbcode")
|
||||
html = time + convertTags(msg, "html")+"<br />"
|
||||
msg = time + convertTags(msg, "text")
|
||||
modes = {"bbcode": bbcodemsg, "html": html, "text": msg}
|
||||
if not self.convos.has_key(handle):
|
||||
time = datetime.now().strftime("%Y-%m-%d.%H.%M")
|
||||
|
@ -249,6 +251,18 @@ class userConfig(object):
|
|||
return None
|
||||
def tabs(self):
|
||||
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):
|
||||
if chum.handle not in self.chums():
|
||||
fp = open(self.filename) # what if we have two clients open??
|
||||
|
@ -1655,6 +1669,16 @@ class PesterWindow(MovingWindow):
|
|||
# sound
|
||||
soundsetting = self.optionmenu.soundcheck.isChecked()
|
||||
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
|
||||
|
||||
@QtCore.pyqtSlot()
|
||||
|
|
Loading…
Reference in a new issue