Change default save path to ~/Videos
ClosedPublic

Authored by ngraham on Oct 10 2017, 3:14 AM.

Details

Summary

BUG: 385367

Changed default save path to ~/Videos, which seems like a more humane starting location than /var/tmp.

Test Plan

Can't test; don't have any machines with optical drives. Would appreciate some rudimentary testing from anyone with appropriate hardware.

Diff Detail

Repository
R467 K3b
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
ngraham created this revision.Oct 10 2017, 3:14 AM
ngraham edited the summary of this revision. (Show Details)
ltoscano requested changes to this revision.Oct 10 2017, 6:59 AM
ltoscano added a subscriber: ltoscano.

The directory can be localized.
Use QStandardPaths and look for QStandardPaths::MoviesLocation; see how the "global paths KCM" in Plasma does it:

https://commits.kde.org/plasma-desktop?path=kcms/desktoppaths/globalpaths.cpp

This revision now requires changes to proceed.Oct 10 2017, 6:59 AM
ngraham updated this revision to Diff 20580.Oct 10 2017, 5:50 PM

Use QStandardPaths::MoviesLocation instead, to aid localizability

Please also note that the directory returned by QStandardPaths::writableLocation may not exist. This is a latent error also with /var/tmp, and it was working with the original value of "/tmp" before the change of https://commits.kde.org/k3b/3125c7cda1e54c1c425189a44303dc360038d777
Also KoZipStore.cpp should be fixed (and ported to QTemporaryFile, maybe in a separate change.

Side note: that patch was merged without a useful commit message and it's unclear its origin, but that's another story.

Good point; I'll add some smarter logic later today.

ngraham planned changes to this revision.Oct 10 2017, 7:07 PM

This may be a little beyond me. The coding style is a little weird here; it's all done in the header file. What's the right place to put the path-checking logic?

When you use that variable (exported through getVideoCdDestination) ensure that the directory exists.

Hi Nathaniel,

Sorry for my late response!

I didn't receive any notification emails about this code review, but my email address is lesliezhai@llvm.org.cn please commit the patch if Luigi gave LGTM :)

The coding style is a little weird here; it's all done in the header file. What's the right place to put the path-checking logic?

It is able to put it in the *constructor* of VideoCdRippingOptions

or

just following the C++11 style, still put

m_videocddestination = XXX; // with your logic

in the header file.

Hi Luigi,

and it was working with the original value of "/tmp" before the change of https://commits.kde.org/k3b/3125c7cda1e54c1c425189a44303dc360038d777

sorry, I just want to save this patch for Fedora packagers.

Regards,
Leslie Zhai

ngraham updated this revision to Diff 20663.Oct 13 2017, 3:46 AM

Move logic into constructor and handle the case where the user has deleted their Videos folder or made it read-only

I must emphasize that this is untested, as I have no CD drive.

Hi Nathaniel,

I must emphasize that this is untested, as I have no CD drive.

It is able to use CDEmu to simulate CD driver.

Regards,
Leslie Zhai

src/rip/k3bvideocdrippingoptions.h
29–30

The old init style could be deleted.

38
// To save variable videoPath
m_videocddestination = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
ngraham updated this revision to Diff 20908.Oct 17 2017, 2:46 PM

Update constructor syntax

ngraham marked an inline comment as done.Oct 17 2017, 2:46 PM
ngraham added inline comments.
src/rip/k3bvideocdrippingoptions.h
38

This was done on @ltoscano's advice, because it's possible (though unlikely) that the user has deleted their Videos folder.

lesliezhai added inline comments.Oct 18 2017, 2:31 AM
src/rip/k3bvideocdrippingoptions.h
38
m_videocddestination = QStandardPaths::writableLocation(QStandardPaths::MoviesLocation);
QFileInfo checkPath(m_videocddestination);
if (!checkPath.exists())
    m_videocddestination = QStandardPaths::writableLocation(QStandardPaths::HomeLocation); // but user has not deleted their $HOME folder.
ngraham added inline comments.Oct 18 2017, 3:36 PM
src/rip/k3bvideocdrippingoptions.h
38

I don't think it's possible for a user to delete their own home folder, which is why that's the fallback path.

ngraham updated this revision to Diff 21077.Oct 21 2017, 6:05 PM
ngraham marked 4 inline comments as done.

Saving a variable and a few lines of code at @lesliezhai's advice

Thanks, now I see what you mean. Changed.

@ltoscano, are you good with this now?

ltoscano resigned from this revision.Oct 24 2017, 2:58 PM
This revision was automatically updated to reflect the committed changes.