Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Clicking the dock icon to show finder instead of show the app (Mac)
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved General and Desktop
11 Posts 3 Posters 6.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    rigid
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      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)?

      1 Reply Last reply
      0
      • R Offline
        R Offline
        rigid
        wrote on last edited by
        #3

        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]

        1 Reply Last reply
        0
        • G Offline
          G Offline
          goetz
          wrote on last edited by
          #4

          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.

          http://www.catb.org/~esr/faqs/smart-questions.html

          1 Reply Last reply
          0
          • F Offline
            F Offline
            fluca1978
            wrote on last edited by
            #5

            [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?

            1 Reply Last reply
            0
            • R Offline
              R Offline
              rigid
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • R Offline
                R Offline
                rigid
                wrote on last edited by
                #7

                [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 )?

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  rigid
                  wrote on last edited by
                  #8

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

                  focusEvent() of mainwindow really dosen't work.

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    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.

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • R Offline
                      R Offline
                      rigid
                      wrote on last edited by
                      #10

                      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]

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

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

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved