void PlanExecutor::integrityCheckFinished(KJob *pJob) { endSleepInhibit(); discardIntegrityNotification(); mIntegrityNotification = new KNotification(QStringLiteral("IntegrityCheckCompleted"), KNotification::Persistent); mIntegrityNotification->setTitle(xi18nc("@title:window", "Integrity Check Completed")); mIntegrityNotification->setText(pJob->errorText()); QStringList lAnswers; if(pJob->error() == BackupJob::ErrorWithLog) { lAnswers << xi18nc("@action:button", "Show log file"); connect(mIntegrityNotification, SIGNAL(action1Activated()), SLOT(showLog())); } else if(pJob->error() == BackupJob::ErrorSuggestRepair) { lAnswers << xi18nc("@action:button", "Yes"); lAnswers << xi18nc("@action:button", "No"); connect(mIntegrityNotification, SIGNAL(action1Activated()), SLOT(startRepairJob())); } mIntegrityNotification->setActions(lAnswers); connect(mIntegrityNotification, SIGNAL(action2Activated()), SLOT(discardIntegrityNotification())); connect(mIntegrityNotification, SIGNAL(closed()), SLOT(discardIntegrityNotification())); connect(mIntegrityNotification, SIGNAL(ignored()), SLOT(discardIntegrityNotification())); mIntegrityNotification->sendEvent(); if(mState == INTEGRITY_TESTING) { //only restore if nothing has changed during the run mState = mLastState; } emit stateChanged(); }
void OpenCalaisTextMatchPlugin::doGetPossibleMatches( const QString& text ) { kDebug(); // cancel previous jobs delete m_lookupJob; m_lookupJob = 0; if ( OpenCalais::Config::licenseKey().isEmpty() ) { kDebug() << "no key"; if ( OpenCalais::Config::showKeyWarning() ) { KNotification* n = KNotification::event( KNotification::Warning, i18n( "No OpenCalais API key configured." ) ); n->setActions( QStringList() << i18n( "Configure..." ) ); connect( n, SIGNAL( action1Activated() ), this, SLOT( slotConfigure() ) ); OpenCalais::Config::self()->findItem( "ShowKeyWarning" )->setProperty( false ); OpenCalais::Config::self()->writeConfig(); } emitFinished(); } else { // do the lookup m_lookupJob = new OpenCalais::LookupJob( this ); connect( m_lookupJob, SIGNAL( result( KJob* ) ), this, SLOT( slotResult( KJob* ) ) ); m_lookupJob->setContent( text ); m_lookupJob->start(); } }
void EmoticonSetInstaller::showRequest() { kDebug(); KNotification *notification = new KNotification(QLatin1String("emoticonsRequest"), NULL, KNotification::Persistent); notification->setText( i18n("Install Emoticonset %1", this->bundleName()) ); notification->setActions( QStringList() << i18n("Install") << i18n("Cancel") ); QObject::connect(notification, SIGNAL(action1Activated()), this, SLOT(install())); QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close())); QObject::connect(notification, SIGNAL(ignored()), this, SLOT(ignoreRequest())); QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close())); QObject::connect(notification, SIGNAL(action2Activated()), this, SLOT(ignoreRequest())); QObject::connect(notification, SIGNAL(action2Activated()), notification, SLOT(close())); notification->sendEvent(); }
void PlanExecutor::notifyBackupFailed(KJob *pFailedJob) { discardFailNotification(); mFailNotification = new KNotification(QStringLiteral("BackupFailed"), KNotification::Persistent); mFailNotification->setTitle(xi18nc("@title:window", "Saving of Backup Failed")); mFailNotification->setText(pFailedJob->errorText()); QStringList lAnswers; if(pFailedJob->error() == BackupJob::ErrorWithLog) { lAnswers << xi18nc("@action:button", "Show log file"); connect(mFailNotification, SIGNAL(action1Activated()), SLOT(showLog())); } else if(pFailedJob->error() == BackupJob::ErrorSuggestRepair) { lAnswers << xi18nc("@action:button", "Yes"); lAnswers << xi18nc("@action:button", "No"); connect(mFailNotification, SIGNAL(action1Activated()), SLOT(startRepairJob())); } mFailNotification->setActions(lAnswers); connect(mFailNotification, SIGNAL(action2Activated()), SLOT(discardFailNotification())); connect(mFailNotification, SIGNAL(closed()), SLOT(discardFailNotification())); connect(mFailNotification, SIGNAL(ignored()), SLOT(discardFailNotification())); mFailNotification->sendEvent(); }
void notifier_t::notify_reboot() { KNotification* note = new KNotification("requestreboot",0L, KNotification::Persistent); note->setTitle(i18n("Please reboot your system.")); note->setText(i18n("In order to complete this upgrade, you need to reboot your system.")); note->setPixmap(KIcon("system-reboot").pixmap(QSize(32,32))); note->setComponentData(m_component_data); note->setActions(QStringList() << i18nc("Do the proposed action (upgrade, reboot, etc) later", "Later") << i18nc("Reboot the system", "Reboot")); connect(note,SIGNAL(closed()),m_reboot_nagger,SLOT(start())); connect(note,SIGNAL(action1Activated()),m_reboot_nagger,SLOT(start())); connect(note,SIGNAL(action2Activated()),SLOT(reboot())); note->sendEvent(); }
void EmoticonSetInstaller::showResult() { kDebug(); KNotification *notification = new KNotification(QLatin1String("emoticonsSuccess"), NULL, KNotification::Persistent); notification->setText( i18n("Installed Emoticonset %1 successfully.", this->bundleName()) ); notification->setActions( QStringList() << i18n("OK") ); QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close())); QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close())); notification->sendEvent(); Q_EMIT showedResult(); }
void PlanExecutor::askUser(const QString &pQuestion) { mQuestion = new KNotification(QLatin1String("StartBackup"), KNotification::Persistent); mQuestion->setTitle(i18nc("@title:window", "Backup Device Available - %1", mPlan->mDescription)); mQuestion->setText(pQuestion); QStringList lAnswers; lAnswers << i18nc("@action:button", "Yes") << i18nc("@action:button", "No"); mQuestion->setActions(lAnswers); connect(mQuestion, SIGNAL(action1Activated()), SLOT(enterBackupRunningState())); connect(mQuestion, SIGNAL(action2Activated()), SLOT(discardUserQuestion())); connect(mQuestion, SIGNAL(closed()), SLOT(discardUserQuestion())); connect(mQuestion, SIGNAL(ignored()), SLOT(discardUserQuestion())); // enter this "do nothing" state, if user answers "no" or ignores, remain there mState = WAITING_FOR_MANUAL_BACKUP; emit stateChanged(); mQuestion->sendEvent(); }
void PlanExecutor::askUser(const QString &pQuestion) { discardUserQuestion(); mQuestion = new KNotification(QStringLiteral("StartBackup"), KNotification::Persistent); mQuestion->setTitle(mPlan->mDescription); mQuestion->setText(pQuestion); QStringList lAnswers; lAnswers << xi18nc("@action:button", "Yes") << xi18nc("@action:button", "No"); mQuestion->setActions(lAnswers); connect(mQuestion, SIGNAL(action1Activated()), SLOT(startBackupSaveJob())); connect(mQuestion, SIGNAL(action2Activated()), SLOT(discardUserQuestion())); connect(mQuestion, SIGNAL(closed()), SLOT(discardUserQuestion())); connect(mQuestion, SIGNAL(ignored()), SLOT(discardUserQuestion())); // enter this "do nothing" state, if user answers "no" or ignores, remain there mState = WAITING_FOR_MANUAL_BACKUP; emit stateChanged(); mQuestion->sendEvent(); }
void PlanExecutor::repairFinished(KJob *pJob) { endSleepInhibit(); discardRepairNotification(); mRepairNotification = new KNotification(QStringLiteral("RepairCompleted"), KNotification::Persistent); mRepairNotification->setTitle(xi18nc("@title:window", "Repair Completed")); mRepairNotification->setText(pJob->errorText()); QStringList lAnswers; lAnswers << xi18nc("@action:button", "Show log file"); mRepairNotification->setActions(lAnswers); connect(mRepairNotification, SIGNAL(action1Activated()), SLOT(showLog())); connect(mRepairNotification, SIGNAL(closed()), SLOT(discardRepairNotification())); connect(mRepairNotification, SIGNAL(ignored()), SLOT(discardRepairNotification())); mRepairNotification->sendEvent(); if(mState == REPAIRING) { //only restore if nothing has changed during the run mState = mLastState; } emit stateChanged(); }
void KNotification::activate(unsigned int action) { switch (action) { case 0: emit activated(); break; case 1: emit action1Activated(); break; case 2: emit action2Activated(); break; case 3: emit action3Activated(); break; } emit activated(action); if(d->id != -1) deleteLater(); d->id = -2; }
void KNotification::activate(unsigned int action) { switch (action) { case 0: emit activated(); break; case 1: emit action1Activated(); break; case 2: emit action2Activated(); break; case 3: emit action3Activated(); break; } // emitting activated() makes the Manager close all the active plugins // which will deref() the KNotification object, which will result // in closing the notification emit activated(action); }
void AdiumxtraProtocolHandler::install() { if (m_url.isEmpty()) { Q_EMIT finished(); return; // BundleInstaller:: xxxxx } QUrl url = QUrl::fromUserInput(m_url); if(url.scheme() == QLatin1String("adiumxtra")) { url.setScheme(QStringLiteral("http")); } QTemporaryFile *tmpFile = new QTemporaryFile(); if (tmpFile->open()) { KIO::Job* getJob = KIO::file_copy(url, QUrl::fromLocalFile(tmpFile->fileName()), -1, KIO::Overwrite | KIO::HideProgressInfo); if (getJob->exec()) { qWarning() << "Download failed"; Q_EMIT finished(); return; // BundleInstaller::BundleCannotOpen; } getJob->deleteLater(); } KArchive *archive = 0L; QMimeDatabase db; QString currentBundleMimeType = db.mimeTypeForFile(tmpFile->fileName()).name(); if (currentBundleMimeType == QLatin1String("application/zip")) { archive = new KZip(tmpFile->fileName()); } else if (currentBundleMimeType == QLatin1String("application/x-compressed-tar") || currentBundleMimeType == QLatin1String("application/x-bzip-compressed-tar") || currentBundleMimeType == QLatin1String("application/x-gzip") || currentBundleMimeType == QLatin1String("application/x-bzip")) { archive = new KTar(tmpFile->fileName()); } else { KNotification *notification = new KNotification(QLatin1String("packagenotrecognized"), NULL, KNotification::Persistent); notification->setText( i18n("Package type not recognized or not supported") ); notification->setActions( QStringList() << i18n("OK") ); QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close())); QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close())); notification->setComponentName(ktelepathyComponentName()); notification->sendEvent(); qWarning() << "Unsupported file type" << currentBundleMimeType; Q_EMIT finished(); return;// BundleInstaller::BundleNotValid; } if (!archive->open(QIODevice::ReadOnly)) { delete archive; qWarning() << "Cannot open theme file"; Q_EMIT finished(); return;// BundleInstaller::BundleCannotOpen; } ChatStyleInstaller *chatStyleInstaller = new ChatStyleInstaller(archive, tmpFile); if (chatStyleInstaller->validate() == BundleInstaller::BundleValid) { chatStyleInstaller->showRequest(); QObject::connect(chatStyleInstaller, SIGNAL(finished(BundleInstaller::BundleStatus)), chatStyleInstaller, SLOT(showResult())); QObject::connect(chatStyleInstaller, SIGNAL(showedResult()), this, SIGNAL(finished())); QObject::connect(chatStyleInstaller, SIGNAL(showedResult()), chatStyleInstaller, SLOT(deleteLater())); QObject::connect(chatStyleInstaller, SIGNAL(ignoredRequest()), this, SIGNAL(finished())); QObject::connect(chatStyleInstaller, SIGNAL(ignoredRequest()), chatStyleInstaller, SLOT(deleteLater())); return;// BundleInstaller::BundleValid; } delete chatStyleInstaller; EmoticonSetInstaller *emoticonSetInstaller = new EmoticonSetInstaller(archive, tmpFile); if(emoticonSetInstaller->validate() == BundleInstaller::BundleValid) { emoticonSetInstaller->showRequest(); QObject::connect(emoticonSetInstaller, SIGNAL(finished(BundleInstaller::BundleStatus)), emoticonSetInstaller, SLOT(showResult())); QObject::connect(emoticonSetInstaller, SIGNAL(showedResult()), this, SIGNAL(finished())); QObject::connect(emoticonSetInstaller, SIGNAL(showedResult()), emoticonSetInstaller, SLOT(deleteLater())); QObject::connect(emoticonSetInstaller, SIGNAL(ignoredRequest()), this, SIGNAL(finished())); QObject::connect(emoticonSetInstaller, SIGNAL(ignoredRequest()), emoticonSetInstaller, SLOT(deleteLater())); return;// BundleInstaller::BundleValid; } delete emoticonSetInstaller; KNotification *notification = new KNotification(QLatin1String("packagenotrecognized"), NULL, KNotification::Persistent); notification->setText( i18n("Package type not recognized or not supported") ); QObject::connect(notification, SIGNAL(action1Activated()), notification, SLOT(close())); QObject::connect(notification, SIGNAL(ignored()), notification, SLOT(close())); notification->setActions( QStringList() << i18n("OK") ); notification->setComponentName(ktelepathyComponentName()); notification->sendEvent(); Q_EMIT finished(); return;// BundleInstaller::BundleUnknownError; }