diff options
author | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-04-07 19:58:51 +0200 |
---|---|---|
committer | Jan Holthuis <jan.holthuis@ruhr-uni-bochum.de> | 2020-04-07 19:58:51 +0200 |
commit | 148a4e684600931695746809394e1e909517bfa0 (patch) | |
tree | 37f1c8a4fb8c2a99f74a4e590208cf3a4c9cc506 /src/controllers/dlgprefcontroller.cpp | |
parent | cb12d22ea4bddd682ac482173387e26f9fe146c2 (diff) |
controllers: Move script file search code into ControllerPreset class
Diffstat (limited to 'src/controllers/dlgprefcontroller.cpp')
-rw-r--r-- | src/controllers/dlgprefcontroller.cpp | 39 |
1 files changed, 15 insertions, 24 deletions
diff --git a/src/controllers/dlgprefcontroller.cpp b/src/controllers/dlgprefcontroller.cpp index c945029f0f..04fc78e096 100644 --- a/src/controllers/dlgprefcontroller.cpp +++ b/src/controllers/dlgprefcontroller.cpp @@ -221,35 +221,26 @@ QString DlgPrefController::presetWikiLink(const ControllerPresetPointer pPreset) } QString DlgPrefController::presetScriptFileLinks(const ControllerPresetPointer pPreset) const { - QString scriptFileLinks; + if (!pPreset) { + return QString(); + } - if (pPreset) { - // Always prefer script from the mapping's directory - QList<QString> scriptPaths = {pPreset->dirPath().absolutePath()}; + QString systemPresetPath = resourcePresetsPath(m_pConfig); + QStringList linkList; + for (const auto& script : pPreset->getScriptFiles(resourcePresetsPath(m_pConfig))) { + QString scriptFileLink = QStringLiteral("<a href=\"") + + script.file.absoluteFilePath() + QStringLiteral("\">") + + script.name + QStringLiteral("</a>"); - QString systemPresetPath = resourcePresetsPath(m_pConfig); - if (!scriptPaths.contains(systemPresetPath)) { - scriptPaths << systemPresetPath; + if (!script.file.exists()) { + scriptFileLink += QStringLiteral(" (") + tr("missing") + QStringLiteral(")"); + } else if (script.file.absoluteFilePath().startsWith(systemPresetPath)) { + scriptFileLink += QStringLiteral(" (") + tr("built-in") + QStringLiteral(")"); } - QStringList linkList; - for (QList<ControllerPreset::ScriptFileInfo>::iterator it = - pPreset->scripts.begin(); it != pPreset->scripts.end(); ++it) { - QString name = it->name; - QString path = ControllerManager::getAbsolutePath( - name, scriptPaths); - QString scriptFileLink = "<a href=\"" + path + "\">" + name + "</a>"; - - qDebug() << "path" << path << systemPresetPath; - if (path.startsWith(systemPresetPath)) { - scriptFileLink = QString(tr("%1 (built-in)")).arg(scriptFileLink); - } - - linkList << scriptFileLink; - } - scriptFileLinks = linkList.join("<br/>"); + linkList << scriptFileLink; } - return scriptFileLinks; + return linkList.join("<br/>"); } void DlgPrefController::slotDirty() { |