Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / qt / 2007-09

Please add qt_mac_set_dock_menu

8 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Felipe Monteiro de Carvalho

Hello,

I am almost finishing the first native release of the magnifier for Mac OS X =) and with lcl-qt

One thing I noticed however is that the dock menu doesn't respond to user commands, and because Mac OS X assigns that menu whether I want it or not, it would be nice to make it actually work. And to do that it's necessary to use a platform specific function present in Qt and called qt_mac_set_dock_menu

I couldn't find documentation for this functions (where are the docs for loose functions??), so I don't know since when it is available. If it's available at least since 4.2, it would be nice to have it added =)

No hurry, you can wait for more requests before adding this. I just thougth I would comment this here so I don't forget about this.

I asked on a Qt forum but I couldn't find any other way to make the dock menu respond to user commands. (There is a Quit menu there, so the user should expect to see the app quit when he presses it).

http://doc.trolltech.com/qq/qq18-macfeatures.html#newlooks

"It has always been possible to change the icon on the dock by using QApplication::setIcon(). It is now also possible to set a QMenu for the dock icon as well. This is available through a C++ function, but is not in a header, so you need to extern it yourself.

    QMenu *menu = new QMenu;
    // Add actions to the menu
    // Connect them to slots
    ...
    extern void qt_mac_set_dock_menu(QMenu *);
    qt_mac_set_dock_menu(menu);"

thanks,

Felipe Monteiro de Carvalho
Den Jean
to Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho wrote 5 lines
Hello, it's necessary to use a platform specific function present in Qt and called qt_mac_set_dock_menu I couldn't find documentation for this functions (where are the docs

The first google result is the doc:
http://doc.trolltech.com/4.3/exportedfunctions.html

Show quoted text 24 lines
for loose functions??), so I don't know since when it is available. If it's available at least since 4.2, it would be nice to have it added =) No hurry, you can wait for more requests before adding this. I just thougth I would comment this here so I don't forget about this. I asked on a Qt forum but I couldn't find any other way to make the dock menu respond to user commands. (There is a Quit menu there, so the user should expect to see the app quit when he presses it). http://doc.trolltech.com/qq/qq18-macfeatures.html#newlooks "It has always been possible to change the icon on the dock by using QApplication::setIcon(). It is now also possible to set a QMenu for the dock icon as well. This is available through a C++ function, but is not in a header, so you need to extern it yourself. QMenu *menu = new QMenu; // Add actions to the menu // Connect them to slots ... extern void qt_mac_set_dock_menu(QMenu *); qt_mac_set_dock_menu(menu);"

Now I know how you know the function name without googling :-) This also shows the use: declare it (not present in header) and use it. Just do the same in your in code like this:

procedure qt_x11_wait_for_window_manager(widget : QWidgetH); cdecl;
external 'libQtGui.so' name '_Z30qt_x11_wait_for_window_managerP7QWidget';

I used an X11 function as I cannot test an Mac only function.

My generator parses classes and their methods. It does not expect flat methods like these. So this would be some manual work. This will also remove the name mangling.

Sample exercise:
==========

somewhere.h:
// Export without mangling (different name, otherwise compiler got crazy,camel
casing in pascal makes it readable again)
C_EXPORT void qtx11waitforwindowmanager(QWidgetH handle);
somewhere.cpp:
// declare, because not present in header
void qt_x11_wait_for_window_manager(QWidget *widget);
// implement
void qtx11waitforwindowmanager(QWidgetH handle) {
  qt_x11_wait_for_window_manager((QWidget *)handle);
}
qt4.pas: (camel casing :-)
procedure QtX11WaitForWindowManager(widget : QWidgetH); cdecl; external QtIntf
name 'qtx11waitforwindowmanager';

I will see when I have time for your mac function and where I can put that function.

regards,

Den Jean

Felipe Monteiro de Carvalho
to Den Jean: The first google result is the doc: http://doc.trolltech.com/4.3/exportedfunctions.html…
Den Jean wrote
procedure qt_x11_wait_for_window_manager(widget : QWidgetH); cdecl; external 'libQtGui.so' name '_Z30qt_x11_wait_for_window_managerP7QWidget';

That's a pretty simple solution! Somehow I didn't think about it ...

But how do you know which name mangling is used?

If it's less work for you we could just say that whoever needs the functions can declare them manually. I would just document somewhere about this. Maybe on the wiki.

thanks,

Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho
to Den Jean

There is a typo:

felipe2:~/Programas/qt4pas-V1.51_Qt4.3.1 felipemonteirodecarvalho$ ./compile_lib_mac.sh
qtpas.cpp:287: error: expected unqualified-id before '{' token

A ; at the end of the c function. I make that mistake all the time when programming in c =))

Felipe Monteiro de Carvalho
Felipe Monteiro de Carvalho
to Felipe Monteiro de Carvalho

thanks, the function seams to work fine .... but it doesn't do what I was expecting =) It just adds extra menu options on the Dock menu ... it doesn't actually makes the existing options (automatically added by Mac OS X) work properly.

Felipe Monteiro de Carvalho