From 8cdea01b225f82edd89e5b3287980d5780a201eb Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 11 Mar 2024 15:16:42 +0100 Subject: [PATCH] Remove support for XML configuration files in SGCT --- .../ext/launcher/include/filesystemaccess.h | 2 +- .../ext/launcher/src/launcherwindow.cpp | 29 +++---------------- apps/OpenSpace/ext/sgct | 2 +- apps/OpenSpace/main.cpp | 8 +---- include/openspace/engine/configuration.h | 2 +- 5 files changed, 8 insertions(+), 35 deletions(-) diff --git a/apps/OpenSpace/ext/launcher/include/filesystemaccess.h b/apps/OpenSpace/ext/launcher/include/filesystemaccess.h index 61ac0471c4..900d300e32 100644 --- a/apps/OpenSpace/ext/launcher/include/filesystemaccess.h +++ b/apps/OpenSpace/ext/launcher/include/filesystemaccess.h @@ -33,7 +33,7 @@ public: * Constructor for filesystemAccess class. * * \param fileExtension The file extensiopn filter used to find files. Only files with - * this extension will be recognized (e.g. '.xml') + * this extension will be recognized (e.g. '.json') * \param hideFileExtensions If `true` then file extensions will be removed from the * listed files in the output * \param useCheckboxes If `true` then the text output format will contain a '0' as diff --git a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp index 65eb3b411c..8a2657fcfa 100644 --- a/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp +++ b/apps/OpenSpace/ext/launcher/src/launcherwindow.cpp @@ -573,9 +573,8 @@ void LauncherWindow::populateProfilesList(std::string preset) { // Returns 'true' if the file was a configuration file, 'false' otherwise bool handleConfigurationFile(QComboBox& box, const std::filesystem::directory_entry& p) { - const bool isXml = p.path().extension() == ".xml"; const bool isJson = p.path().extension() == ".json"; - if (!isXml && !isJson) { + if (!isJson) { return false; } box.addItem(QString::fromStdString(p.path().filename().string())); @@ -598,11 +597,6 @@ bool handleConfigurationFile(QComboBox& box, const std::filesystem::directory_en } } - // For now, mark the XML configuration files to show that they are deprecated - if (isXml) { - box.setItemData(box.count() - 1, QBrush(Qt::darkYellow), Qt::ForegroundRole); - } - return true; } @@ -630,8 +624,6 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { _userConfigStartingIdx++; _preDefinedConfigStartingIdx++; - bool hasXmlConfig = false; - // Sort files std::vector files; for (const fs::directory_entry& p : fs::directory_iterator(_userConfigPath)) { @@ -639,7 +631,7 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { } std::sort(files.begin(), files.end()); - // Add all the files with the .xml or .json extension to the dropdown + // Add all the files with the .json extension to the dropdown for (const fs::directory_entry& p : files) { bool isConfigFile = handleConfigurationFile(*_windowConfigBox, p); if (isConfigFile) { @@ -647,7 +639,6 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { _userConfigStartingIdx++; _preDefinedConfigStartingIdx++; } - hasXmlConfig |= p.path().extension() == ".xml"; } _windowConfigBox->addItem(QString::fromStdString("--- OpenSpace Configurations ---")); model = qobject_cast(_windowConfigBox->model()); @@ -661,10 +652,9 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { files.push_back(p); } std::sort(files.begin(), files.end()); - // Add all the files with the .xml or .json extension to the dropdown + // Add all the files with the .json extension to the dropdown for (const fs::directory_entry& p : files) { handleConfigurationFile(*_windowConfigBox, p); - hasXmlConfig |= p.path().extension() == ".xml"; } } else { @@ -674,18 +664,7 @@ void LauncherWindow::populateWindowConfigsList(std::string preset) { ); } - if (hasXmlConfig) { - // At least one XML configuration file is present, so we should show the tooltip - // informing the user that files will be deprecated - _windowConfigBox->setToolTip( - "Support for XML-based configuration files will be removed in the next " - "version of OpenSpace. Please convert the files to the new JSON format or " - "run the Node tool at " - "https://github.com/sgct/sgct/tree/master/support/config-converter" - ); - } - - // Always add the .cfg sgct default as first item + // Always add the .cfg SGCT default as first item _windowConfigBox->insertItem( _windowConfigBoxIndexSgctCfgDefault, QString::fromStdString(_sgctConfigName) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index 4bf071f548..be88262a5f 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit 4bf071f5486dee3bb6ae95d8a90e9ee6f8ef2a18 +Subproject commit be88262a5fe36715043433654490afa0c750a6a4 diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index f6f47ac0b3..18df1b87a8 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -1065,16 +1065,10 @@ std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTC std::filesystem::path cj = c; cj.replace_extension(".json"); - std::filesystem::path cx = c; - cx.replace_extension(".xml"); - if (c.extension().empty()) { if (std::filesystem::exists(cj)) { config += ".json"; } - else if (std::filesystem::exists(cx)) { - config += ".xml"; - } else { throw ghoul::RuntimeError(fmt::format( "Error loading configuration file '{}'. File could not be found", @@ -1083,7 +1077,7 @@ std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTC } } else { - // user customzied sgct config + // user customized SGCT config } } global::configuration->windowConfiguration = config; diff --git a/include/openspace/engine/configuration.h b/include/openspace/engine/configuration.h index a7d2295deb..7bb5abeacc 100644 --- a/include/openspace/engine/configuration.h +++ b/include/openspace/engine/configuration.h @@ -47,7 +47,7 @@ struct Configuration { ghoul::Dictionary createDictionary(); - std::string windowConfiguration = "${CONFIG}/single.xml"; + std::string windowConfiguration = "${CONFIG}/single.json"; std::string asset; std::string profile;