From f9f552fc3fc5dfeb680a6546098cc190db829c20 Mon Sep 17 00:00:00 2001 From: Kiooeht Date: Fri, 8 Jul 2011 01:41:49 -0700 Subject: [PATCH] Sound options rearrange + add --- menus.py | 25 ++++++++++++++++++++++--- pesterchum.py | 35 +++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/menus.py b/menus.py index b8d68ea..9a3586a 100644 --- a/menus.py +++ b/menus.py @@ -941,14 +941,20 @@ class PesterOptions(QtGui.QDialog): self.chatsoundcheck.setChecked(self.config.chatSound()) self.memosoundcheck = QtGui.QCheckBox("Memo Sounds", self) 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.setChecked(self.config.nameSound()) if self.config.soundOn(): self.soundcheck.setChecked(True) + if not self.memosoundcheck.isChecked(): + self.memoSoundChange(0) else: self.chatsoundcheck.setEnabled(False) self.memosoundcheck.setEnabled(False) - self.namesoundcheck.setEnabled(False) + self.memoSoundChange(0) self.volume = QtGui.QSlider(QtCore.Qt.Horizontal, self) self.volume.setMinimum(0) self.volume.setMaximum(100) @@ -1144,7 +1150,11 @@ class PesterOptions(QtGui.QDialog): layout_indent = QtGui.QVBoxLayout() layout_indent.addWidget(self.chatsoundcheck) 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_sound.addLayout(layout_indent) layout_sound.addSpacing(15) @@ -1211,10 +1221,19 @@ class PesterOptions(QtGui.QDialog): if state == 0: self.chatsoundcheck.setEnabled(False) self.memosoundcheck.setEnabled(False) - self.namesoundcheck.setEnabled(False) + self.memoSoundChange(0) else: self.chatsoundcheck.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) @QtCore.pyqtSlot(int) def printValue(self, v): diff --git a/pesterchum.py b/pesterchum.py index 4c8c64d..abfa329 100644 --- a/pesterchum.py +++ b/pesterchum.py @@ -513,6 +513,8 @@ class userConfig(object): return self.config.get('chatSound', True) def memoSound(self): return self.config.get('memoSound', True) + def memoPing(self): + return self.config.get('pingSound', True) def nameSound(self): return self.config.get('nameSound', True) def volume(self): @@ -1460,6 +1462,9 @@ class PesterWindow(MovingWindow): self.serverOverride = options["server"] if "port" in options: self.portOverride = options["port"] + if "honk" in options: + self.honk = options["honk"] + else: self.honk = True self.setAutoFillBackground(True) self.setObjectName("main") @@ -1776,19 +1781,19 @@ class PesterWindow(MovingWindow): msg = "%s" % (systemColor.name(), msg) memo.addMessage(msg, handle) 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 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() - else: + elif self.config.memoPing(): self.memosound.play() def changeColor(self, handle, color): @@ -2627,6 +2632,10 @@ class PesterWindow(MovingWindow): curmemosound = self.config.memoSound() if memosoundsetting != curmemosound: 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() curnamesound = self.config.nameSound() if namesoundsetting != curnamesound: @@ -3263,7 +3272,7 @@ class MainProgram(QtCore.QObject): def oppts(self, argv): options = {} 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: return options for opt, arg in opts: @@ -3273,6 +3282,8 @@ class MainProgram(QtCore.QObject): options["port"] = arg elif opt in ("--advanced"): options["advanced"] = True + elif opt in ("--no-honk"): + options["honk"] = False return options def run(self):