Sound options rearrange + add

This commit is contained in:
Kiooeht 2011-07-08 01:41:49 -07:00
parent 6e3d00f0c6
commit f9f552fc3f
2 changed files with 45 additions and 15 deletions

View file

@ -941,14 +941,20 @@ class PesterOptions(QtGui.QDialog):
self.chatsoundcheck.setChecked(self.config.chatSound()) self.chatsoundcheck.setChecked(self.config.chatSound())
self.memosoundcheck = QtGui.QCheckBox("Memo Sounds", self) self.memosoundcheck = QtGui.QCheckBox("Memo Sounds", self)
self.memosoundcheck.setChecked(self.config.memoSound()) self.memosoundcheck.setChecked(self.config.memoSound())
self.connect(self.memosoundcheck, QtCore.SIGNAL('stateChanged(int)'),
self, QtCore.SLOT('memoSoundChange(int)'))
self.memopingcheck = QtGui.QCheckBox("Memo Ping", self)
self.memopingcheck.setChecked(self.config.memoPing())
self.namesoundcheck = QtGui.QCheckBox("Memo Mention (initials)", self) self.namesoundcheck = QtGui.QCheckBox("Memo Mention (initials)", self)
self.namesoundcheck.setChecked(self.config.nameSound()) self.namesoundcheck.setChecked(self.config.nameSound())
if self.config.soundOn(): if self.config.soundOn():
self.soundcheck.setChecked(True) self.soundcheck.setChecked(True)
if not self.memosoundcheck.isChecked():
self.memoSoundChange(0)
else: else:
self.chatsoundcheck.setEnabled(False) self.chatsoundcheck.setEnabled(False)
self.memosoundcheck.setEnabled(False) self.memosoundcheck.setEnabled(False)
self.namesoundcheck.setEnabled(False) self.memoSoundChange(0)
self.volume = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.volume = QtGui.QSlider(QtCore.Qt.Horizontal, self)
self.volume.setMinimum(0) self.volume.setMinimum(0)
self.volume.setMaximum(100) self.volume.setMaximum(100)
@ -1144,7 +1150,11 @@ class PesterOptions(QtGui.QDialog):
layout_indent = QtGui.QVBoxLayout() layout_indent = QtGui.QVBoxLayout()
layout_indent.addWidget(self.chatsoundcheck) layout_indent.addWidget(self.chatsoundcheck)
layout_indent.addWidget(self.memosoundcheck) layout_indent.addWidget(self.memosoundcheck)
layout_indent.addWidget(self.namesoundcheck) layout_doubleindent = QtGui.QVBoxLayout()
layout_doubleindent.addWidget(self.memopingcheck)
layout_doubleindent.addWidget(self.namesoundcheck)
layout_doubleindent.setContentsMargins(22,0,0,0)
layout_indent.addLayout(layout_doubleindent)
layout_indent.setContentsMargins(22,0,0,0) layout_indent.setContentsMargins(22,0,0,0)
layout_sound.addLayout(layout_indent) layout_sound.addLayout(layout_indent)
layout_sound.addSpacing(15) layout_sound.addSpacing(15)
@ -1211,10 +1221,19 @@ class PesterOptions(QtGui.QDialog):
if state == 0: if state == 0:
self.chatsoundcheck.setEnabled(False) self.chatsoundcheck.setEnabled(False)
self.memosoundcheck.setEnabled(False) self.memosoundcheck.setEnabled(False)
self.namesoundcheck.setEnabled(False) self.memoSoundChange(0)
else: else:
self.chatsoundcheck.setEnabled(True) self.chatsoundcheck.setEnabled(True)
self.memosoundcheck.setEnabled(True) self.memosoundcheck.setEnabled(True)
if self.memosoundcheck.isChecked():
self.memoSoundChange(1)
@QtCore.pyqtSlot(int)
def memoSoundChange(self, state):
if state == 0:
self.memopingcheck.setEnabled(False)
self.namesoundcheck.setEnabled(False)
else:
self.memopingcheck.setEnabled(True)
self.namesoundcheck.setEnabled(True) self.namesoundcheck.setEnabled(True)
@QtCore.pyqtSlot(int) @QtCore.pyqtSlot(int)
def printValue(self, v): def printValue(self, v):

View file

@ -513,6 +513,8 @@ class userConfig(object):
return self.config.get('chatSound', True) return self.config.get('chatSound', True)
def memoSound(self): def memoSound(self):
return self.config.get('memoSound', True) return self.config.get('memoSound', True)
def memoPing(self):
return self.config.get('pingSound', True)
def nameSound(self): def nameSound(self):
return self.config.get('nameSound', True) return self.config.get('nameSound', True)
def volume(self): def volume(self):
@ -1460,6 +1462,9 @@ class PesterWindow(MovingWindow):
self.serverOverride = options["server"] self.serverOverride = options["server"]
if "port" in options: if "port" in options:
self.portOverride = options["port"] self.portOverride = options["port"]
if "honk" in options:
self.honk = options["honk"]
else: self.honk = True
self.setAutoFillBackground(True) self.setAutoFillBackground(True)
self.setObjectName("main") self.setObjectName("main")
@ -1776,19 +1781,19 @@ class PesterWindow(MovingWindow):
msg = "<c=%s>%s</c>" % (systemColor.name(), msg) msg = "<c=%s>%s</c>" % (systemColor.name(), msg)
memo.addMessage(msg, handle) memo.addMessage(msg, handle)
if self.config.soundOn(): if self.config.soundOn():
if self.config.nameSound():
initials = self.userprofile.chat.initials()
search = r"\b[%s%s][%s%s]\b" % (initials[0].lower(), initials[0], initials[1].lower(), initials[1])
m = convertTags(msg, "text")
if m.find(":") <= 3:
m = m[m.find(":"):]
if re.search(search, m):
self.namesound.play()
return
if self.config.memoSound(): if self.config.memoSound():
if re.search(r"\bhonk\b", convertTags(msg, "text"), re.I): if self.config.nameSound():
initials = self.userprofile.chat.initials()
search = r"\b[%s%s][%s%s]\b" % (initials[0].lower(), initials[0], initials[1].lower(), initials[1])
m = convertTags(msg, "text")
if m.find(":") <= 3:
m = m[m.find(":"):]
if re.search(search, m):
self.namesound.play()
return
if self.honk and re.search(r"\bhonk\b", convertTags(msg, "text"), re.I):
self.honksound.play() self.honksound.play()
else: elif self.config.memoPing():
self.memosound.play() self.memosound.play()
def changeColor(self, handle, color): def changeColor(self, handle, color):
@ -2627,6 +2632,10 @@ class PesterWindow(MovingWindow):
curmemosound = self.config.memoSound() curmemosound = self.config.memoSound()
if memosoundsetting != curmemosound: if memosoundsetting != curmemosound:
self.config.set('memoSound', memosoundsetting) self.config.set('memoSound', memosoundsetting)
memopingsetting = self.optionmenu.memopingcheck.isChecked()
curmemoping = self.config.memoPing()
if memopingsetting != curmemoping:
self.config.set('pingSound', memopingsetting)
namesoundsetting = self.optionmenu.namesoundcheck.isChecked() namesoundsetting = self.optionmenu.namesoundcheck.isChecked()
curnamesound = self.config.nameSound() curnamesound = self.config.nameSound()
if namesoundsetting != curnamesound: if namesoundsetting != curnamesound:
@ -3263,7 +3272,7 @@ class MainProgram(QtCore.QObject):
def oppts(self, argv): def oppts(self, argv):
options = {} options = {}
try: try:
opts, args = getopt.getopt(argv, "s:p:", ["server=", "port=", "advanced"]) opts, args = getopt.getopt(argv, "s:p:", ["server=", "port=", "advanced", "no-honk"])
except getopt.GetoptError: except getopt.GetoptError:
return options return options
for opt, arg in opts: for opt, arg in opts:
@ -3273,6 +3282,8 @@ class MainProgram(QtCore.QObject):
options["port"] = arg options["port"] = arg
elif opt in ("--advanced"): elif opt in ("--advanced"):
options["advanced"] = True options["advanced"] = True
elif opt in ("--no-honk"):
options["honk"] = False
return options return options
def run(self): def run(self):