mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-12 16:23:07 -07:00
Mac OS: Properly detect "Downloads" folder
This commit is contained in:
parent
380989d808
commit
b0d6f3f9bf
1 changed files with 13 additions and 2 deletions
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…
Add table
Add a link
Reference in a new issue