Better password prompt implementation [WIP]

Fixes #3215. This is a work in progress and I'd therefore like to hear your feedback.

- [ ] Improve the localization handling.
- [ ] Decrease 'flicker' effect after entering a valid password and another document was already open.
- [ ] Code improvements and review.