Simultaneous modelocking and Q-switching of a Co:MgF2 laser by loss-modulation frequency detuning