Use a more declarative way to deal with the current file
Differential Revision: https://phabricator.kde.org/D15033