Fixes #3918 - Adds topological sort over plugin dependencies when using "Activate all" button

WIP This already works, but needs some cleanup before merge.

Fixes #3918