From 7a32912c75d52e7d3d59a5ba94d1046cc9acf761 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Gl=C3=BCpker?= Date: Mon, 4 Jun 2018 19:01:51 +0200 Subject: Play annoying warning, when time is running short --- 9kwpyqt.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/9kwpyqt.py b/9kwpyqt.py index 7e25142..618a211 100755 --- a/9kwpyqt.py +++ b/9kwpyqt.py @@ -44,6 +44,7 @@ class CaptchaGUI(QWidget): config = None # Configuration (9kwpyqt.ini) sound = False # QSound() timer = False # QTimer() for 30sec timing + soundUrgent = False # QSound() for urgent message (low time) running = False startCredits = None @@ -55,6 +56,7 @@ class CaptchaGUI(QWidget): currentWorker = 0 offlinemessage = "Click \"Start\" to fetch next captcha." timeleft = None + urgentSoundPlayed = False waitingoncaptcha = 0 @@ -348,6 +350,7 @@ class CaptchaGUI(QWidget): # Use config settings self.apiurl = self.config['DEFAULT']['API_URL']+"?source=pythonapi&apikey="+self.config['DEFAULT']['API_KEY']+"&" self.sound = QSound(os.path.join(THIS_DIR, self.config['DEFAULT']['Soundfile'])) + self.soundUrgent = QSound(os.path.join(THIS_DIR, self.config['DEFAULT']['SoundfileUrgent'])) self.soundCheckbox.setChecked( self.config.getboolean('DEFAULT', 'Sound') ) if self.config.getboolean('DEFAULT', 'Autostart'): self.toggleRunning(force_start=True) @@ -373,10 +376,14 @@ class CaptchaGUI(QWidget): def onTimerTick(self): if not self.timeleft: self.captchaTimer.setText("...") + self.urgentSoundPlayed = False self.timer.stop() else: timing = self.timeleft - time.time() self.captchaTimer.setText(str(round(timing, 1))+"s") + if self.soundCheckbox.isChecked() and not self.urgentSoundPlayed and timing <= 10: + self.urgentSoundPlayed = True + self.soundUrgent.play() if timing <= 0: self.toggleRunning(force_stop=True) self.offlinemessage = "30 seconds passed without input." -- cgit v1.2.3