From b0d6f3f9bfc5c80a4cfb0b49d3d14ec814c24626 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=A3=CF=84=CE=AD=CF=86=CE=B1=CE=BD=CE=BF=CF=82=20=CE=91?= =?UTF-8?q?=CE=BD=CF=84=CE=AC=CF=81=CE=B7=CF=82?= Date: Fri, 7 Oct 2011 19:08:17 +0300 Subject: [PATCH] Mac OS: Properly detect "Downloads" folder --- src/misc.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/misc.cpp b/src/misc.cpp index b5bd2df98..4560a57d5 100644 --- a/src/misc.cpp +++ b/src/misc.cpp @@ -199,8 +199,19 @@ QString misc::QDesktopServicesDownloadLocation() { #endif #ifdef Q_WS_MAC - // TODO: Use NSSearchPathForDirectoriesInDomains(NSDownloadsDirectory, NSUserDomainMask, YES) - // See http://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Miscellaneous/Foundation_Functions/Reference/reference.html + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationSupportDirectory, NSUserDomainMask, YES); + 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 // Fallback