def METHOD_NAME(self, state):
    if state == Qt.ApplicationActive:
        # On macOS, when the app is hidden, there will be an icon on the
        # macOS dock, if user click the dock, we should activate the app window.
        # For other platforms(Win32/Linux), the dock icon is not visible if
        # the window is hidden/closed.
        #
        # When the state will be changed to QApplicationActive?
        # * the dock icon is clicked (on macOS)
        # * the Qt.Tool widget got focus (on macOS and Linux)
        # * the Qt.Window widget got focus (on Linux)
        if IS_MACOS:
            self._app.show()
            self._app.activateWindow()
    elif state == Qt.ApplicationInactive:
        # when app window is not the top window, it changes to inactive
        if self._toggle_app_action is not None:
            self._toggle_app_action.setText(TOGGLE_APP_TEXT[0])