First-principles study of photoinduced electron-transfer dynamics in a Mg–porphyrin–quinone complex