VioletGiraffe / file-commander

Cross-platform Total Commander-like orthodox file manager for Windows, Mac and Linux
Apache License 2.0
379 stars 56 forks source link

Support Cmd+Backspace shortcut for deleting items without a prompt #81

Closed VioletGiraffe closed 6 years ago

antis81 commented 9 years ago

Does the dialog appear by itself? Then it can be easily turned off by the user in the OSX system preferences.

IIRC the "Do you want to move file to trash?" prompt is enabled/disabled via a "system setting" for Finder. I did some investigation and am not totally sure, but you should have a look into the file ~/Library/Preferences/com.apple.finder.plist. The file contains binary data and if you want to open it, you need a special plist editor (builtin on OSX, but available for windows as well).

This should be respected here to preserve native behaviour. The QSettings class can handle plist files. Something like this should go fine:

// note: this is an example, not a final solution!
// Maybe this flag can be queried directly via a Qt function. Didn't find that so far.
static bool APPLICATION::showDeletePrompt() {
#ifdef Q_OS_MAC
  // TODO: need to check syntax
  // create a settings file with user scope and native format (plist for mac)
  QSettings settings(QStringLiteral("apple.com"), QStringLiteral("finder"));
  return settings.value(QStringLiteral("showDeleteFileDialog")).toBool();
#endif

// TODO: implement for windows and linux
return true;
VioletGiraffe commented 9 years ago

The deletion prompt dialog is my own and is displayed every time you want to delete something.

antis81 commented 9 years ago

The deletion prompt dialog is my own and is displayed every time you want to delete something.

Alright, then it's simply a task of adding a flag to CSettings and a platform specific shortcut. Think that's ok, though I'd prefer system dialogs, if available.

VioletGiraffe commented 9 years ago

I use the system deletion API (hence the system dialog) on Windows, but I don't know the first thing about OS X APIs. If you want to implement the files deletion via native API - be my guest! :)

antis81 commented 9 years ago

Hm ... Qt doesn't provide a QFile::moveToTrash method so far. So the first thing I did was reviving a very old issue dating back to 2006 (Wowsa!). If interested, see here.

Anyway, there's implementations for XDG (Linux/FreeBSD and others) and OSX floating around the web. As I'm running a Linux, I can help with that part. The best I could find so far is located on stackoverflow. Another good information resource is the send2trash Python module.

VioletGiraffe commented 9 years ago

Well done, upvoted the issue.