Bug 503821

Summary: "Screenshot of Selection": Can't save screenshots
Product: [Applications] kate Reporter: madness742
Component: generalAssignee: KWrite Developers <kwrite-bugs-null>
Status: RESOLVED FIXED    
Severity: normal CC: waqar.17a
Priority: NOR    
Version First Reported In: 25.04.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description madness742 2025-05-06 04:04:45 UTC
SUMMARY
If you try to save a screenshot of a selection, it won’t work. Depending on the filename you use, you’ll see a different error message.

STEPS TO REPRODUCE
1. Select 1 or more lines.
2. Right click and select "Take Screenshot of Selection".
3. Click on "Save".
4. Type a name and hit "Save".

OBSERVED RESULT
Screenshot will not be saved, and depending on the filename you'll get a different error.

"screenshot" <-- Screenshot saving failed: Unsupported image format
"screenshot.jpg" <-- Screenshot saving failed: Unknown error
"screenshot.png" <-- Screenshot saving failed: Unknown error

EXPECTED RESULT
The screenshot should be saved to the drive.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Fedora Linux 42
KDE Plasma Version: 6.3.4
KDE Frameworks Version: 6.13.0
Qt Version: 6.9.0
Comment 1 Waqar Ahmed 2025-05-06 04:55:20 UTC
Git commit c74e5bedde4b8de0ae4a7b23175ddf0bf76a1da5 by Waqar Ahmed.
Committed on 06/05/2025 at 04:54.
Pushed by waqar into branch 'master'.

Fix error logic

Check whether write succeeded instead of checking for errorString.

QImageWriter's error enum is broken, it is always UnknownError if there
was no error thus there is always an errorString.

M  +1    -2    src/view/screenshotdialog.cpp

https://invent.kde.org/frameworks/ktexteditor/-/commit/c74e5bedde4b8de0ae4a7b23175ddf0bf76a1da5
Comment 2 Waqar Ahmed 2025-05-06 04:57:00 UTC
> "screenshot.jpg" <-- Screenshot saving failed: Unknown error
> "screenshot.png" <-- Screenshot saving failed: Unknown error

In the above two cases, the file is actually created and saved correctly in my testing. The error is bogus, you can ignore that.
Comment 3 madness742 2025-05-06 06:18:36 UTC
Thank you for the quick fix. 

Please let me know if I should post this somewhere else, but I wanted to leave a small suggestion. It would be great if the "Save" dialogue has the same behaviour as Spectacle. As in available/default File Types (PNG Image) and pre-filled name (Screenshot_$CurrentTimestamp). It makes for a nice coherent experience. :)