Diffstat (limited to 'noncore/settings/packagemanager/installdlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 72 |
1 files changed, 31 insertions, 41 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 980d5eb..6a9ccbd 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -207,6 +207,5 @@ void InstallDlg::slotBtnStart() | |||
207 | if ( btnText == tr( "Abort" ) ) | 207 | if ( btnText == tr( "Abort" ) ) |
208 | { | 208 | { |
209 | // Stop execution of current command and prevent any others from executing | 209 | // Prevent unexecuted commands from executing |
210 | m_packman->abortCommand(); | ||
211 | m_currCommand = 999; | 210 | m_currCommand = 999; |
212 | 211 | ||
@@ -223,15 +222,35 @@ void InstallDlg::slotBtnStart() | |||
223 | } | 222 | } |
224 | 223 | ||
225 | // Start was clicked, execute first command | 224 | // Start was clicked, start executing |
226 | m_btnOptions->setEnabled( false ); | 225 | m_btnOptions->setEnabled( false ); |
226 | if ( m_numCommands > 1 ) | ||
227 | { | ||
227 | m_btnStart->setText( tr( "Abort" ) ); | 228 | m_btnStart->setText( tr( "Abort" ) ); |
228 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); | 229 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); |
230 | } | ||
231 | else | ||
232 | { | ||
233 | m_btnStart->setEnabled( false ); | ||
234 | } | ||
229 | 235 | ||
230 | QString dest; | 236 | QString dest; |
231 | if ( m_destination ) | 237 | if ( m_destination ) |
232 | dest = m_destination->currentText(); | 238 | dest = m_destination->currentText(); |
233 | m_packman->executeCommand( m_command[ 0 ], m_packages[ 0 ], dest, this, | 239 | |
234 | SLOT(slotOutput(OProcess*,char*,int)), SLOT(slotErrors(OProcess*,char*,int)), | 240 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
235 | SLOT(slotFinished(OProcess*)), true ); | 241 | { |
242 | // Execute next command | ||
243 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | ||
244 | this, SLOT(slotOutput(char*)), true ); | ||
245 | } | ||
246 | |||
247 | // All commands executed, allow user to close dialog | ||
248 | m_btnStart->setEnabled( true ); | ||
249 | m_btnStart->setText( tr( "Close" ) ); | ||
250 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | ||
251 | |||
252 | m_btnOptions->setEnabled( true ); | ||
253 | m_btnOptions->setText( tr( "Save output" ) ); | ||
254 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | ||
236 | } | 255 | } |
237 | 256 | ||
@@ -268,42 +287,13 @@ void InstallDlg::slotBtnOptions() | |||
268 | } | 287 | } |
269 | 288 | ||
270 | void InstallDlg::slotOutput( OProcess */*process*/, char *buffer, int buffLen ) | 289 | void InstallDlg::slotOutput( char *msg ) |
271 | { | 290 | { |
272 | QString lineStr = buffer; | 291 | // Allow processing of other events |
273 | if ( lineStr[buffLen-1] == '\n' ) | 292 | qApp->processEvents(); |
274 | lineStr.truncate( buffLen - 1 ); | ||
275 | m_output->append( lineStr ); | ||
276 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
277 | } | ||
278 | 293 | ||
279 | void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen ) | 294 | QString lineStr = msg; |
280 | { | 295 | if ( lineStr[lineStr.length()-1] == '\n' ) |
281 | QString lineStr = buffer; | 296 | lineStr.truncate( lineStr.length() - 1 ); |
282 | if ( lineStr[buffLen-1] == '\n' ) | ||
283 | lineStr.truncate( buffLen - 1 ); | ||
284 | m_output->append( lineStr ); | 297 | m_output->append( lineStr ); |
285 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 298 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
286 | } | 299 | } |
287 | |||
288 | void InstallDlg::slotFinished( OProcess */*process*/ ) | ||
289 | { | ||
290 | ++m_currCommand; | ||
291 | if ( m_currCommand < m_numCommands ) | ||
292 | { | ||
293 | // More commands left, execute next one | ||
294 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], m_destination->currentText(), | ||
295 | this, SLOT(slotOutput(OProcess*,char*,int)), | ||
296 | SLOT(slotErrors(OProcess*,char*,int)), | ||
297 | SLOT(slotFinished(OProcess*)), true ); | ||
298 | } | ||
299 | else | ||
300 | { | ||
301 | // All commands executed, allow user to close dialog | ||
302 | m_btnStart->setText( tr( "Close" ) ); | ||
303 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | ||
304 | |||
305 | m_btnOptions->setEnabled( true ); | ||
306 | m_btnOptions->setText( tr( "Save output" ) ); | ||
307 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | ||
308 | } | ||
309 | } | ||