<html>
<body>
<div style="font-family: Verdana, Arial, Helvetica, Sans-Serif;">
<table bgcolor="#f9f3c9" width="100%" cellpadding="12" style="border: 1px #c9c399 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
This is an automatically generated e-mail. To reply, visit:
<a href="https://git.reviewboard.kde.org/r/126369/">https://git.reviewboard.kde.org/r/126369/</a>
</td>
</tr>
</table>
<br />
<pre style="white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Well, it isn't exactly easy, but I remembered that KMail can badge the system tray icon with the number of read messages. Adapted to KNotifications (no extra dependencies except for Qt5::MacExtras for the -optional?- app icon badging) that gives </p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><div class="codehilite" style="background: #f8f8f8"><pre style="line-height: 125%"><span style="color: #B00040">void</span> KStatusNotifierItemPrivate<span style="color: #666666">::</span>syncLegacySystemTrayIcon()
{
<span style="color: #008000; font-weight: bold">if</span> (status <span style="color: #666666">==</span> KStatusNotifierItem<span style="color: #666666">::</span>NeedsAttention) {
<span style="color: #BC7A00">#ifdef Q_OS_OSX</span>
QtMac<span style="color: #666666">::</span>setBadgeLabelText(QStringLiteral(<span style="color: #BA2121">"!"</span>));
<span style="color: #008000; font-weight: bold">if</span> (attentionIconName.isNull() <span style="color: #666666">&&</span> attentionIcon.isNull()) {
<span style="color: #408080; font-style: italic">// code adapted from kmail's KMSystemTray::updateCount()</span>
<span style="color: #B00040">int</span> overlaySize <span style="color: #666666">=</span> <span style="color: #666666">22</span>;
QIcon attnIcon <span style="color: #666666">=</span> qApp<span style="color: #666666">-></span>windowIcon();
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>attnIcon.availableSizes().isEmpty()) {
overlaySize <span style="color: #666666">=</span> attnIcon.availableSizes().at(<span style="color: #666666">0</span>).width();
}
QFont labelFont <span style="color: #666666">=</span> QFontDatabase<span style="color: #666666">::</span>systemFont(QFontDatabase<span style="color: #666666">::</span>GeneralFont);
labelFont.setBold(<span style="color: #008000">true</span>);
QFontMetrics <span style="color: #0000FF">qfm</span>(labelFont);
<span style="color: #B00040">float</span> attnHeight <span style="color: #666666">=</span> overlaySize <span style="color: #666666">*</span> <span style="color: #666666">0.667</span>;
<span style="color: #008000; font-weight: bold">if</span> (qfm.height() <span style="color: #666666">></span> attnHeight) {
<span style="color: #B00040">float</span> labelSize <span style="color: #666666">=</span> attnHeight;
labelFont.setPointSizeF(labelSize);
}
<span style="color: #408080; font-style: italic">// Paint the label in a pixmap</span>
QPixmap overlayPixmap(overlaySize, overlaySize);
overlayPixmap.fill(Qt<span style="color: #666666">::</span>transparent);
QPainter <span style="color: #0000FF">p</span>(<span style="color: #666666">&</span>overlayPixmap);
p.setFont(labelFont);
p.setBrush(Qt<span style="color: #666666">::</span>NoBrush);
<span style="color: #408080; font-style: italic">// this sort of badge/label is red on OS X</span>
p.setPen(QColor(<span style="color: #666666">224</span>,<span style="color: #666666">0</span>,<span style="color: #666666">0</span>));
p.setOpacity(<span style="color: #666666">1.0</span>);
<span style="color: #408080; font-style: italic">// use U+2022, the Unicode bullet</span>
p.drawText(overlayPixmap.rect(), Qt<span style="color: #666666">::</span>AlignRight<span style="color: #666666">|</span>Qt<span style="color: #666666">::</span>AlignTop, QStringLiteral(<span style="color: #BA2121">"•"</span>));
p.end();
QPixmap iconPixmap <span style="color: #666666">=</span> attnIcon.pixmap(overlaySize, overlaySize);
QPainter <span style="color: #0000FF">pp</span>(<span style="color: #666666">&</span>iconPixmap);
pp.drawPixmap(<span style="color: #666666">0</span>, <span style="color: #666666">0</span>, overlayPixmap);
pp.end();
systemTrayIcon<span style="color: #666666">-></span>setIcon(iconPixmap);
} <span style="color: #008000; font-weight: bold">else</span>
<span style="color: #BC7A00">#endif</span>
{
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>movieName.isNull()) {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>movie) {
movie <span style="color: #666666">=</span> <span style="color: #008000; font-weight: bold">new</span> QMovie(movieName);
}
systemTrayIcon<span style="color: #666666">-></span>setMovie(movie);
} <span style="color: #008000; font-weight: bold">else</span> <span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>attentionIconName.isNull()) {
systemTrayIcon<span style="color: #666666">-></span>setIcon(QIcon<span style="color: #666666">::</span>fromTheme(attentionIconName));
} <span style="color: #008000; font-weight: bold">else</span> {
systemTrayIcon<span style="color: #666666">-></span>setIcon(attentionIcon);
}
}
} <span style="color: #008000; font-weight: bold">else</span> {
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>iconName.isNull()) {
systemTrayIcon<span style="color: #666666">-></span>setIcon(QIcon<span style="color: #666666">::</span>fromTheme(iconName));
} <span style="color: #008000; font-weight: bold">else</span> {
systemTrayIcon<span style="color: #666666">-></span>setIcon(icon);
}
<span style="color: #BC7A00">#ifdef Q_OS_OSX</span>
QtMac<span style="color: #666666">::</span>setBadgeLabelText(QString());
<span style="color: #BC7A00">#endif</span>
}
systemTrayIcon<span style="color: #666666">-></span>setToolTip(toolTipTitle);
}
</pre></div>
</p></pre>
<br />
<p>- René J.V. Bertin</p>
<br />
<p>On December 17th, 2015, 12:40 p.m. CET, René J.V. Bertin wrote:</p>
<table bgcolor="#fefadf" width="100%" cellspacing="0" cellpadding="12" style="border: 1px #888a85 solid; border-radius: 6px; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
<tr>
<td>
<div>Review request for KDE Software on Mac OS X and KDE Frameworks.</div>
<div>By René J.V. Bertin.</div>
<p style="color: grey;"><i>Updated Dec. 17, 2015, 12:40 p.m.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
knotifications
</div>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Description </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">OS X has a number of limitations in features used by KNotifications, notably concerning the status notifier item (aka system tray icon).</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This RR will likely evolve to address multiple limitations (at least also the NeedsAttention state); at the moment it only proposes an emulation of <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">QMenu::addSection</code>.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;"><code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">QMenu::addSection</code> works by adding a QAction with a "texted separator" at the insertion location. Texted separators do not exist in menu items in the OS X "global" menubar (they become regular separators), and Qt will not provide a platform-specific implementation. Loss of the section title text is maybe not always an issue, but I think it is in the system tray menu. I therefore propose to emulate <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">QMenu::addSection</code> by replacing the texted separator with an inactive (disabled) menu item that shows the text, followed by a standard separator. Menus in the notification area are much less subject to interface guidelines, so the presence of an item icon is acceptable and IMO useful for the <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">titleAction</code>.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Testing the NeedsAttention state with the tests/kstatusnotifieritemtest application leads to disappearance of the menubar icon, i.e. the access to the notifier menu becomes invisible rather than blinking (which is what I get on Linux using the same packaging). Adding a few qDebug statements shows that the <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">attentionIcon</code> is empty.
I'd appreciate a crash course how this feature is supposed to work, so I can see if an OS X implementation might be feasible.</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Testing </h1>
<table width="100%" bgcolor="#ffffff" cellspacing="0" cellpadding="10" style="border: 1px solid #b8b5a0">
<tr>
<td>
<pre style="margin: 0; padding: 0; white-space: pre-wrap; white-space: -moz-pre-wrap; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word;"><p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">On OS X 10.9.5 with Qt 5.5.1 and frameworks 5.17.0 .</p></pre>
</td>
</tr>
</table>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">Diffs</b> </h1>
<ul style="margin-left: 3em; padding-left: 0;">
<li>src/kstatusnotifieritem.cpp <span style="color: grey">(f9bf460)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/126369/diff/" style="margin-left: 3em;">View Diff</a></p>
<h1 style="color: #575012; font-size: 10pt; margin-top: 1.5em;">File Attachments </h1>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/12/16/286037ae-07b3-454a-a226-1748854493a1__kstatusnotifieritemtest-systray.png">the systray icon & menu created by kstatusnotifieritemtest . This application has no icon to show.</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/12/16/4fc9d4e4-1537-478c-9196-94cbc17b6b7c__kwalletmanager-systray.png">The systray icon and menu created by the KDE4 kwalletmanager (code has an equivalent patch)</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/12/16/fc48a963-2e18-4396-bd38-062d41688118__Apple-systray-menu-with-icons.png">An Apple systray icon+menu that shows icons (which cannot be hidden)</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2015/12/17/e896e90d-f0a8-43f7-9199-847572832df7__kstatusnotifieritemtest-with-appIcon.png">kstatusnotifieritemtest with added appIcon</a></li>
</ul>
</td>
</tr>
</table>
</div>
</body>
</html>