Browse Source

Mac OS: Properly detect "Downloads" folder

adaptive-webui-19844
Στέφανος Αντάρης 13 years ago committed by Christophe Dumez
parent
commit
b0d6f3f9bf
  1. 15
      src/misc.cpp

15
src/misc.cpp

@ -199,8 +199,19 @@ QString misc::QDesktopServicesDownloadLocation() {
#endif #endif
#ifdef Q_WS_MAC #ifdef Q_WS_MAC
// TODO: Use NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES) NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES);
// See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html NSString *applicationDirectory = [paths objectAtIndex:0];
NSRange range;
range.location = 0;
range.length = [applicationDirectory length];
QString path(range.length, QChar(0));
unichar *chars = new unichar[range.location];
[nsstr getCharacters:chars range:range];
QString path = QString::fromUtf16(chars, range.length);
delete chars;
path += QLatin1Char('/') + qApp->applicationName();
return path;
#endif #endif
// Fallback // Fallback

Loading…
Cancel
Save