Look at the power source switching in the Uno schematic between USB and the dc barrel jack, it does exactly what describe.