Changeset View
Changeset View
Standalone View
Standalone View
kded/notification.cpp
Show All 29 Lines | |||||
30 | 30 | | |||
31 | #include <KLocalizedString> | 31 | #include <KLocalizedString> | ||
32 | #include <KNotification> | 32 | #include <KNotification> | ||
33 | 33 | | |||
34 | #include <QDBusConnection> | 34 | #include <QDBusConnection> | ||
35 | #include <QIcon> | 35 | #include <QIcon> | ||
36 | #include <QTimer> | 36 | #include <QTimer> | ||
37 | 37 | | |||
38 | #include <algorithm> | ||||
39 | | ||||
38 | Notification::Notification(QObject *parent) : | 40 | Notification::Notification(QObject *parent) : | ||
39 | QObject(parent) | 41 | QObject(parent) | ||
40 | { | 42 | { | ||
41 | // devices | 43 | // devices | ||
42 | for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) { | 44 | for (const NetworkManager::Device::Ptr &device : NetworkManager::networkInterfaces()) { | ||
43 | addDevice(device); | 45 | addDevice(device); | ||
44 | } | 46 | } | ||
45 | 47 | | |||
▲ Show 20 Lines • Show All 518 Lines • ▼ Show 20 Line(s) | |||||
564 | { | 566 | { | ||
565 | if (m_activeConnectionsBeforeSleep.isEmpty()) { | 567 | if (m_activeConnectionsBeforeSleep.isEmpty()) { | ||
566 | // if we weren't connected before, don't bother telling us now :) | 568 | // if we weren't connected before, don't bother telling us now :) | ||
567 | return; | 569 | return; | ||
568 | } | 570 | } | ||
569 | 571 | | |||
570 | m_activeConnectionsBeforeSleep.clear(); | 572 | m_activeConnectionsBeforeSleep.clear(); | ||
571 | 573 | | |||
572 | const auto &connections = NetworkManager::activeConnections(); | 574 | const auto ac = NetworkManager::activeConnections(); | ||
573 | for (const auto &connection : connections) { | 575 | if (std::any_of(ac.constBegin(), ac.constEnd(), [](const auto &connection) { | ||
davidre: const auto&? | |||||
574 | if (connection->state() == NetworkManager::ActiveConnection::State::Activated || | 576 | return connection->state() == NetworkManager::ActiveConnection::State::Activated | ||
575 | connection->state() == NetworkManager::ActiveConnection::State::Activating) { | 577 | || connection->state() == NetworkManager::ActiveConnection::State::Activating; | ||
578 | })) { | ||||
576 | // we have an active or activating connection, don't tell the user we're no longer connected | 579 | // we have an active or activating connection, don't tell the user we're no longer connected | ||
577 | return; | 580 | return; | ||
578 | } | 581 | } | ||
579 | } | | |||
580 | 582 | | |||
581 | KNotification *notify = new KNotification(QStringLiteral("NoLongerConnected"), KNotification::CloseOnTimeout); | 583 | KNotification *notify = new KNotification(QStringLiteral("NoLongerConnected"), KNotification::CloseOnTimeout); | ||
582 | connect(notify, &KNotification::closed, this, &Notification::notificationClosed); | 584 | connect(notify, &KNotification::closed, this, &Notification::notificationClosed); | ||
583 | const QString uni = QStringLiteral("offlineNotification"); | 585 | const QString uni = QStringLiteral("offlineNotification"); | ||
584 | notify->setProperty("uni", uni); | 586 | notify->setProperty("uni", uni); | ||
585 | notify->setComponentName("networkmanagement"); | 587 | notify->setComponentName("networkmanagement"); | ||
586 | notify->setIconName(QStringLiteral("dialog-warning")); | 588 | notify->setIconName(QStringLiteral("dialog-warning")); | ||
587 | notify->setTitle(i18n("No Network Connection")); | 589 | notify->setTitle(i18n("No Network Connection")); | ||
588 | notify->setText(i18n("You are no longer connected to a network.")); | 590 | notify->setText(i18n("You are no longer connected to a network.")); | ||
589 | m_notifications[uni] = notify; | 591 | m_notifications[uni] = notify; | ||
590 | notify->sendEvent(); | 592 | notify->sendEvent(); | ||
591 | } | 593 | } |
const auto&?