comparison base/ResourceFinder.cpp @ 1398:e1926cba940c

Support pre-5.4 Qt builds. Also, don't use SVDEBUG in here, because it depends on this class!
author Chris Cannam
date Mon, 06 Mar 2017 09:34:09 +0000
parents 8f076d02569a
children 5ac102155409
comparison
equal deleted inserted replaced
1397:b0533d195c83 1398:e1926cba940c
131 cerr << "ERROR: Can't use ResourceFinder before setting application name" << endl; 131 cerr << "ERROR: Can't use ResourceFinder before setting application name" << endl;
132 throw std::logic_error("Can't use ResourceFinder before setting application name"); 132 throw std::logic_error("Can't use ResourceFinder before setting application name");
133 } 133 }
134 134
135 #if QT_VERSION >= 0x050000 135 #if QT_VERSION >= 0x050000
136
136 // This is expected to be much more reliable than 137 // This is expected to be much more reliable than
137 // getOldStyleUserResourcePrefix(), but it returns a different 138 // getOldStyleUserResourcePrefix(), but it returns a different
138 // directory because it includes the organisation name (which is 139 // directory because it includes the organisation name (which is
139 // fair enough). Hence migrateOldStyleResources() which moves 140 // fair enough). Hence migrateOldStyleResources() which moves
140 // across any resources found in the old-style path the first time 141 // across any resources found in the old-style path the first time
141 // we look for the new-style one 142 // we look for the new-style one
143 #if QT_VERSION >= 0x050400
142 return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); 144 return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
143 #else 145 #else
146 cerr << "WARNING: ResourceFinder::getOldStyleUserResourcePrefix: Building with older version of Qt (pre 5.4), resource location may be incompatible with future versions" << endl;
147 return QStandardPaths::writableLocation(QStandardPaths::DataLocation);
148 #endif
149
150 #else
151 cerr << "WARNING: ResourceFinder::getOldStyleUserResourcePrefix: Building with very old version of Qt (pre 5.0?), resource location may be incompatible with future versions" << endl;
144 return getOldStyleUserResourcePrefix(); 152 return getOldStyleUserResourcePrefix();
145 #endif 153 #endif
146 } 154 }
147 155
148 static void 156 static void
237 for (QStringList::const_iterator i = prefixes.begin(); 245 for (QStringList::const_iterator i = prefixes.begin();
238 i != prefixes.end(); ++i) { 246 i != prefixes.end(); ++i) {
239 247
240 QString prefix = *i; 248 QString prefix = *i;
241 249
242 SVDEBUG << "ResourceFinder::getResourcePath: Looking up file \"" << fileName << "\" for category \"" << resourceCat << "\" in prefix \"" << prefix << "\"" << endl; 250 // cerr << "ResourceFinder::getResourcePath: Looking up file \"" << fileName << "\" for category \"" << resourceCat << "\" in prefix \"" << prefix << "\"" << endl;
243 251
244 QString path = 252 QString path =
245 QString("%1%2/%3").arg(prefix).arg(resourceCat).arg(fileName); 253 QString("%1%2/%3").arg(prefix).arg(resourceCat).arg(fileName);
246 if (QFileInfo(path).exists() && QFileInfo(path).isReadable()) { 254 if (QFileInfo(path).exists() && QFileInfo(path).isReadable()) {
247 cerr << "Found it!" << endl; 255 // cerr << "Found it!" << endl;
248 return path; 256 return path;
249 } 257 }
250 } 258 }
251 259
252 return ""; 260 return "";