Commit 02f08cac authored by Damien Caliste's avatar Damien Caliste

[fingerterm] Don't copy anymore layouts to user config directory on startup.

parent 5250432d
...@@ -49,6 +49,8 @@ bool KeyLoader::loadLayout(QString layout) ...@@ -49,6 +49,8 @@ bool KeyLoader::loadLayout(QString layout)
} }
else { // load from file else { // load from file
QFile f(iUtil->configPath() + "/" + layout + ".layout"); QFile f(iUtil->configPath() + "/" + layout + ".layout");
if (!f.exists()) // fallback to installation directory
f.setFileName(QStringLiteral(DEPLOYMENT_PATH) + "/data/" + layout + ".layout");
ret = loadLayoutInternal(f); ret = loadLayoutInternal(f);
} }
...@@ -197,6 +199,15 @@ const QStringList KeyLoader::availableLayouts() ...@@ -197,6 +199,15 @@ const QStringList KeyLoader::availableLayouts()
ret << s.left(s.lastIndexOf('.')); ret << s.left(s.lastIndexOf('.'));
} }
// Add also layouts from installation path.
QDir dataDir(QStringLiteral(DEPLOYMENT_PATH) + "/data");
results = dataDir.entryList(filter, QDir::Files|QDir::Readable, QDir::Name);
foreach(QString s, results) {
QString layout = s.left(s.lastIndexOf('.'));
if (!ret.contains(layout))
ret << layout;
}
return ret; return ret;
} }
......
...@@ -40,8 +40,6 @@ extern "C" { ...@@ -40,8 +40,6 @@ extern "C" {
#include "version.h" #include "version.h"
#include "keyloader.h" #include "keyloader.h"
static void copyFilesFromPath(QString from, QString to);
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QString settings_path(QDir::homePath() + "/.config/FingerTerm"); QString settings_path(QDir::homePath() + "/.config/FingerTerm");
...@@ -131,9 +129,6 @@ int main(int argc, char *argv[]) ...@@ -131,9 +129,6 @@ int main(int argc, char *argv[])
QString startupErrorMsg; QString startupErrorMsg;
// copy the default config files to the config dir if they don't already exist
copyFilesFromPath(QStringLiteral(DEPLOYMENT_PATH) + QDir::separator() + QStringLiteral("data"), util.configPath());
KeyLoader keyLoader; KeyLoader keyLoader;
keyLoader.setUtil(&util); keyLoader.setUtil(&util);
bool ret = keyLoader.loadLayout(util.keyboardLayout()); bool ret = keyLoader.loadLayout(util.keyboardLayout());
...@@ -179,14 +174,3 @@ int main(int argc, char *argv[]) ...@@ -179,14 +174,3 @@ int main(int argc, char *argv[])
return app.exec(); return app.exec();
} }
static void copyFilesFromPath(QString from, QString to)
{
QDir fromDir(from);
QDir toDir(to);
// Copy files from fromDir to toDir, but don't overwrite existing ones
foreach (const QString &filename, fromDir.entryList(QDir::Files)) {
QFile::copy(fromDir.filePath(filename), toDir.filePath(filename));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment