Tuning optical properties of 2D semiconductors by strain and electrostatic gating