void MainWindow::notificationsChanged() { QList<NotificationChecker::NotificationEntry> entries = MMC->notificationChecker()->notificationEntries(); QList<int> shownNotifications = stringToIntList(MMC->settings()->get("ShownNotifications").toString()); for (auto it = entries.begin(); it != entries.end(); ++it) { NotificationChecker::NotificationEntry entry = *it; if (!shownNotifications.contains(entry.id) && entry.applies()) { NotificationDialog dialog(entry, this); if (dialog.exec() == NotificationDialog::DontShowAgain) { shownNotifications.append(entry.id); } } } MMC->settings()->set("ShownNotifications", intListToString(shownNotifications)); }
void MainWindow::notificationsChanged() { QList<NotificationChecker::NotificationEntry> entries = MMC->notificationChecker()->notificationEntries(); QList<int> shownNotifications = stringToIntList(MMC->settings()->get("ShownNotifications").toString()); for (auto it = entries.begin(); it != entries.end(); ++it) { NotificationChecker::NotificationEntry entry = *it; if (!shownNotifications.contains(entry.id) && entry.applies()) { QMessageBox::Icon icon; switch (entry.type) { case NotificationChecker::NotificationEntry::Critical: icon = QMessageBox::Critical; break; case NotificationChecker::NotificationEntry::Warning: icon = QMessageBox::Warning; break; case NotificationChecker::NotificationEntry::Information: icon = QMessageBox::Information; break; } QMessageBox box(icon, tr("Notification"), entry.message, QMessageBox::Close, this); QPushButton *dontShowAgainButton = box.addButton(tr("Don't show again"), QMessageBox::AcceptRole); box.setDefaultButton(QMessageBox::Close); box.exec(); if (box.clickedButton() == dontShowAgainButton) { shownNotifications.append(entry.id); } } } MMC->settings()->set("ShownNotifications", intListToString(shownNotifications)); }