<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/120355/">https://git.reviewboard.kde.org/r/120355/</a>
</td>
</tr>
</table>
<br />
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<p style="margin-top: 0;">On September 27th, 2014, 6:13 nachm. UTC, <b>René J.V. Bertin</b> wrote:</p>
<blockquote style="margin-left: 1em; border-left: 2px solid #d0d0d0; padding-left: 10px;">
<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;">How about this modification if I were to modify <code style="text-rendering: inherit;color: #4444cc;padding: 0;white-space: normal;margin: 0;line-height: inherit;">KMenu::addTitle</code> to do something similar to what my patch to Konqueror does, on OS X? I modified the code to detect when an action is being added to a KMenu that has a KMainWindow with a KMenuBar among its associated widgets. If I understand correctly, this means that the menu <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">may</em> end up being displayed in the global menubar on OS X. It's not as refined as I would have liked, but there appears to be no reliable way to detect whether a menu belongs to a menubar that is the OS X global one.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">```C++<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
QAction<em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;"> KMenu::addTitle(const QIcon &icon, const QString &text, QAction</em> before)<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
{<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
bool notMacMenuBar = true;</p>
<h1 style="font-size: 100%;text-rendering: inherit;padding: 0;white-space: normal;margin: 0;line-height: inherit;">ifdef Q_OS_MAC</h1>
<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: #008000; font-weight: bold">if</span> (QAction <span style="color: #666666">*</span>mAct <span style="color: #666666">=</span> menuAction()) {
qDebug() <span style="color: #666666"><<</span> <span style="color: #BA2121">"## addTitle this="</span> <span style="color: #666666"><<</span> this <span style="color: #666666"><<</span> <span style="color: #BA2121">"mAct="</span> <span style="color: #666666"><<</span> mAct <span style="color: #666666"><<</span> mAct<span style="color: #666666">-></span>text();
foreach (QWidget <span style="color: #666666">*</span>w, mAct<span style="color: #666666">-></span>associatedWidgets()) {
qDebug() <span style="color: #666666"><<</span> <span style="color: #BA2121">"### widget"</span> <span style="color: #666666"><<</span> w <span style="color: #666666"><<</span> w<span style="color: #666666">-></span>windowTitle() <span style="color: #666666"><<</span> <span style="color: #BA2121">"parent="</span> <span style="color: #666666"><<</span> w<span style="color: #666666">-></span>parentWidget();
<span style="color: #008000; font-weight: bold">if</span> (qobject_cast<span style="color: #666666"><</span>KMenu<span style="color: #666666">*></span>(w) <span style="color: #666666">||</span> qobject_cast<span style="color: #666666"><</span>QMenu<span style="color: #666666">*></span>(w)) {
<span style="color: #008000; font-weight: bold">if</span> (KMainWindow <span style="color: #666666">*</span>obj <span style="color: #666666">=</span> qobject_cast<span style="color: #666666"><</span>KMainWindow<span style="color: #666666">*></span>(w<span style="color: #666666">-></span>parentWidget())) {
<span style="color: #008000; font-weight: bold">if</span> (obj<span style="color: #666666">-></span>hasMenuBar()) {
<span style="color: #408080; font-style: italic">// this is a KMainWindow with a menubar. On OS X, that could be the menubar, in which we</span>
<span style="color: #408080; font-style: italic">// have to create our title items differently.</span>
notMacMenuBar <span style="color: #666666">=</span> <span style="color: #008000">false</span>;
qDebug() <span style="color: #666666"><<</span> <span style="color: #BA2121">"#### widget"</span> <span style="color: #666666"><<</span> obj <span style="color: #666666"><<</span> obj<span style="color: #666666">-></span>windowTitle() <span style="color: #666666"><<</span> <span style="color: #BA2121">"has menubar"</span> <span style="color: #666666"><<</span> obj<span style="color: #666666">-></span>menuBar() <span style="color: #666666"><<</span> <span style="color: #BA2121">"with parent"</span> <span style="color: #666666"><<</span> obj<span style="color: #666666">-></span>menuBar()<span style="color: #666666">-></span>parentWidget();
<span style="color: #008000; font-weight: bold">break</span>;
}
}
}
}
}
</pre></div>
</p>
<h1 style="font-size: 100%;text-rendering: inherit;padding: 0;white-space: normal;margin: 0;line-height: inherit;">endif // Q_OS_MAC</h1>
<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: #008000; font-weight: bold">if</span> (notMacMenuBar) {
QAction <span style="color: #666666">*</span>buttonAction <span style="color: #666666">=</span> new QAction(this);
QFont font <span style="color: #666666">=</span> buttonAction<span style="color: #666666">-></span>font();
font.setBold(<span style="color: #008000">true</span>);
buttonAction<span style="color: #666666">-></span>setFont(font);
buttonAction<span style="color: #666666">-></span>setText(text);
buttonAction<span style="color: #666666">-></span>setIcon(icon);
QWidgetAction <span style="color: #666666">*</span>action <span style="color: #666666">=</span> new QWidgetAction(this);
action<span style="color: #666666">-></span>setObjectName(KMENU_TITLE);
QToolButton <span style="color: #666666">*</span>titleButton <span style="color: #666666">=</span> new QToolButton(this);
titleButton<span style="color: #666666">-></span>installEventFilter(d); <span style="color: #408080; font-style: italic">// prevent clicks on the title of the menu</span>
titleButton<span style="color: #666666">-></span>setDefaultAction(buttonAction);
titleButton<span style="color: #666666">-></span>setDown(<span style="color: #008000">true</span>); <span style="color: #408080; font-style: italic">// prevent hover style changes in some styles</span>
titleButton<span style="color: #666666">-></span>setToolButtonStyle(Qt<span style="color: #666666">::</span>ToolButtonTextBesideIcon);
action<span style="color: #666666">-></span>setDefaultWidget(titleButton);
insertAction(before, action);
<span style="color: #008000; font-weight: bold">return</span> action;
}
<span style="color: #008000; font-weight: bold">else</span>{
QAction <span style="color: #666666">*</span>action <span style="color: #666666">=</span> new QAction(this);
action<span style="color: #666666">-></span>setText(text);
action<span style="color: #666666">-></span>setIcon(icon);
action<span style="color: #666666">-></span>setEnabled(<span style="color: #008000">false</span>);
<span style="color: #008000; font-weight: bold">if</span> (before <span style="color: #666666">&&</span> actions().contains(before)) {
QAction <span style="color: #666666">*</span>sepLow <span style="color: #666666">=</span> new QAction(this);
sepLow<span style="color: #666666">-></span>setSeparator(<span style="color: #008000">true</span>);
insertAction(before, sepLow);
insertAction(sepLow, action);
<span style="color: #008000; font-weight: bold">if</span> (<span style="color: #666666">!</span>actions().startsWith(action)) {
QAction <span style="color: #666666">*</span>sepHigh <span style="color: #666666">=</span> new QAction(this);
sepHigh<span style="color: #666666">-></span>setSeparator(<span style="color: #008000">true</span>);
insertAction(action,sepHigh);
qDebug() <span style="color: #666666"><<</span> <span style="color: #BA2121">"#### inserted high separator before"</span> <span style="color: #666666"><<</span> action <span style="color: #666666"><<</span> <span style="color: #BA2121">"before low separator before"</span> <span style="color: #666666"><<</span> before;
}
<span style="color: #008000; font-weight: bold">else</span>{
qDebug() <span style="color: #666666"><<</span> <span style="color: #BA2121">"#### inserted"</span> <span style="color: #666666"><<</span> action <span style="color: #666666"><<</span> <span style="color: #BA2121">"before low separator before"</span> <span style="color: #666666"><<</span> before;
}
}
<span style="color: #008000; font-weight: bold">else</span>{
addAction(action);
addSeparator();
qDebug() <span style="color: #666666"><<</span> <span style="color: #BA2121">"#### appended low separator after"</span> <span style="color: #666666"><<</span> action <span style="color: #666666"><<</span> <span style="color: #BA2121">"after existing"</span> <span style="color: #666666"><<</span> actions().size()<span style="color: #666666">-2</span> <span style="color: #666666"><<</span> <span style="color: #BA2121">"items (before="</span> <span style="color: #666666"><<</span> before;
}
<span style="color: #008000; font-weight: bold">return</span> action;
}
</pre></div>
</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">}```</p></pre>
</blockquote>
</blockquote>
<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;">While it's true that my sketch simplified in ignoring the possibility to have the title on a submenu to the global menubar, this patch is <em style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;">very</em> specific in it's matching (though not necessarily correct)</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">It matches a popup menu which is submenu to a popup menu which is parented by a KMainWindow which has a menubar...</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">There're also some technical issues, but that's minor.<br style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: normal;" />
In any case a strongly suggest to open a review request for this patch to be annotated.</p></pre>
<br />
<p>- Thomas</p>
<br />
<p>On September 26th, 2014, 5:28 nachm. UTC, 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 Base Apps, KDE Software on Mac OS X, kdelibs, and Qt KDE.</div>
<div>By René J.V. Bertin.</div>
<p style="color: grey;"><i>Updated Sept. 26, 2014, 5:28 nachm.</i></p>
<div style="margin-top: 1.5em;">
<b style="color: #575012; font-size: 10pt;">Repository: </b>
kde-baseapps
</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;">Mac OS X cannot handle the formatting used for title menu items when it applies to items in the toplevel menu bar. An application calling KMenu::addTitle on such a menu item will crash immediately, somewhere deep in Qt.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">This patch works around that crash by emulating the addTitle effect.</p>
<p style="padding: 0;text-rendering: inherit;margin: 0;line-height: inherit;white-space: inherit;">Curiously, the addTitle call that causes the crash when clicking on the Help menu concerns a submenu of an item of the Tools menu...</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;">OS X 10.6.8 with kdelibs 4.14.1</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>konq-plugins/uachanger/uachangerplugin.cpp <span style="color: grey">(5e2d094)</span></li>
</ul>
<p><a href="https://git.reviewboard.kde.org/r/120355/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/2014/09/26/b5c2dd92-33db-4225-9750-d10e13f0f835__prevent_addTitleRelated_crash.patch">patch for qwidget_mac.mm</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2014/09/26/96f4fbfa-854e-4596-9f5f-d82f98a06955__Screen_shot_2014-09-26_at_19.16.20.png">with the Qt patch</a></li>
<li><a href="https://git.reviewboard.kde.org/media/uploaded/files/2014/09/26/5ddf4a63-b3bb-415a-815a-c06eb7a5c7f2__Screen_shot_2014-09-26_at_19.19.40.png">with the addTitle emulation patch</a></li>
</ul>
</td>
</tr>
</table>
</div>
</body>
</html>