Tabbed options menu, turn logging on and off

This commit is contained in:
Kiooeht 2011-04-27 18:53:03 -07:00
parent 973235a95d
commit 15917bd5d9
3 changed files with 64 additions and 16 deletions

View file

@ -19,6 +19,7 @@ class PesterTabWindow(QtGui.QFrame):
self.mainwindow = mainwindow self.mainwindow = mainwindow
self.tabs = QtGui.QTabBar(self) self.tabs = QtGui.QTabBar(self)
self.tabs.setMovable(True)
self.tabs.setTabsClosable(True) self.tabs.setTabsClosable(True)
self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'), self.connect(self.tabs, QtCore.SIGNAL('currentChanged(int)'),
self, QtCore.SLOT('changeTab(int)')) self, QtCore.SLOT('changeTab(int)'))

View file

@ -566,6 +566,13 @@ class PesterOptions(QtGui.QDialog):
hr.setFrameShape(QtGui.QFrame.HLine) hr.setFrameShape(QtGui.QFrame.HLine)
hr.setFrameShadow(QtGui.QFrame.Sunken) hr.setFrameShadow(QtGui.QFrame.Sunken)
self.tabs = QtGui.QTabWidget(self)
self.tabs.setMovable(True)
self.tabs.setUsesScrollButtons(False)
tabNames = ["Interface", "Chum List", "Conversations", "Logging"]
for t in tabNames:
self.tabs.addTab(QtGui.QWidget(), t)
self.tabcheck = QtGui.QCheckBox("Tabbed Conversations", self) self.tabcheck = QtGui.QCheckBox("Tabbed Conversations", self)
if self.config.tabs(): if self.config.tabs():
self.tabcheck.setChecked(True) self.tabcheck.setChecked(True)
@ -611,6 +618,11 @@ class PesterOptions(QtGui.QDialog):
layout_3.addWidget(sortLabel) layout_3.addWidget(sortLabel)
layout_3.addWidget(self.sortBox, 10) layout_3.addWidget(self.sortBox, 10)
self.logpesterscheck = QtGui.QCheckBox("Log all chats", self)
self.logpesterscheck.setChecked(self.config.logPesters())
self.logmemoscheck = QtGui.QCheckBox("Log all memos", self)
self.logmemoscheck.setChecked(self.config.logMemos())
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()'),
@ -622,20 +634,37 @@ class PesterOptions(QtGui.QDialog):
layout_2.addWidget(self.cancel) layout_2.addWidget(self.cancel)
layout_2.addWidget(self.ok) layout_2.addWidget(self.ok)
# Tab layouts
# Interface
layout_interface = QtGui.QVBoxLayout(self.tabs.widget(0))
layout_interface.setAlignment(QtCore.Qt.AlignTop)
layout_interface.addWidget(self.tabcheck)
layout_interface.addWidget(self.soundcheck)
# Chum List
layout_chumlist = QtGui.QVBoxLayout(self.tabs.widget(1))
layout_chumlist.setAlignment(QtCore.Qt.AlignTop)
layout_chumlist.addWidget(self.hideOffline)
#layout_chumlist.addWidget(self.groupscheck)
layout_chumlist.addWidget(self.showemptycheck)
layout_chumlist.addWidget(self.showonlinenumbers)
layout_chumlist.addLayout(layout_3)
# Conversations
layout_chat = QtGui.QVBoxLayout(self.tabs.widget(2))
layout_chat.setAlignment(QtCore.Qt.AlignTop)
layout_chat.addWidget(self.timestampcheck)
layout_chat.addWidget(self.timestampBox)
layout_chat.addWidget(self.secondscheck)
# Logging
layout_logs = QtGui.QVBoxLayout(self.tabs.widget(3))
layout_logs.setAlignment(QtCore.Qt.AlignTop)
layout_logs.addWidget(self.logpesterscheck)
layout_logs.addWidget(self.logmemoscheck)
layout_0 = QtGui.QVBoxLayout() layout_0 = QtGui.QVBoxLayout()
layout_0.addWidget(self.tabcheck) layout_0.addWidget(self.tabs)
layout_0.addWidget(self.soundcheck)
layout_0.addWidget(self.hideOffline)
#layout_0.addWidget(self.groupscheck)
layout_0.addWidget(self.showemptycheck)
layout_0.addWidget(self.showonlinenumbers)
#layout_0.addWidget(sortLabel)
#layout_0.addWidget(self.sortBox)
layout_0.addLayout(layout_3)
layout_0.addWidget(hr)
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

@ -69,8 +69,9 @@ class NoneSound(object):
def play(self): pass def play(self): pass
class PesterLog(object): class PesterLog(object):
def __init__(self, handle): def __init__(self, handle, parent=None):
global _datadir global _datadir
self.parent = parent
self.handle = handle self.handle = handle
self.convos = {} self.convos = {}
if sys.platform != "darwin": if sys.platform != "darwin":
@ -79,6 +80,10 @@ class PesterLog(object):
self.logpath = _datadir+"logs" self.logpath = _datadir+"logs"
def log(self, handle, msg): def log(self, handle, msg):
if handle[0] == '#':
if not self.parent.config.logMemos(): return
else:
if not self.parent.config.logPesters(): return
#watch out for illegal characters #watch out for illegal characters
handle = re.sub(r'[<>:"/\\|?*]', "_", handle) handle = re.sub(r'[<>:"/\\|?*]', "_", handle)
#time = strftime("[%H:%M:%S] ") #time = strftime("[%H:%M:%S] ")
@ -329,6 +334,10 @@ class userConfig(object):
if not self.config.has_key('onlineNumbers'): if not self.config.has_key('onlineNumbers'):
self.set("onlineNumbers", False) self.set("onlineNumbers", False)
return self.config.get('onlineNumbers', False) return self.config.get('onlineNumbers', False)
def logPesters(self):
return self.config.get('logPesters', True)
def logMemos(self):
return self.config.get('logMemos', True)
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??
@ -1287,7 +1296,7 @@ class PesterWindow(MovingWindow):
self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0))) self.userprofile = userProfile(PesterProfile("pesterClient%d" % (random.randint(100,999)), QtGui.QColor("black"), Mood(0)))
self.theme = self.userprofile.getTheme() self.theme = self.userprofile.getTheme()
self.chatlog = PesterLog(self.profile().handle) self.chatlog = PesterLog(self.profile().handle, self)
self.move(100, 100) self.move(100, 100)
@ -2281,6 +2290,15 @@ class PesterWindow(MovingWindow):
elif curonlinenum and not onlinenumsetting: elif curonlinenum and not onlinenumsetting:
self.chumList.hideOnlineNumbers() self.chumList.hideOnlineNumbers()
self.config.set("onlineNumbers", onlinenumsetting) self.config.set("onlineNumbers", onlinenumsetting)
# logging
logpesterssetting = self.optionmenu.logpesterscheck.isChecked()
curlogpesters = self.config.logPesters()
if logpesterssetting != curlogpesters:
self.config.set('logPesters', logpesterssetting)
logmemossetting = self.optionmenu.logmemoscheck.isChecked()
curlogmemos = self.config.logMemos()
if logmemossetting != curlogmemos:
self.config.set('logMemos', logmemossetting)
self.optionmenu = None self.optionmenu = None
@QtCore.pyqtSlot() @QtCore.pyqtSlot()
@ -2322,7 +2340,7 @@ class PesterWindow(MovingWindow):
self.changeTheme(self.userprofile.getTheme()) self.changeTheme(self.userprofile.getTheme())
self.chatlog.close() self.chatlog.close()
self.chatlog = PesterLog(handle) self.chatlog = PesterLog(handle, self)
# is default? # is default?
if self.chooseprofile.defaultcheck.isChecked(): if self.chooseprofile.defaultcheck.isChecked():