Jean-Marc Lasgouttes a écrit :
"Abdel" == Abdel <[EMAIL PROTECTED]> writes:
Abdel> OK, thanks. My main problem is that while a MenuItem is of
Abdel> Submenu kind, sometimes (depends on the document you load and
Abdel> the time of day) its associated submenu is empty. This happens
Abdel> only for the Navigate menu, others works fine.
I think this is related to your next question. Menu objects are
"uninstantiated" menus, and expand should be called on the one you want to
open (File, Edit...) before doing anything else. I agree this is not a
very good API (instantiated menus should be a different C++ class),
but I do not think it is a big problem, actually.
Well, my problem then is that I don't understand the API :-(
Abdel> In my opinion we should just be able to use getMenu() without
Abdel> having to expand it. In this case MenuVackend member menulist_
Abdel> should of course be mutable (because getMenu is a const
Abdel> function). So the MenuBackend should make sure that the menu
Abdel> you ask for is always up to date.
I don't like mutable variables :)
The question is probably why you want to get these menus. Are you
trying to use MenuBackend to build your dynamic ToC stuff?
No, I just wanted this Navigate menu to work, that's all.
In this
case I think you are using the wrong approach. You should take the
horrible code from MenuBackend and merge it into toc.C. This code
should return the ToC as a tree (not a list of strings) and
MenuBackend and your code should use that directly.
Well I have already written my own tree generation code in QTocDialog.C.
I have just compared my code with the code from the MenuBackend and it
is indeed similar (I prefer mine ;-)). I think I'll just give up on the
Navigate menu and put a popup menu in one toolbar instead. The first
Item in this menu would be to open the full blown TocDialog, the rest
would be the standard navigate stuff.
Abdel> Another problem that I have is with the MenuItem::func()
Abdel> member. I store it this way in a QLAction which is a lyx
Abdel> tailored QAction: QLAction * action = new
Abdel> QLAction(*(owner_->view()), label, m->func()); So the
Abdel> FuncRequest is stored in the QLAction and is called when you
Abdel> click on the corresponding MenuItem. The problem is that this
Abdel> make lyx crashing for some MenuItem randomly (not all). It
Abdel> seems that this FuncRequest is not constant for a given
Abdel> MenuItem... weird.
I'd have to see the crash.
I'll try to work on that next week-end.
Abdel> My idea is that in the future, maybe for 1.5, there should be a
Abdel> unique configuration file which will describe all available
Abdel> FuncRequests, together with associated label, icon, tooltip,
Abdel> number of argument (if any), etc. All these will be converted
Abdel> into QLAction. These QLAction would then be available as
Abdel> MenuItem or Toolbar button indifferently.
I am not sure we want that, in particular for labels. Do we really
want to enforce the way the menu appears?
It would still be defined in a configuration file (the FuncRequest one).
But I think this is not really important. In any case we could still
provide a way to change the labels if really needed (ex: right-clicking
on a menuItem could allow changing its label, shortcut, etc).
Abdel> I realize now that my explanation is a bit abstract so I attach
Abdel> my ports of QView, QLMenubar and QLPopupmenu to this mail
Abdel> (QLAction is defined in QView.[hC]
Abdel> Sorry Jean-Marc, you asked for it ;-)
No problem.
Thanks,
Abdel.
JMarc