Changeset View
Changeset View
Standalone View
Standalone View
src/statusnotifier.cpp
Show All 40 Lines | 38 | { | |||
---|---|---|---|---|---|
41 | // this is used for both the SNI tooltip as well as the notification | 41 | // this is used for both the SNI tooltip as well as the notification | ||
42 | m_title = i18nc("Placeholder is an application name; it crashed", "%1 Closed Unexpectedly", crashedApp->name()); | 42 | m_title = i18nc("Placeholder is an application name; it crashed", "%1 Closed Unexpectedly", crashedApp->name()); | ||
43 | 43 | | |||
44 | // if nobody bothered to look at the crash after 1 minute, just close | 44 | // if nobody bothered to look at the crash after 1 minute, just close | ||
45 | m_autoCloseTimer->setSingleShot(true); | 45 | m_autoCloseTimer->setSingleShot(true); | ||
46 | m_autoCloseTimer->setInterval(60000); | 46 | m_autoCloseTimer->setInterval(60000); | ||
47 | m_autoCloseTimer->start(); | 47 | m_autoCloseTimer->start(); | ||
48 | connect(m_autoCloseTimer, &QTimer::timeout, this, &StatusNotifier::expired); | 48 | connect(m_autoCloseTimer, &QTimer::timeout, this, &StatusNotifier::expired); | ||
49 | connect(this, &StatusNotifier::activated, this, [this] { | 49 | connect(this, &StatusNotifier::activated, this, &StatusNotifier::deleteLater); | ||
50 | deleteLater(); | | |||
51 | }); | | |||
52 | 50 | | |||
53 | KService::Ptr service = KService::serviceByStorageId(crashedApp->fakeExecutableBaseName()); | 51 | KService::Ptr service = KService::serviceByStorageId(crashedApp->fakeExecutableBaseName()); | ||
54 | if (service) { | 52 | if (service) { | ||
55 | m_iconName = service->icon(); | 53 | m_iconName = service->icon(); | ||
56 | } | 54 | } | ||
57 | 55 | | |||
58 | m_sni->setTitle(m_title); | 56 | m_sni->setTitle(m_title); | ||
59 | m_sni->setIconByName(QStringLiteral("tools-report-bug")); | 57 | m_sni->setIconByName(QStringLiteral("tools-report-bug")); | ||
Show All 10 Lines | 67 | QAction *action = new QAction(QIcon::fromTheme(QStringLiteral("tools-report-bug")), | |||
70 | i18n("Report &Bug"), nullptr); | 68 | i18n("Report &Bug"), nullptr); | ||
71 | connect(action, &QAction::triggered, this, &StatusNotifier::activated); | 69 | connect(action, &QAction::triggered, this, &StatusNotifier::activated); | ||
72 | sniMenu->addAction(action); | 70 | sniMenu->addAction(action); | ||
73 | sniMenu->setDefaultAction(action); | 71 | sniMenu->setDefaultAction(action); | ||
74 | 72 | | |||
75 | if (canBeRestarted(crashedApp)) { | 73 | if (canBeRestarted(crashedApp)) { | ||
76 | action = new QAction(QIcon::fromTheme(QStringLiteral("system-reboot")), | 74 | action = new QAction(QIcon::fromTheme(QStringLiteral("system-reboot")), | ||
77 | i18n("&Restart Application"), nullptr); | 75 | i18n("&Restart Application"), nullptr); | ||
78 | connect(action, &QAction::triggered, this, [crashedApp] { | 76 | connect(action, &QAction::triggered, crashedApp, &CrashedApplication::restart); | ||
79 | crashedApp->restart(); | | |||
80 | }); | | |||
81 | // once restarted successfully, disable restart option | 77 | // once restarted successfully, disable restart option | ||
82 | connect(crashedApp, &CrashedApplication::restarted, action, [action](bool success) { | 78 | connect(crashedApp, &CrashedApplication::restarted, action, [action](bool success) { | ||
83 | action->setEnabled(!success); | 79 | action->setEnabled(!success); | ||
84 | }); | 80 | }); | ||
85 | sniMenu->addAction(action); | 81 | sniMenu->addAction(action); | ||
86 | } | 82 | } | ||
87 | 83 | | |||
88 | sniMenu->addSeparator(); | 84 | sniMenu->addSeparator(); | ||
▲ Show 20 Lines • Show All 74 Lines • Show Last 20 Lines |