From b3d9058d96f5f2939360fde1b6c28062f4db827b Mon Sep 17 00:00:00 2001 From: ormorph Date: Tue, 5 Dec 2023 21:14:11 +0900 Subject: Added event processing if the process has finished its work Signed-off-by: ormorph (cherry picked from commit 7bd4251db36952dce6c17d477f4671199d5c9971) --- src/kstreamripper.cpp | 11 +++++++++++ src/kstreamripper.h | 4 ++++ src/processcontroller.cpp | 8 ++++++++ src/processcontroller.h | 4 ++++ 4 files changed, 27 insertions(+) diff --git a/src/kstreamripper.cpp b/src/kstreamripper.cpp index a4fef54..7a5d7cb 100644 --- a/src/kstreamripper.cpp +++ b/src/kstreamripper.cpp @@ -227,12 +227,23 @@ void KStreamRipper::ripButtonClicked() ProcItem->getProcessController()->startRip(m_destEdit->text(), m_timeEdit->text()); m_ripButton->setEnabled( false ); m_stopRipButton->setEnabled( true ); + connect(ProcItem->getProcessController(), TQT_SIGNAL(stopRipSignal(ProcessController*)), this, TQT_SLOT(ripStopped(ProcessController*))); } else { KMessageBox::error(this, "The streamripper executable wasn't found. Make sure " "it's in your path.", "streamripper not found"); } } +void KStreamRipper::ripStopped(ProcessController *curProc) +{ + const ProcessController *proc = ((ProcessListViewItem*)m_streamsListView->currentItem())->getProcessController(); + if (curProc == proc) + { + m_ripButton->setEnabled( true ); + m_stopRipButton->setEnabled( false ); + } +} + void KStreamRipper::stopRipButtonClicked() { ProcessListViewItem * ProcItem = (ProcessListViewItem*)m_streamsListView->currentItem(); diff --git a/src/kstreamripper.h b/src/kstreamripper.h index 5a16a99..7677e6f 100644 --- a/src/kstreamripper.h +++ b/src/kstreamripper.h @@ -22,7 +22,10 @@ #define KSTREAMRIPPER_H #include + #include "kstreamripperbase.h" +#include "processcontroller.h" + #if KDE_IS_VERSION(3,3,90) #include #include @@ -57,6 +60,7 @@ protected slots: void deleteStreamButtonClicked(); void tuneInButtonClicked(); void ripButtonClicked(); + void ripStopped(ProcessController*); void stopRipButtonClicked(); void browseButtonClicked(); void helpButtonClicked(); diff --git a/src/processcontroller.cpp b/src/processcontroller.cpp index f39a4c6..35558b2 100644 --- a/src/processcontroller.cpp +++ b/src/processcontroller.cpp @@ -26,6 +26,7 @@ ProcessController::ProcessController(ProcessListViewItem * parent) : TQObject((TQObject *)parent), myParent(parent), myStatus(false), myAutomatic(false), myProcess(new TQProcess(this)) { connect (myProcess, TQT_SIGNAL( readyReadStdout() ), (ProcessController *) this, TQT_SLOT( readStdout()) ); + connect (myProcess, TQT_SIGNAL(processExited() ), (ProcessController *) this, TQT_SLOT( processExited()) ); // connect (myProcess, TQT_SIGNAL( destroyed() ), myProcess, TQT_SLOT( kill()) ); // this should work, according to http://doc.trolltech.com/3.2/qobject.html#~TQObject but it doesn't } @@ -68,6 +69,13 @@ void ProcessController::readStdout() } } +void ProcessController::processExited() +{ + myStatus = false; + myParent->setText( 1, "" ); + myParent->setText( 2, "" ); + emit stopRipSignal(this); +} void ProcessController::startRip(TQString destination, TQString time) { diff --git a/src/processcontroller.h b/src/processcontroller.h index 88deff7..9405471 100644 --- a/src/processcontroller.h +++ b/src/processcontroller.h @@ -54,8 +54,12 @@ public: void startRip(TQString destination, TQString time); void stopRip(); +signals: + void stopRipSignal(ProcessController*); + protected slots: void readStdout(); + void processExited(); private: ProcessListViewItem * myParent; -- cgit v1.2.1