Changeset View
Changeset View
Standalone View
Standalone View
src/notifybypopup.cpp
Show First 20 Lines • Show All 197 Lines • ▼ Show 20 Line(s) | 188 | if (!d->dbusServiceExists) { | |||
---|---|---|---|---|---|
198 | } | 198 | } | ||
199 | } | 199 | } | ||
200 | #endif | 200 | #endif | ||
201 | } | 201 | } | ||
202 | 202 | | |||
203 | 203 | | |||
204 | NotifyByPopup::~NotifyByPopup() | 204 | NotifyByPopup::~NotifyByPopup() | ||
205 | { | 205 | { | ||
206 | Q_FOREACH (KPassivePopup *p, d->passivePopups) { | 206 | for (KPassivePopup *p : qAsConst(d->passivePopups)) { | ||
207 | p->deleteLater(); | 207 | p->deleteLater(); | ||
208 | } | 208 | } | ||
209 | 209 | | |||
210 | delete d; | 210 | delete d; | ||
211 | } | 211 | } | ||
212 | 212 | | |||
213 | void NotifyByPopup::notify(KNotification *notification, KNotifyConfig *notifyConfig) | 213 | void NotifyByPopup::notify(KNotification *notification, KNotifyConfig *notifyConfig) | ||
214 | { | 214 | { | ||
▲ Show 20 Lines • Show All 113 Lines • ▼ Show 20 Line(s) | 327 | if (event->timerId() != d->animationTimer) { | |||
328 | KNotificationPlugin::timerEvent(event); | 328 | KNotificationPlugin::timerEvent(event); | ||
329 | return; | 329 | return; | ||
330 | } | 330 | } | ||
331 | 331 | | |||
332 | bool cont = false; | 332 | bool cont = false; | ||
333 | QRect screen = QGuiApplication::primaryScreen()->availableGeometry(); | 333 | QRect screen = QGuiApplication::primaryScreen()->availableGeometry(); | ||
334 | d->nextPosition = screen.top(); | 334 | d->nextPosition = screen.top(); | ||
335 | 335 | | |||
336 | Q_FOREACH (KPassivePopup *popup, d->passivePopups) | 336 | for (KPassivePopup *popup : qAsConst(d->passivePopups)) | ||
337 | { | 337 | { | ||
338 | int y = popup->pos().y(); | 338 | int y = popup->pos().y(); | ||
339 | if (y > d->nextPosition) { | 339 | if (y > d->nextPosition) { | ||
340 | y = qMax(y - 5, d->nextPosition); | 340 | y = qMax(y - 5, d->nextPosition); | ||
341 | d->nextPosition = y + popup->height(); | 341 | d->nextPosition = y + popup->height(); | ||
342 | cont = cont || y != d->nextPosition; | 342 | cont = cont || y != d->nextPosition; | ||
343 | popup->move(popup->pos().x(), y); | 343 | popup->move(popup->pos().x(), y); | ||
344 | } else { | 344 | } else { | ||
▲ Show 20 Lines • Show All 69 Lines • ▼ Show 20 Line(s) | |||||
414 | void NotifyByPopup::onServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) | 414 | void NotifyByPopup::onServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) | ||
415 | { | 415 | { | ||
416 | Q_UNUSED(serviceName); | 416 | Q_UNUSED(serviceName); | ||
417 | // close all notifications we currently hold reference to | 417 | // close all notifications we currently hold reference to | ||
418 | for (KNotification *n : qAsConst(d->galagoNotifications)) { | 418 | for (KNotification *n : qAsConst(d->galagoNotifications)) { | ||
419 | if (n) { | 419 | if (n) { | ||
420 | emit finished(n); | 420 | emit finished(n); | ||
421 | } | 421 | } | ||
422 | } | 422 | } | ||
423 | Q_FOREACH (KNotification *n, d->passivePopups.keys()) { | 423 | QMap<KNotification*, KPassivePopup *>::const_iterator i = d->passivePopups.constBegin(); | ||
dfaure: same | |||||
424 | emit finished(n); | 424 | while (i != d->passivePopups.constEnd()) { | ||
pino: this loop now will run forever... | |||||
425 | emit finished(i.key()); | ||||
426 | ++i; | ||||
dfaure: This is why a for() loop is better than a while loop() for such usage. | |||||
425 | } | 427 | } | ||
426 | d->galagoNotifications.clear(); | 428 | d->galagoNotifications.clear(); | ||
427 | d->passivePopups.clear(); | 429 | d->passivePopups.clear(); | ||
428 | 430 | | |||
429 | d->dbusServiceCapCacheDirty = true; | 431 | d->dbusServiceCapCacheDirty = true; | ||
430 | d->popupServerCapabilities.clear(); | 432 | d->popupServerCapabilities.clear(); | ||
431 | 433 | | |||
432 | if (newOwner.isEmpty()) { | 434 | if (newOwner.isEmpty()) { | ||
▲ Show 20 Lines • Show All 157 Lines • ▼ Show 20 Line(s) | 567 | if (!notification->pixmap().isNull()) { | |||
590 | 592 | | |||
591 | vb->layout()->addItem(hbox); | 593 | vb->layout()->addItem(hbox); | ||
592 | } | 594 | } | ||
593 | 595 | | |||
594 | 596 | | |||
595 | if (!notification->actions().isEmpty()) { | 597 | if (!notification->actions().isEmpty()) { | ||
596 | QString linkCode = QStringLiteral("<p align=\"right\">"); | 598 | QString linkCode = QStringLiteral("<p align=\"right\">"); | ||
597 | int i = 0; | 599 | int i = 0; | ||
598 | Q_FOREACH (const QString &it, notification->actions()) { | 600 | const auto actionList = notification->actions(); | ||
601 | for (const QString &it : actionList) { | ||||
599 | i++; | 602 | i++; | ||
600 | linkCode += QStringLiteral(" <a href=\"%1/%2\">%3</a>").arg(QString::number(notification->id()), QString::number(i), it.toHtmlEscaped()); | 603 | linkCode += QStringLiteral(" <a href=\"%1/%2\">%3</a>").arg(QString::number(notification->id()), QString::number(i), it.toHtmlEscaped()); | ||
601 | } | 604 | } | ||
602 | 605 | | |||
603 | linkCode += QLatin1String("</p>"); | 606 | linkCode += QLatin1String("</p>"); | ||
604 | QLabel *link = new QLabel(linkCode , vb ); | 607 | QLabel *link = new QLabel(linkCode , vb ); | ||
605 | link->setTextInteractionFlags(Qt::LinksAccessibleByMouse); | 608 | link->setTextInteractionFlags(Qt::LinksAccessibleByMouse); | ||
606 | link->setOpenExternalLinks(false); | 609 | link->setOpenExternalLinks(false); | ||
▲ Show 20 Lines • Show All 59 Lines • ▼ Show 20 Line(s) | 621 | { | |||
666 | QStringList actionList; | 669 | QStringList actionList; | ||
667 | if (popupServerCapabilities.contains(QStringLiteral("actions"))) { | 670 | if (popupServerCapabilities.contains(QStringLiteral("actions"))) { | ||
668 | QString defaultAction = notification->defaultAction(); | 671 | QString defaultAction = notification->defaultAction(); | ||
669 | if (!defaultAction.isEmpty()) { | 672 | if (!defaultAction.isEmpty()) { | ||
670 | actionList.append(QStringLiteral("default")); | 673 | actionList.append(QStringLiteral("default")); | ||
671 | actionList.append(defaultAction); | 674 | actionList.append(defaultAction); | ||
672 | } | 675 | } | ||
673 | int actId = 0; | 676 | int actId = 0; | ||
674 | Q_FOREACH (const QString &actionName, notification->actions()) { | 677 | const auto listActions = notification->actions(); | ||
678 | for (const QString &actionName : listActions) { | ||||
675 | actId++; | 679 | actId++; | ||
676 | actionList.append(QString::number(actId)); | 680 | actionList.append(QString::number(actId)); | ||
677 | actionList.append(actionName); | 681 | actionList.append(actionName); | ||
678 | } | 682 | } | ||
679 | } | 683 | } | ||
680 | 684 | | |||
681 | args.append(actionList); // actions | 685 | args.append(actionList); // actions | ||
682 | 686 | | |||
▲ Show 20 Lines • Show All 157 Lines • Show Last 20 Lines |
same