Changeset View
Changeset View
Standalone View
Standalone View
src/notifybysnore.cpp
Show First 20 Lines • Show All 134 Lines • ▼ Show 20 Line(s) | |||||
135 | 135 | | |||
136 | NotifyBySnore::~NotifyBySnore() | 136 | NotifyBySnore::~NotifyBySnore() | ||
137 | { | 137 | { | ||
138 | m_server.close(); | 138 | m_server.close(); | ||
139 | } | 139 | } | ||
140 | 140 | | |||
141 | void NotifyBySnore::notify(KNotification *notification, KNotifyConfig *config) | 141 | void NotifyBySnore::notify(KNotification *notification, KNotifyConfig *config) | ||
142 | { | 142 | { | ||
143 | Q_UNUSED(config); | ||||
144 | // HACK work around that notification->id() is only populated after returning from here | ||||
145 | // note that config will be invalid at that point, so we can't pass that along | ||||
146 | QMetaObject::invokeMethod(this, [this, notification](){ notifyDeferred(notification); }, Qt::QueuedConnection); | ||||
147 | } | ||||
148 | | ||||
149 | void NotifyBySnore::notifyDeferred(KNotification* notification) | ||||
150 | { | ||||
143 | QProcess *proc = new QProcess(); | 151 | QProcess *proc = new QProcess(); | ||
144 | QStringList arguments; | 152 | QStringList arguments; | ||
145 | 153 | | |||
146 | arguments << QStringLiteral("-t"); | 154 | arguments << QStringLiteral("-t"); | ||
147 | if (!notification->title().isEmpty()) { | 155 | if (!notification->title().isEmpty()) { | ||
148 | arguments << notification->title(); | 156 | arguments << notification->title(); | ||
149 | } else { | 157 | } else { | ||
150 | arguments << qApp->applicationDisplayName(); | 158 | arguments << qApp->applicationDisplayName(); | ||
151 | } | 159 | } | ||
152 | arguments << QStringLiteral("-m") << notification->text(); | 160 | arguments << QStringLiteral("-m") << notification->text(); | ||
153 | const QString iconPath = m_iconDir.path() + QLatin1Char('/') | 161 | const QString iconPath = m_iconDir.path() + QLatin1Char('/') | ||
154 | + QString::number(notification->id()) + QStringLiteral(".png"); | 162 | + QString::number(notification->id()) + QStringLiteral(".png"); | ||
155 | if (!notification->pixmap().isNull()) { | 163 | if (!notification->pixmap().isNull()) { | ||
164 | auto iconPath = QString(m_iconDir.path() + QLatin1Char('/') | ||||
165 | + QString::number(notification->id()) + QStringLiteral(".png")); | ||||
156 | notification->pixmap().save(iconPath, "PNG"); | 166 | notification->pixmap().save(iconPath, "PNG"); | ||
157 | arguments << QStringLiteral("-p") << iconPath; | 167 | arguments << QStringLiteral("-p") << iconPath; | ||
158 | } else if (!qApp->windowIcon().isNull()) { | 168 | } else if (!qApp->windowIcon().isNull()) { | ||
159 | QIcon app_icon = qApp->windowIcon(); | 169 | QIcon app_icon = qApp->windowIcon(); | ||
160 | // We limit the icon size to 1024x1024 as it is the highest supported by Windows | 170 | // We limit the icon size to 1024x1024 as it is the highest supported by Windows | ||
161 | QPixmap pixmap = app_icon.pixmap(1024, 1024); | 171 | QPixmap pixmap = app_icon.pixmap(1024, 1024); | ||
162 | pixmap.save(iconPath, "PNG"); | 172 | pixmap.save(iconPath, "PNG"); | ||
163 | arguments << QStringLiteral("-p") << iconPath; | 173 | arguments << QStringLiteral("-p") << iconPath; | ||
▲ Show 20 Lines • Show All 45 Lines • Show Last 20 Lines |