mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 02:36:34 +01:00
DataPaths: Add locate function
This commit is contained in:
parent
f27bc89019
commit
72f9c4eb7b
@ -77,6 +77,19 @@ QStringList DataPaths::allPaths(DataPaths::Path type)
|
|||||||
return qz_data_paths()->m_paths[type];
|
return qz_data_paths()->m_paths[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// static
|
||||||
|
QString DataPaths::locate(Path type, const QString &file)
|
||||||
|
{
|
||||||
|
const QStringList dirs = allPaths(type);
|
||||||
|
for (const QString &dir : dirs) {
|
||||||
|
const QString fullPath = QDir(dir).absoluteFilePath(file);
|
||||||
|
if (QFileInfo::exists(fullPath)) {
|
||||||
|
return fullPath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
// static
|
// static
|
||||||
QString DataPaths::currentProfilePath()
|
QString DataPaths::currentProfilePath()
|
||||||
{
|
{
|
||||||
|
@ -53,6 +53,8 @@ public:
|
|||||||
static QString path(Path type);
|
static QString path(Path type);
|
||||||
// Returns all paths (Themes -> /usr/share/themes, ~/.config/falkon/themes)
|
// Returns all paths (Themes -> /usr/share/themes, ~/.config/falkon/themes)
|
||||||
static QStringList allPaths(Path type);
|
static QStringList allPaths(Path type);
|
||||||
|
// Returns full path of existing file
|
||||||
|
static QString locate(Path type, const QString &file);
|
||||||
// Convenience function for getting CurrentProfile
|
// Convenience function for getting CurrentProfile
|
||||||
static QString currentProfilePath();
|
static QString currentProfilePath();
|
||||||
|
|
||||||
|
@ -991,16 +991,7 @@ void MainApplication::loadSettings()
|
|||||||
|
|
||||||
void MainApplication::loadTheme(const QString &name)
|
void MainApplication::loadTheme(const QString &name)
|
||||||
{
|
{
|
||||||
QString activeThemePath;
|
QString activeThemePath = DataPaths::locate(DataPaths::Themes, name);
|
||||||
const QStringList themePaths = DataPaths::allPaths(DataPaths::Themes);
|
|
||||||
|
|
||||||
foreach (const QString &path, themePaths) {
|
|
||||||
const QString theme = QString("%1/%2").arg(path, name);
|
|
||||||
if (QFile::exists(theme + QLatin1String("/main.css"))) {
|
|
||||||
activeThemePath = theme;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (activeThemePath.isEmpty()) {
|
if (activeThemePath.isEmpty()) {
|
||||||
qWarning() << "Cannot load theme " << name;
|
qWarning() << "Cannot load theme " << name;
|
||||||
|
@ -109,14 +109,8 @@ void Plugins::loadPlugins()
|
|||||||
if (QFileInfo(pluginFile).isAbsolute()) {
|
if (QFileInfo(pluginFile).isAbsolute()) {
|
||||||
fullPath = pluginFile;
|
fullPath = pluginFile;
|
||||||
} else {
|
} else {
|
||||||
const QStringList dirs = DataPaths::allPaths(DataPaths::Plugins);
|
fullPath = DataPaths::locate(DataPaths::Plugins, pluginFile);
|
||||||
for (const QString &dir : dirs) {
|
if (fullPath.isEmpty()) {
|
||||||
fullPath = dir + QL1C('/') + pluginFile;
|
|
||||||
if (QFileInfo::exists(fullPath)) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!QFileInfo::exists(fullPath)) {
|
|
||||||
qWarning() << "Plugin" << pluginFile << "not found";
|
qWarning() << "Plugin" << pluginFile << "not found";
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user