void KMDBCreator::slotCancelled() { if (m_proc.isRunning()) m_proc.kill(); else emit dbCreated(); }
KMDriverDB::KMDriverDB(TQObject *parent, const char *name) : TQObject(parent,name) { m_creator = new KMDBCreator(this,"db-creator"); connect(m_creator,TQT_SIGNAL(dbCreated()),TQT_SLOT(slotDbCreated())); m_entries.setAutoDelete(true); m_pnpentries.setAutoDelete(true); }
bool KMDBCreator::createDriverDB(const QString& dirname, const QString& filename, QWidget *parent) { bool started(true); // initialize status m_status = false; m_firstflag = true; // start the child process m_proc.clearArguments(); QString exestr = KMFactory::self()->manager()->driverDbCreationProgram(); m_proc << exestr << dirname << filename; kdDebug() << "executing : " << exestr << " " << dirname << " " << filename << endl; QString msg; if (exestr.isEmpty()) msg = i18n("No executable defined for the creation of the " "driver database. This operation is not implemented."); else if (KStandardDirs::findExe(exestr).isEmpty()) msg = i18n("The executable %1 could not be found in your " "PATH. Check that this program exists and is " "accessible in your PATH variable.").arg(exestr); else if (!m_proc.start(KProcess::NotifyOnExit, KProcess::AllOutput)) msg = i18n("Unable to start the creation of the driver " "database. The execution of %1 failed.").arg(exestr); if (!msg.isEmpty()) { KMManager::self()->setErrorMsg(msg); started = false; } // Create the dialog if the process is running and if needed if (started) { if (!m_dlg) { m_dlg = new QProgressDialog(parent->topLevelWidget(),"progress-dialog",true); m_dlg->setLabelText(i18n("Please wait while KDE rebuilds a driver database.")); m_dlg->setCaption(i18n("Driver Database")); connect(m_dlg,SIGNAL(canceled()),SLOT(slotCancelled())); } m_dlg->setMinimumDuration(0); // always show the dialog m_dlg->setProgress(0); // to force showing } else // be sure to emit this signal otherwise the DB widget won't never be notified emit dbCreated(); return started; }
void KMDBCreator::slotProcessExited(KProcess*) { // delete the progress dialog if (m_dlg) { m_dlg->reset(); } // set exit status m_status = (m_proc.normalExit() && m_proc.exitStatus() == 0); if (!m_status) { KMFactory::self()->manager()->setErrorMsg(i18n("Error while creating driver database: abnormal child-process termination.")); // remove the incomplete driver DB file so that, it will be // reconstructed on next check QFile::remove(m_proc.args()[2]); } //else emit dbCreated(); }