Example #1
0
void WicdApplet::notify(const QString &event, const QString &message) const
{
    if (m_status.State != 10) { //don't notify on startup
        KNotification *notify = new KNotification(event);
        notify->setText(message);
        notify->setComponentData(KComponentData("wicd-kde"));
        notify->sendEvent();
    }
}
Example #2
0
void ActivityList::dataUpdated(const QString& source, const Plasma::DataEngine::Data& data)
{
    Q_UNUSED(source)
    Q_ASSERT(m_engine);
    
    int newItems = 0;

    foreach(const QString& key, data.keys()) {
        if (!data.value(key).value<Plasma::DataEngine::Data>().isEmpty()) {
            
            if (m_knownEvents.contains(source + data[key].value<Plasma::DataEngine::Data>().value("id").toString())) {
                continue;
            }
            
            QString id(source + data[key].value<Plasma::DataEngine::Data>().value("id").toString());
            QDateTime time(data[key].value<Plasma::DataEngine::Data>().value("timestamp").toDateTime());
            m_knownEvents.insert(id);

            ActivityWidget* widget = new ActivityWidget(m_engine, m_container);
            widget->setActivityData(data[key].value<Plasma::DataEngine::Data>());

            int i;
            for(i = 0; i < m_layout->count(); ++i) {
                ActivityWidget* widget = static_cast<ActivityWidget*>(m_layout->itemAt(i));
                if (time > widget->timestamp()) {
                    break;
                }
            }
            m_layout->insertItem(i, widget);
            
            ++newItems;
        }
    }
    
    while (m_layout->count() > m_limit) {
        ActivityWidget* widget = static_cast<ActivityWidget*>(m_layout->itemAt(m_layout->count()-1));
        m_layout->removeAt(m_layout->count()-1);
        widget->deleteLater();
    }
    
    // Don't mass-spam the user with notifications
    if (newItems < 4) {
        for(int i = 0; i<newItems; ++i) {
            ActivityWidget* widget = static_cast<ActivityWidget*>(m_layout->itemAt(i));
            KNotification* notification = new KNotification("activity");
            notification->setTitle("OpenDesktop Activities");
            notification->setText(widget->message());
            notification->setComponentData(KComponentData("plasma-applet-opendesktop-activities", "plasma-applet-opendesktop-activities", KComponentData::SkipMainComponentRegistration));
            notification->sendEvent();
        }
    }

    // Go to the top of the list
    setScrollPosition(QPointF(0, 0));
}
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 notifier_t::show_update_notification(const QString& title, const QString& message, const QString& iconname) {
  if(m_upgrade_notification) {
    m_upgrade_notification.data()->close();
  }
  KNotification* note = new KNotification("updatesavailable",0L, KNotification::Persistent);
  note->setTitle(title);
  note->setText(message);
  note->setPixmap(KIcon(iconname).pixmap(QSize(32,32)));
  note->setComponentData(m_component_data);
  note->setActions(QStringList()
    << i18nc("Do the proposed action (upgrade, reboot, etc) later", "Later"));
  note->sendEvent();
  m_upgrade_notification=note;
  return;
}