Fix counting up placeholder (%Nd)
ClosedPublic

Authored by davidre on Jun 27 2019, 8:16 AM.

Details

Summary

The change from QString to Qurl in 0a1f081ebe75eaf25a1142e5efd00cb2354e35fe broke it.

Test Plan

Press save button two times

Diff Detail

Repository
R166 Spectacle
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
davidre created this revision.Jun 27 2019, 8:16 AM
Restricted Application added a project: Spectacle. · View Herald TranscriptJun 27 2019, 8:16 AM
davidre requested review of this revision.Jun 27 2019, 8:16 AM

The summary doesn't really match what this is doing?

ExortManager::defaultSaveLocation() is used in formatFilename() where the QString is used to create a QDir from it. In formatFilename() the placeholders are replaced by the respective values. For doing the counting of filenames we check if their are already files in the directory we save to that look like the current filename format. Because toString() includes the protocol this didn't work. If you set your filename template to image%1d.png and press save twice these are the resulting filenames:

  • Without this patch: image1.png, image1-1.png (Because the lookup didn't work and to avoid overwriting a file a "-1" is appended)
  • WIth this patch image1.png, image2.png
broulik accepted this revision.Jun 27 2019, 12:40 PM

Patch makes sense either way. Also fixes Spectacle creating a folder named file: in my home every time I take a screenshot.

This revision is now accepted and ready to land.Jun 27 2019, 12:40 PM
This revision was automatically updated to reflect the committed changes.