From c9d2ead2153b8e5bcd8ad5020b2b8df7666bbce5 Mon Sep 17 00:00:00 2001 From: Kermit Mei Date: Tue, 2 Nov 2010 14:20:05 +0800 Subject: [PATCH] add status information --- src/mainwindow.py | 36 ++++++++++++++++++++++++++++++++++-- src/mainwindow.ui | 6 +++++- src/mprocess.py | 6 +----- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/src/mainwindow.py b/src/mainwindow.py index b887376..679a0b7 100644 --- a/src/mainwindow.py +++ b/src/mainwindow.py @@ -2,11 +2,13 @@ from PyQt4.QtCore import SIGNAL,SLOT,Qt from PyQt4.QtCore import QPoint +from PyQt4.QtCore import QString from PyQt4.QtCore import QSettings from PyQt4.QtCore import QDir from PyQt4.QtCore import QCoreApplication from PyQt4.QtGui import QWidget +from PyQt4.QtGui import QLabel from PyQt4.QtGui import QMainWindow from PyQt4.QtGui import QSlider from PyQt4.QtGui import QFileDialog @@ -26,6 +28,9 @@ class MainWindow(QMainWindow,Ui_MainWindow): QSettings.NativeFormat,self) self.currDir = QDir(self.settings.value("LastPath").toString()) + self.statusLabel = QLabel() + self.statusBar.addWidget(self.statusLabel) + ##Set up the volume slide widget for setting volume self.volumeSlide = QSlider(self) self.volumeSlide.hide() @@ -43,6 +48,9 @@ class MainWindow(QMainWindow,Ui_MainWindow): self.pause) self.connect(self.stopBtn, SIGNAL("clicked()"), + self.stopped) + + self.connect(self.stopBtn, SIGNAL("clicked()"), self.mprocess.stop) self.connect(self.volumeBtn, SIGNAL("toggled(bool)"), @@ -57,8 +65,8 @@ class MainWindow(QMainWindow,Ui_MainWindow): self.connect(self.openBtn,SIGNAL("clicked()"), self.openFile) - self.connect(self.mprocess,SIGNAL("stopped()"), - self.stopped) + self.connect(self.mprocess,SIGNAL("updateStatus()"), + self.setStatusInfo) self.connect(self.aBtn, SIGNAL("toggled(bool)"),self.pointA) self.connect(self.bBtn, SIGNAL("toggled(bool)"),self.pointB) @@ -154,4 +162,28 @@ class MainWindow(QMainWindow,Ui_MainWindow): self.bBtn.setEnabled(False) #END def pointB(self): + def setStatusInfo(self): + colPre = '' + colBak = '' + black = ' ' * 8 + if(self.mprocess.timeLength != None): + message = str(int(self.mprocess.timePos)*100/int(self.mprocess.timeLength)) + message += "%" + else: + message = "0%" + message += black + if(self.mprocess.timePos != None): + message += 'pos=' + message += str(self.mprocess.timePos) + message += black + + if(self.mprocess.pa != None): + message += "A=" + str(self.mprocess.pa) + message += black + if(self.mprocess.pb != None): + message += "B=" + str(self.mprocess.pb) + message += black + self.statusLabel.setText(QString(colPre + message + colBak)) + #END def setStatusInfo(self, currProcess, pa, pb, status): + #END class MainWindow(QMainWindow,Ui_MainWindow) diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 8f73371..c94438b 100644 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -378,7 +378,11 @@ - + + + background-color: qlineargradient(spread:pad, x1:1, y1:0, x2:1, y2:0, stop:1 rgba(0, 0, 0, 255)); + + diff --git a/src/mprocess.py b/src/mprocess.py index 171aef8..eed23e3 100644 --- a/src/mprocess.py +++ b/src/mprocess.py @@ -78,7 +78,6 @@ class MProcess(QProcess): "-wid", str(self.wid), self.fileName]) if(self.state() != QProcess.NotRunning): - print "self.terminate()" self.terminate() if(not self.waitForFinished()): self.kill() @@ -152,7 +151,6 @@ class MProcess(QProcess): self.timeLength = float(re.search("\d+\.?\d",resStr).group(0)) if(self.slider != None): self.slider.setRange(0,int(self.timeLength)+1) - print self.timeLength elif(re.search("End of file",resStr)): self.closeTimer() self.playerState = MProcess.STOPPED @@ -170,7 +168,6 @@ class MProcess(QProcess): if(self.timePos > self.pb): self.timePos = self.pa - print "seek "+ str(self.pa) + " 0\n" self.write("seek "+ str(self.pa) + " 2\n") #END def analyseResult(self): @@ -183,7 +180,6 @@ class MProcess(QProcess): if(self.slider != None and self.timePos != None): self.slider.setValue(int(self.timePos)) - if(self.playerState == MProcess.PAUSED): self.closeTimer() return @@ -191,13 +187,13 @@ class MProcess(QProcess): if(self.state() == QProcess.NotRunning): self.closeTimer() self.playerState = MProcess.STOPPED - self.emit(SIGNAL("stopped()")) return self.write("get_time_pos\n") if(self.timeLength == None): self.write("get_time_length\n") + self.emit(SIGNAL("updateStatus()")) #END def timerEvent(self,event): #END class MProcess(QProcess): -- 2.11.4.GIT