Present error dialog when user tries to create directory named "." or ".."
ClosedPublic

Authored by tmarshall on Jun 30 2018, 1:27 AM.

Details

Summary

BUG: 387449

In Dolphin, when a user tries to create a folder named "." or "..", they are presented with a dialog that informs them that since the folder name they entered begins with a ".", the folder they are about to create will be hidden. This is, of course, misleading. This patch instead presents them with a similar dialog, informing them of the error and asking them for a new name.

Before:

After:

Diff Detail

Repository
R241 KIO
Lint
Lint Skipped
Unit
Unit Tests Skipped
tmarshall created this revision.Jun 30 2018, 1:27 AM
Restricted Application added a project: Frameworks. · View Herald TranscriptJun 30 2018, 1:27 AM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
tmarshall requested review of this revision.Jun 30 2018, 1:27 AM
ngraham added a subscriber: ngraham.
ngraham added inline comments.
src/filewidgets/knewfilemenu.cpp
859

has give -> has given

874

This message might be a little bit too terse. How about something that helps explain the reason as well, like this?

"<name>" has a special meaning for the operating system and cannot be used as the name for a folder.

tmarshall updated this revision to Diff 36952.EditedJun 30 2018, 3:13 PM

Fixed a typo in the comment and improved the wording of the error message.

New:

bruns added a subscriber: bruns.Jun 30 2018, 3:14 PM
bruns added inline comments.
src/filewidgets/knewfilemenu.cpp
873

Should be QMessageBox::Error in this case

874

Folder "<name> could not be created:
"<name>" is reserved for use by the operating system.

We should probably use an error message similar to the one returned from the KIO job in case something goes wrong.

bruns added inline comments.Jun 30 2018, 3:16 PM
src/filewidgets/knewfilemenu.cpp
874

... and cannot be used as the name for a folder.

or for anything else.

tmarshall updated this revision to Diff 36954.Jun 30 2018, 3:21 PM
tmarshall marked 2 inline comments as done.
tmarshall added a subscriber: tmarshall.

Changed QMessageBox::Warning to QMessageBox::Critical and updated the error message.

New:

tmarshall marked an inline comment as done.Jun 30 2018, 3:24 PM
tmarshall added inline comments.
src/filewidgets/knewfilemenu.cpp
873

I get newfilemenu.cpp:873:74: error: ‘Error’ is not a member of ‘QMessageBox’

QMessageBox::Critical seems to work though.

ngraham accepted this revision.Jun 30 2018, 3:55 PM

Nice, I think this is looking great. +1 on the latest wording. A lovely first patch!

To land it for you, we'll need your full name and email address, so it would be great if you could provide that now. In the future, if you submit your patch using arc (see https://community.kde.org/Infrastructure/Phabricator#Using_Arcanist_to_post_patches) this will happen automatically via the git authorship information, so we won't have to bug you.

Any comments from the Frameworks folks?

src/filewidgets/knewfilemenu.cpp
873

Correct: QMessageBox::Error does not exist; it's QMessageBox::Critical. See https://doc.qt.io/qt-5/qmessagebox.html#Icon-enum

This revision is now accepted and ready to land.Jun 30 2018, 3:55 PM

How am I to provide my name and email? Just in a comment?

Hmm, shouldn't this check be at the kio_file level @dfaure ?
If we put it here, it will still fail when you try to create a folder named "." not by using the knewfilemenu in dolphin.

@elvisangelaccio The check has to come before the check for name.startsWith('.') because that's what launches the "The name <name> starts with a ." dialog.

cfeck added a subscriber: cfeck.Jul 1 2018, 3:33 AM

I think the comment can be omitted. It doesn't add information to the code.

@ngraham

Name: Thomas Marshall
Email: tmarshall7997@gmail.com

dfaure added a comment.Jul 1 2018, 7:04 PM

Well, it makes sense for this check to be at the GUI level, the user interaction can be better adapted then, as in this patch.

KIO::mkpath("/home/dfaure/tmp/.") should at least not warn or error in any way IMHO.

(btw mkdir of such a path, on the command line, always fails: either the tmp dir exists and it says "already exists", or it doesn't exist and it can't create the parent dir first)

elvisangelaccio requested changes to this revision.Jul 1 2018, 8:14 PM
elvisangelaccio added inline comments.
src/filewidgets/knewfilemenu.cpp
860 ↗(On Diff #36954)

Please use QLatin1String here, which is faster for string comparisons.

874 ↗(On Diff #36954)

Please use semantic markup here: https://api.kde.org/frameworks/ki18n/html/prg_guide.html#kuit_markup

tl;dr use <filename>%1</filename> instead of \"%1\" and <nl/> instead of \n

876 ↗(On Diff #36954)

Please use QString() here

884 ↗(On Diff #36954)

m_text = QString(), like we already do in _k_slotAbortDialog().

This revision now requires changes to proceed.Jul 1 2018, 8:14 PM

@tmarshall, any update on this?

Sorry for the delay @ngraham . I've been traveling. I'll have these changes complete by the end of today.

Thanks for the update!

tmarshall updated this revision to Diff 38050.Jul 19 2018, 4:49 AM
tmarshall marked 8 inline comments as done.

I've made the requested changes.

elvisangelaccio accepted this revision.Jul 28 2018, 3:37 PM
This revision is now accepted and ready to land.Jul 28 2018, 3:37 PM

@tmarshall Do you have commit access?

@tmarshall Do you have commit access?

I do not.

This revision was automatically updated to reflect the committed changes.