void NotifyWidget::display(const Notification ¬ification) { qCDebug(SNORE) << m_id << notification.id() << m_window->isVisible(); m_notification = notification; QColor color; QVariant vcolor = notification.application().constHints().privateValue(parent(), "backgroundColor"); if (vcolor.isValid()) { color = vcolor.value<QColor>(); } else { color = computeBackgrondColor(notification.application().icon().pixmap(QSize(20, 20)).toImage()); notification.application().hints().setPrivateValue(parent(), "backgroundColor", color); } m_appIcon = QUrl::fromLocalFile(notification.application().icon().localUrl(QSize(m_appIconSize, m_appIconSize))); emit appIconChanged(); m_image = QUrl::fromLocalFile(notification.icon().localUrl(QSize(m_imageSize, m_imageSize))); emit imageChanged(); m_title = notification.title(Utils::AllMarkup); emit titleChanged(); m_body = notification.text(Utils::AllMarkup); emit bodyChanged(); if (!notification.isUpdate()) { syncSettings(); m_color = color; m_textColor = compueTextColor(color); emit colorChanged(); emit textColorChanged(); m_window->show(); Utils::raiseWindowToFront(m_window); } }
void SnoreToast::slotNotify(Notification notification) { QProcess *p = new QProcess(this); p->setReadChannelMode(QProcess::MergedChannels); connect(p,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(slotToastNotificationClosed(int,QProcess::ExitStatus))); connect(qApp,SIGNAL(aboutToQuit()),p,SLOT(kill())); QStringList arguements; arguements << "-t" << Snore::toPlainText(notification.title()) << "-m" << Snore::toPlainText(notification.text()); if(notification.icon().isValid()) { arguements << "-p" << QDir::toNativeSeparators(notification.icon().localUrl()); } arguements << "-w" << "-appID" << appId(notification.application()) << "-id" << QString::number(notification.id()); if(notification.hints().value("silent",true).toBool()) { arguements << "-silent"; } snoreDebug( SNORE_DEBUG ) << "SnoreToast" << arguements; p->start("SnoreToast", arguements); p->setProperty("SNORE_NOTIFICATION_ID",notification.id()); }
void GrowlBackend::slotNotify(Notification notification) { Growl *growl = m_applications.value(notification.application().name()); QString alert = notification.alert().name(); snoreDebug(SNORE_DEBUG) << "Notify Growl:" << notification.application() << alert << notification.title(); GrowlNotificationData data(alert.toUtf8().constData(), notification.id(), notification.title().toUtf8().constData(), notification.text().toUtf8().constData()); if (notification.icon().isValid()) { data.setIcon(notification.icon().localUrl().toUtf8().constData()); } data.setCallbackData("1"); growl->Notify(data); slotNotificationDisplayed(notification); }
void NotifyWidget::update(const Notification ¬ification) { snoreDebug( SNORE_DEBUG ) << m_id << notification.id(); m_notification = notification; QRect desktop = QDesktopWidget().availableGeometry(); resize(computeSize()); int space = 10 * logicalDpiY() / dpisScale(); m_dest = QPoint(desktop.topRight().x() - width(), desktop.topRight().y() + space + (space + height()) * m_id); m_start = QPoint(desktop.topRight().x(), m_dest.y()); QColor color; QVariant vcolor = notification.application().constHints().privateValue(parent(), "backgroundColor"); if(vcolor.isValid()) { color = vcolor.value<QColor>(); } else { color = computeBackgrondColor(notification.application().icon().image().scaled(20,20)); notification.application().constHints().setPrivateValue(parent(), "backgroundColor", color); } QRgb gray = qGray(qGray(color.rgb()) - qGray(QColor(Qt::white).rgb())); QColor textColor = QColor(gray, gray, gray); QMetaObject::invokeMethod(qmlNotification, "update", Qt::QueuedConnection, Q_ARG( QVariant, notification.title()), Q_ARG( QVariant, notification.text()), Q_ARG( QVariant, QUrl::fromLocalFile(notification.icon().localUrl())), Q_ARG( QVariant, QUrl::fromLocalFile(notification.application().icon().localUrl())), Q_ARG( QVariant, color), Q_ARG( QVariant, textColor)); }