Clicking the dock icon to show finder instead of show the app (Mac)



  • the default action of Clicking the app dock icon is to show the app,

    but in my application I want to show the finder. How could I achieve it?

    I make attempting in eventFilter() ,showEvent() and focusEvent(),

    but it seems it doesn't trigger any of those functions when I click the app icon.



  • So your application is going to be a finder launcher? Why don't you create a new process and show the finder, while hiding your window(s) (if they have to be shown only under certain circumstances)?



  • Not only a finder launcher, my app is still running and menu can still be clicked.
    My window is hidden, but even I create a new process of finder, the problem relies on how could I get the UI message of clicking dock icon.

    [quote author="fluca1978" date="1321860137"]So your application is going to be a finder launcher? Why don't you create a new process and show the finder, while hiding your window(s) (if they have to be shown only under certain circumstances)?[/quote]



  • I as a user would be seriously confused (at best) if clicking the dock icon of a certain application brought up the window of a completely different application.

    You should seriously consider a sane UI design!

    Luckily, I doubt that this can be achieved at all, as the Dock is managed by the OS and the dock icon is associated with your application, not another one.



  • [quote author="rigid" date="1321863188"]Not only a finder launcher, my app is still running and menu can still be clicked.
    My window is hidden, but even I create a new process of finder, the problem relies on how could I get the UI message of clicking dock icon.

    [/quote]

    As Volker said, this is not a good UI design. Anyway it could be that listening for the focus on your main window could do the trick: when your main window receives the focus it could open a new finder window. However, this assumes that the user does not dock your application at all during the life time.
    What really is your aim?



  • but dropbox do so, its mac version open sharefolder in finder when user've login and click on the dock icon.

    [quote author="Volker" date="1321881728"]I as a user would be seriously confused (at best) if clicking the dock icon of a certain application brought up the window of a completely different application.

    You should seriously consider a sane UI design!

    Luckily, I doubt that this can be achieved at all, as the Dock is managed by the OS and the dock icon is associated with your application, not another one.[/quote]

    but dropbox do so, its mac version open sharefolder in finder when user've login and click on the dock icon.



  • [quote author="fluca1978" date="1321882151"]
    [quote author="rigid" date="1321863188"]Not only a finder launcher, my app is still running and menu can still be clicked.
    My window is hidden, but even I create a new process of finder, the problem relies on how could I get the UI message of clicking dock icon.

    [/quote]

    As Volker said, this is not a good UI design. Anyway it could be that listening for the focus on your main window could do the trick: when your main window receives the focus it could open a new finder window. However, this assumes that the user does not dock your application at all during the life time.
    What really is your aim?

    [/quote]

    I want to open finder when user click on the dock icon(mac),
    it can simple call a command "open /dir/" in the code,
    but the importance relies on how could I capture the click action.

    I can't find out what's this message in qt,
    event can't find the event you said
    "when your main window receives the focus"

    I've try eventFilter() ,showEvent() and focusEvent(), doesn't work.

    is it in macEvent ( EventHandlerCallRef caller, EventRef event )?



  • who can tell me which event response to click on mac icon action?

    focusEvent() of mainwindow really dosen't work.



  • Please stop pushing your topic just after 6 hours. Everyone helping here is a volunteer. You're not going to make them eager to answer by grouching this fast. In case you have some new info, please use the edit button and add it to your last post if there haven't been any answers yet.

    And no, I do not have a solution for your problem. Depending on your Qt build, subclassing QApplication and reimplementing method macEventFilter (Carbon) or subclassing NSApplication (Cocoa) could be of help. I never did either one, though.



  • I found the solution. It needs to overwrite event() function in qappliation.
    and insert handling in

    @
    if(event->type() == QEvent::ApplicationActivate){

    }
    @

    Then another problem is that how could I Deactivate the program by code. I uses

    @
    QEvent* event = new QEvent(QEvent::ApplicationDeactivate);
    bool result = QApplication::sendEvent(QApplication::instance(), event);
    @

    this event is sent and received but it isn't really Deactivated.
    When I shift focus to another window using mouse, the program receive the message again and this time it really Deactivated.

    [EDIT: code formatting, please wrap in @-tags, Volker]



  • I'm not sure if it is possible at all to "give away" the application focus other than by closing the last window.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.