>>>>> "John" == John Levon <[EMAIL PROTECTED]> writes:

John> On Wed, Jul 02, 2003 at 10:44:48AM +0200, Jean-Marc Lasgouttes
John> wrote:
>> There is a nice problem with LyX on Qt/Mac, also. In their infinite
>> wisdom, the Qt/Mac coders decided that it would be a good idea to
>> find all the items in menus that look like "Preferences",
>> "Settings", "About LyX", remove them from their respective menus
>> and put them in the application menu.

John> I'm gobsmacked (to the extent I think you are kidding me a
John> little)...

You will find the information somewhere on this page:
http://doc.trolltech.com/3.1/qmenubar.html

I append also a part of the ugly code that does this thing for your
enjoyment. 

>> I can think of some ways to work around this nonsense, but It would
>> be much better if trolltech had plans to improve the situation in
>> later

John> I haven't been following if this has been reported or not ?

I have seen references to that on qt-interest, but no real answer from
trolltech. It may be worth asking for a way of doing such things
properly.

BTW, ronald, you may want for now to recompile qt with
QMAC_QMENUBAR_NO_MERGE defined (I do not know where, unfortunately).
It would be also useful to build a static version of libqt and use
that.

JMarc

PS: here is the code. I am not sure how it works really. I can send
you the whole qmenubar_map.cpp if you want. It looks like someone had
only 10 minutes to get the whole thing to work...


#if !defined(QMAC_QMENUBAR_NO_MERGE)
uint QMenuBar::isCommand(QMenuItem *it, bool just_check)
{
    if(it->popup() || it->custom() || it->isSeparator())
        return 0;

    QString t = it->text().lower();
    for(int w = 0; (w=t.find('&', w)) != -1; )
        t.remove(w, 1);
    int st = t.findRev('\t');
    if(st != -1)
        t.remove(st, t.length()-st);
    t.replace(QRegExp("\\.*$"), ""); //no ellipses
    //now the fun part
    uint ret = 0;
    if(t.find(tr("About").lower(), 0, FALSE) == 0) {
        if(t.find(QRegExp("qt$", FALSE)) == -1)
            ret = kHICommandAbout;
        else
            ret = 'CUTE';
    } else if(t.find(tr("Config").lower(), 0, FALSE) == 0 || 
t.find(tr("Preference").lower(), 0, FALSE) == 0 ||
              t.find(tr("Options").lower(), 0, FALSE) == 0 || 
t.find(tr("Setting").lower(), 0, FALSE) == 0 ||
              t.find(tr("Setup").lower(), 0, FALSE) == 0 ) {
        ret = kHICommandPreferences;
    } else if(t.find(tr("Quit").lower(), 0, FALSE) == 0 || t.find(tr("Exit").lower(), 
0, FALSE) == 0) {
        ret = kHICommandQuit;
    }
    //shall we?
    if(just_check) {
        //do nothing, we already checked
    } else if(ret && activeMenuBar &&
              (!activeMenuBar->mac_d->commands || 
!activeMenuBar->mac_d->commands->find(ret))) {
        if(ret == kHICommandAbout || ret == 'CUTE') {
            if(activeMenuBar->mac_d->apple_menu) {
                QString text = it->text();
                for(int w = 0; (w=text.find('&', w)) != -1; )
                    text.remove(w, 1);
                int st = text.findRev('\t');
                if(st != -1)
                    text.remove(st, text.length()-st);
                text.replace(QRegExp("\\.*$"), ""); //no ellipses
#ifdef Q_WS_MACX
                if(ret == kHICommandAbout && text.lower() == tr("About").lower()) {
                    ProcessSerialNumber psn;
                    if(GetCurrentProcess(&psn) == noErr) {
                        CFStringRef cfstr;
                        CopyProcessName(&psn, &cfstr);
                        text += " " + cfstring2qstring(cfstr);
                    } else {
                        QString prog = qApp->argv()[0];
                        text += " " + prog.section('/', -1, -1);;
                    }
                }
#endif
                CFStringRef cfref;
                no_ampersands(text, &cfref);
                InsertMenuItemTextWithCFString(activeMenuBar->mac_d->apple_menu,
                                               cfref, activeMenuBar->mac_d->in_apple++,
                                               kMenuItemAttrAutoRepeat, ret);
            }
        }
        EnableMenuCommand(0, ret);
    } else {
        ret = 0;
    }
    return ret;
}
#endif

Reply via email to