Use projectName() in stead of projectFileName() to check if we have an active project.
After recent changes projectFileName() returns an empty string in some situations even if we have a valid project (maybe if you do not have a .kateproject file?).