[applet/{analog,digital}-clock] Use `onPressed: wasExpanded = ...` idiom
This is a common snippet of code in applets. It prevents applet from re-expanding again when user clicks on the compact representation when the applet is already expanded and located on a desktop containment.
See also: 79bcefdd
FIXED-IN: 5.24.7 5.25.4 5.26
While at it, I also cleaned up some code a bit; not even worth mentioning or cherry-picking.