This has been imported and refactored in KCMUtils. See kcmutils!121 (merged)
Task: https://phabricator.kde.org/T12150