Mercurial > hg > svcore
comparison base/ResourceFinder.cpp @ 1251:67aee57e32c8 3.0-integration
Merge from branch piper
author | Chris Cannam |
---|---|
date | Fri, 04 Nov 2016 14:57:03 +0000 |
parents | 8f076d02569a |
children | e1926cba940c |
comparison
equal
deleted
inserted
replaced
1241:c6bdf247016a | 1251:67aee57e32c8 |
---|---|
31 #include <QStandardPaths> | 31 #include <QStandardPaths> |
32 #endif | 32 #endif |
33 | 33 |
34 #include <cstdlib> | 34 #include <cstdlib> |
35 #include <iostream> | 35 #include <iostream> |
36 #include <stdexcept> | |
36 | 37 |
37 /** | 38 /** |
38 Resource files may be found in three places: | 39 Resource files may be found in three places: |
39 | 40 |
40 * Bundled into the application as Qt4 resources. These may be | 41 * Bundled into the application as Qt4 resources. These may be |
124 } | 125 } |
125 | 126 |
126 static QString | 127 static QString |
127 getNewStyleUserResourcePrefix() | 128 getNewStyleUserResourcePrefix() |
128 { | 129 { |
130 if (qApp->applicationName() == "") { | |
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"); | |
133 } | |
134 | |
129 #if QT_VERSION >= 0x050000 | 135 #if QT_VERSION >= 0x050000 |
130 // This is expected to be much more reliable than | 136 // This is expected to be much more reliable than |
131 // getOldStyleUserResourcePrefix(), but it returns a different | 137 // getOldStyleUserResourcePrefix(), but it returns a different |
132 // directory because it includes the organisation name (which is | 138 // directory because it includes the organisation name (which is |
133 // fair enough). Hence migrateOldStyleResources() which moves | 139 // fair enough). Hence migrateOldStyleResources() which moves |
134 // across any resources found in the old-style path the first time | 140 // across any resources found in the old-style path the first time |
135 // we look for the new-style one | 141 // we look for the new-style one |
136 return QStandardPaths::writableLocation(QStandardPaths::DataLocation); | 142 return QStandardPaths::writableLocation(QStandardPaths::AppDataLocation); |
137 #else | 143 #else |
138 return getOldStyleUserResourcePrefix(); | 144 return getOldStyleUserResourcePrefix(); |
139 #endif | 145 #endif |
140 } | 146 } |
141 | 147 |