| 38 | } |
| 39 | |
| 40 | bool ApplicationList::loadSettings() |
| 41 | { |
| 42 | QSettings settings; |
| 43 | QStringList names = settings.value(SETTINGS_APPLICATION_NAMES, QStringList()).toStringList(); |
| 44 | QStringList paths = settings.value(SETTINGS_APPLICATION_PATHS, QStringList()).toStringList(); |
| 45 | QStringList params = settings.value(SETTINGS_APPLICATION_PARAMS, QStringList()).toStringList(); |
| 46 | int defapp = settings.value(SETTINGS_APPLICATION_DEFAULT, -1).toInt(); |
| 47 | |
| 48 | // Params will be empty first time starting with the new setting. |
| 49 | // Return false and inform user about problem with application settings. |
| 50 | bool succeeded = true; |
| 51 | if (!names.empty() && !paths.empty() && params.empty()) { |
| 52 | for (int i = 0; i < paths.length(); i++) |
| 53 | params << QString(); |
| 54 | succeeded = false; |
| 55 | } |
| 56 | |
| 57 | if (names.empty() && paths.empty() && params.empty()) { |
| 58 | #ifndef _WIN32 |
| 59 | // use as default for gnome environments |
| 60 | if (QFileInfo("/usr/bin/gedit").isExecutable()) { |
| 61 | Application app; |
| 62 | app.setName("gedit"); |
| 63 | app.setPath("/usr/bin/gedit"); |
| 64 | app.setParameters("+(line) (file)"); |
| 65 | addApplication(app); |
| 66 | defapp = 0; |
| 67 | } |
| 68 | checkAndAddApplication("/usr/bin/geany","geany","+(line) (file)"); |
| 69 | checkAndAddApplication("/usr/bin/qtcreator","Qt Creator","-client (file):(line)"); |
| 70 | // use as default for kde environments |
| 71 | if (QFileInfo("/usr/bin/kate").isExecutable()) { |
| 72 | Application app; |
| 73 | app.setName("kate"); |
| 74 | app.setPath("/usr/bin/kate"); |
| 75 | app.setParameters("-l(line) (file)"); |
| 76 | addApplication(app); |
| 77 | defapp = 0; |
| 78 | } |
| 79 | #else |
| 80 | if (findDefaultWindowsEditor()) { |
| 81 | defapp = 0; |
| 82 | } |
| 83 | #endif |
| 84 | } else if (names.size() == paths.size()) { |
| 85 | for (int i = 0; i < names.size(); i++) { |
| 86 | const Application app(names[i], paths[i], params[i]); |
| 87 | addApplication(app); |
| 88 | } |
| 89 | } |
| 90 | |
| 91 | if (defapp == -1) |
| 92 | mDefaultApplicationIndex = 0; |
| 93 | else if (defapp < names.size()) |
| 94 | mDefaultApplicationIndex = defapp; |
| 95 | else |
| 96 | mDefaultApplicationIndex = 0; |
| 97 | |