Remove ConfigFile::locateConfigFile()
Needed adjustments to support the config suffix feature. Since it is only used by videodownloader it can be dropped.
This commit is contained in:
parent
5cb0d801ba
commit
1f08721dda
|
@ -298,63 +298,4 @@ bool hasCoreApp()
|
|||
}
|
||||
} // namespace ApplicationInstances
|
||||
|
||||
/*!
|
||||
* \brief Provides convenience functions for handling config files.
|
||||
*/
|
||||
namespace ConfigFile {
|
||||
|
||||
/*!
|
||||
* \brief Locates the config file with the specified \a fileName for the
|
||||
* application with the specified \a applicationName.
|
||||
* \remarks If \a settings is not nullptr, the path provided by that object is
|
||||
* also considered.
|
||||
*/
|
||||
QString locateConfigFile(const QString &applicationName, const QString &fileName, const QSettings *settings)
|
||||
{
|
||||
// check whether the file is in the current working directory
|
||||
if (QFile::exists(fileName)) {
|
||||
return fileName;
|
||||
} else {
|
||||
// check whether the file is in the settings directory used by QSettings
|
||||
QString path;
|
||||
if (settings) {
|
||||
path = QFileInfo(settings->fileName()).absoluteDir().absoluteFilePath(fileName);
|
||||
if (QFile::exists(path)) {
|
||||
return path;
|
||||
}
|
||||
}
|
||||
// check whether there is a user created version of the file under /etc/app/
|
||||
#ifdef Q_OS_WIN32
|
||||
// use relative paths on Windows
|
||||
path = QStringLiteral("../etc/") % applicationName % QChar('/') % fileName;
|
||||
if (QFile::exists(path)) {
|
||||
return path;
|
||||
} else {
|
||||
// check whether there is the default version of the file under
|
||||
// /usr/share/app/
|
||||
path = QStringLiteral("../share/") % applicationName % QChar('/') % fileName;
|
||||
if (QFile::exists(path)) {
|
||||
return path;
|
||||
} else {
|
||||
return QString(); // file is not present
|
||||
}
|
||||
}
|
||||
#else
|
||||
path = QStringLiteral("/etc/") % applicationName % QChar('/') % fileName;
|
||||
if (QFile::exists(path)) {
|
||||
return path;
|
||||
} else {
|
||||
// check whether there is the default version of the file under
|
||||
// /usr/share/app/
|
||||
path = QStringLiteral("/usr/share/") % applicationName % QChar('/') % fileName;
|
||||
if (QFile::exists(path)) {
|
||||
return path;
|
||||
} else {
|
||||
return QString(); // file is not present
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} // namespace ConfigFile
|
||||
} // namespace QtUtilities
|
||||
|
|
|
@ -59,11 +59,6 @@ QT_UTILITIES_EXPORT bool hasGuiApp();
|
|||
QT_UTILITIES_EXPORT bool hasCoreApp();
|
||||
} // namespace ApplicationInstances
|
||||
|
||||
namespace ConfigFile {
|
||||
|
||||
QT_UTILITIES_EXPORT QString locateConfigFile(const QString &applicationName, const QString &fileName, const QSettings *settings = nullptr);
|
||||
}
|
||||
|
||||
} // namespace QtUtilities
|
||||
|
||||
#endif // APPLICATION_UTILITIES_RESOURCES_H
|
||||
|
|
Loading…
Reference in New Issue