Fix heading level line break handling with Qt 6.3
The old code was assuming it can read the previous heading level after applying the current key press, which doesn't need to be the case when enter/return is pressed. This seems to have worked due to the base implementation happening to preserve the heading level, which isn't the case in Qt 6.3 anymore. So, read the old heading level early enough, and set the desired new one in all cases.