Implemented dialog framework.

Preferences is now a dialog.