For reference, the full QPlatformMenu patch: <a href="https://codereview.qt-project.org/#change,4068">https://codereview.qt-project.org/#change,4068</a><br><br><div class="gmail_quote">On Fri, Feb 17, 2012 at 20:22, BogDan <span dir="ltr"><<a href="mailto:bog_dan_ro@yahoo.com">bog_dan_ro@yahoo.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
<br>
Hi,<br>
<br>
I have some bad news, these days I was very busy at work and I didn't had time finish the menu changes, the problem is next two weeks I'll be in Belarus (business travel). Sadly, these weeks, I don't think I'll have enough time to work on it ...<br>
<br>
<br>
<br>
Cheers,<br>
BogDan.<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
----- Original Message -----<br>
> From: BogDan <<a href="mailto:bog_dan_ro@yahoo.com">bog_dan_ro@yahoo.com</a>><br>
> To: "<a href="mailto:mkruisselbrink@kde.org">mkruisselbrink@kde.org</a>" <<a href="mailto:mkruisselbrink@kde.org">mkruisselbrink@kde.org</a>><br>
> Cc: "<a href="mailto:cbro@semperpax.com">cbro@semperpax.com</a>" <<a href="mailto:cbro@semperpax.com">cbro@semperpax.com</a>>; Necessitas <<a href="mailto:necessitas-devel@kde.org">necessitas-devel@kde.org</a>><br>
> Sent: Thursday, February 16, 2012 9:21 PM<br>
> Subject: Re: Native Options Menu<br>
><br>
> Hi,<br>
><br>
> + necessitas-devel in CC<br>
><br>
> I believe our goal should be to easily port an application *and* that<br>
> application should look and fell the same with native applications, otherwise<br>
> Android users will fell the difference and some (most) of them will reject any<br>
> application which looks odd. So IMHO we should focus on this matter.<br>
><br>
><br>
> Regarding active window thing, yes I've seen that message, but I<br>
> didn't had time to dig more and to find a proper solution. A quick and dirty<br>
> solution will be to set the last top level widget as the active one, but sounds<br>
> too easy to be the right solution :).<br>
><br>
> Cheers,<br>
> BogDan.<br>
><br>
> ________________________________<br>
> From: Marijn Kruisselbrink <<a href="mailto:mkruisselbrink@kde.org">mkruisselbrink@kde.org</a>>;<br>
> To: BogDan <<a href="mailto:bog_dan_ro@yahoo.com">bog_dan_ro@yahoo.com</a>>;<br>
> Cc: Chris Browet <<a href="mailto:cbro@semperpax.com">cbro@semperpax.com</a>>;<br>
> Subject: Re: Native Options Menu<br>
> Sent: Thu, Feb 16, 2012 7:27:55 AM<br>
><br>
><br>
> I don't have a particularly strong opinion either way, for my purposes<br>
> having<br>
> just QMainWindow be able to have a menu would be fine, but that might indeed<br>
> not be flexible enough. For QML and android 3.x and later we might want to<br>
> somehow expose some sort of actionbar api to get among other things a<br>
> "native"<br>
> option menu? Although I'm not sure what our goal there is, minimal effort to<br>
><br>
> port an application, or being able to use qt/qml to make an app that looks and<br>
> feels native?<br>
><br>
> For the activeWindow issue, there is actually a comment in QWidget::destroy in<br>
> qwidget_qpa.cpp "we don't have proper focus event handling yet" in<br>
> one of the<br>
> places where activeWindow should be updated to some correct value, but is<br>
> always set to 0 instead. Not sure how hard it would be to fix that though (not<br>
> sure if there is anything in Qt5 that solves the<br>
> problem in a way that might<br>
> be back-portable).<br>
><br>
> Marijn<br>
><br>
> On Wednesday, February 15, 2012 02:29:35 PM BogDan wrote:<br>
>> Hi Chris,<br>
>> <br>
>><br>
>> >Hi BogDan,<br>
>> ><br>
>> >I think your approach is too restrictive for at least 2 reasons:<br>
>> ><br>
>> >1) If only QMainWindow is taken into account, it would be impossible to<br>
>> >create an options menu for, e.g., a QDialog descendant<br>
>><br>
>> You are right !<br>
>><br>
>> >2) I already coded a mechanism in the QML components for Android that<br>
>> >would allow to display an options menu in QML, too. It involves adding<br>
>> >QAction's to the QDeclarativeView (not via a QMenuBar).<br>
>><br>
>> I'll try to backport platform menu from Qt5 [1], this way you can set<br>
> the<br>
>> menu easily from QML and it will fix the first issue as well.<br>
>><br>
>><br>
>><br>
>> Cheers,<br>
>> BogDan.<br>
>><br>
>><br>
>> [1]<br>
>> <a href="http://qt.gitorious.org/qt/qtbase/blobs/master/src/widgets/kernel/qplatfor" target="_blank">http://qt.gitorious.org/qt/qtbase/blobs/master/src/widgets/kernel/qplatfor</a><br>
>> mmenu_qpa.h<br>
>><br>
>> >- Chris -<br>
>> ><br>
>> ><br>
>> >On Wed, Feb 15, 2012 at 11:23, BogDan <<a href="mailto:bog_dan_ro@yahoo.com">bog_dan_ro@yahoo.com</a>><br>
> wrote:<br>
>> ><br>
>> >Hello everyone,<br>
>> ><br>
>> >> First and foremost I'd like to thank you for your work !<br>
>> >><br>
>> >> I almost finish the review, I've done some trivial changes to<br>
> your<br>
>> >>code. I want to discuss with you a particular change which I'm<br>
> not very<br>
>> >>sure it's ok. It's about "prepareOptionsMenu"<br>
> which I'd like to simplify<br>
>> >>it a little bit.<br>
>> >><br>
>> >> The biggest change in that function is that<br>
> I suppose that *ONLY* a<br>
>> >>QMainWindow may have menus, and *ONLY* if that window is the active<br>
> one<br>
>> >>I'm going to show the menu. Of course I must fix the<br>
>> >>QApplication::activeWindow() issue first :) !<br>
>> >><br>
>> >><br>
>> >>Here is the new code:<br>
>> >><br>
>> >><br>
>> >>static jboolean prepareOptionsMenu(JNIEnv *env, jobject /*thiz*/,<br>
> jobject<br>
>> >>menu) {<br>
>> >> // remove all actions from the menu first<br>
>> >> env->CallVoidMethod(menu, s_menu_removeGroup, menuGroupId);<br>
>> >><br>
>> >> // if the main window is not the active one (e.g a dialog is<br>
>> >>displayed), don't show the menu ! const QMainWindow* window =<br>
>> >>qobject_cast<QMainWindow*>(QApplication::activeWindow()); if<br>
> (!window ||<br>
>> >>!window->menuBar())<br>
>><br>
>>> return JNI_FALSE;<br>
>> >><br>
>> >> QList<QAction*> actions =<br>
> window->menuBar()->actions();<br>
>> >><br>
>> >> // and add actions to menu<br>
>> >> foreach (QAction* action, actions)<br>
>> >> {<br>
>> >> QMenu *subMenu = action->menu();<br>
>> >> if (subMenu)<br>
>> >> {<br>
>> >> QString txt = action->text();<br>
>> >> jstring str =<br>
> env->NewString(reinterpret_cast<const<br>
>> >>jchar*>(txt.data()), txt.length()); jobject submenu =<br>
>> >>env->CallObjectMethod(menu, s_menu_addSubMenu, menuGroupId,<br>
> jint(-1),<br>
>> >>jint(0) /*order*/, str);<br>
> env->DeleteLocalRef(str);<br>
>> >><br>
>> >> foreach (QAction* subAction, subMenu->actions())<br>
>> >> addActionToMenu(env, submenu, subAction);<br>
>> >><br>
>> >> env->DeleteLocalRef(submenu);<br>
>> >> }<br>
>> >> else<br>
>> >> addActionToMenu(env, menu, action);<br>
>> >> }<br>
>> >> return JNI_TRUE;<br>
>> >>}<br>
>> >><br>
>> >><br>
>> >>Let me know if this approach is ok for you !<br>
>> >><br>
>> >><br>
>> >>Cheers,<br>
>> >>BogDan.<br>
> <br>
</div></div></blockquote></div><br>