comparison base/ResourceFinder.cpp @ 982:f161ca450050

Use QStandardPaths::writableLocation(DataLocation) instead of synthesising path ourselves (hopefully fixing encoding difficulties on Windows)
author Chris Cannam
date Tue, 09 Sep 2014 20:37:07 +0100
parents 9a422d610058
children a8f91db36e9d
comparison
equal deleted inserted replaced
981:c6f2b93a7d52 982:f161ca450050
25 #include <QFileInfo> 25 #include <QFileInfo>
26 #include <QStringList> 26 #include <QStringList>
27 #include <QProcess> 27 #include <QProcess>
28 #include <QCoreApplication> 28 #include <QCoreApplication>
29 29
30 #if QT_VERSION >= 0x050000
31 #include <QStandardPaths>
32 #endif
33
30 #include <cstdlib> 34 #include <cstdlib>
31 #include <iostream> 35 #include <iostream>
32 36
33 /** 37 /**
34 Resource files may be found in three places: 38 Resource files may be found in three places:
89 } 93 }
90 94
91 QString 95 QString
92 ResourceFinder::getUserResourcePrefix() 96 ResourceFinder::getUserResourcePrefix()
93 { 97 {
98 #if QT_VERSION >= 0x050000
99 QString loc = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
100 return loc;
101 #else
94 #ifdef Q_OS_WIN32 102 #ifdef Q_OS_WIN32
103 // This does not work correctly for non-ASCII home directory names
95 char *homedrive = getenv("HOMEDRIVE"); 104 char *homedrive = getenv("HOMEDRIVE");
96 char *homepath = getenv("HOMEPATH"); 105 char *homepath = getenv("HOMEPATH");
97 QString home; 106 QString home;
98 if (homedrive && homepath) { 107 if (homedrive && homepath) {
99 home = QString("%1%2").arg(homedrive).arg(homepath); 108 home = QString("%1%2").arg(homedrive).arg(homepath);
112 #else 121 #else
113 return QString("%1/.local/share/%2") 122 return QString("%1/.local/share/%2")
114 .arg(home) 123 .arg(home)
115 .arg(qApp->applicationName()); 124 .arg(qApp->applicationName());
116 #endif 125 #endif
117 #endif 126 #endif
127 #endif
118 } 128 }
119 129
120 QStringList 130 QStringList
121 ResourceFinder::getResourcePrefixList() 131 ResourceFinder::getResourcePrefixList()
122 { 132 {