Commit e6fb116c authored by jcfr's avatar jcfr
Browse files

ENH: Support per user per revision extensions settings

There is now a clear distinction between:
 - userSettings -> i.e. ~/.config/NA-MIC/Slicer.ini
 - revisionUserSettings -> i.e. ~/.config/NA-MIC/Slicer-<revision>.ini

The following slicer settings are now revision specific:
 - Extensions/ManagerEnabled
 - Extensions/ServerUrl
 - Extensions/InstallPath
 - Modules/AdditonalPath
 - Modules/IgnoreModules

Additionally, the launcher version has also been updated to be able to
consider settings associated with a user, application and revision. This is
captured by the new parameter APPLICATION_REVISION, ORGANIZATION_DOMAIN,
ORGANIZATION_NAME and USER_ADDITIONAL_SETTINGS_FILEBASENAME passed to the CMake
function "ctkAppLauncherConfigure".

qSlicerCoreApplication API has also been extended and now includes methods
like:
  - QSettings* userSettings()  [settings() method is deprecated and kept for backward compatibility]
  - QSettings* revisionUserSettings()
  - QString launcherRevisionUserSettingsFilePath()
  - QString slicerUserSettingsFilePath()
  - QString slicerRevisionUserSettingsFilePath()

In addition to the settings, the extensions install path is also revision
specific, it means that it's now possible to have multiple version of slicer
running with different set of extensions.

Fixes #2791, #2143, #2720, #2533


Since the version of the launcher is updated, launcher will return EXIT_FAILURE
also when no application is been set in the launcher settings.

Fixes #2767

git-svn-id: http://svn.slicer.org/Slicer4/trunk@21482 3bd1e089-480b-0410-8dfb-8563597acbee
parent e0480309
......@@ -286,6 +286,10 @@ if(${PROJECT_NAME} STREQUAL ${Slicer_MAIN_PROJECT})
TARGET ${PROJECT_NAME}${SlicerApp_EXE_SUFFIX}
APPLICATION_INSTALL_SUBDIR ${Slicer_INSTALL_BIN_DIR}
APPLICATION_NAME ${SlicerApp_APPLICATION_NAME}
APPLICATION_REVISION ${Slicer_WC_REVISION}
ORGANIZATION_DOMAIN ${Slicer_ORGANIZATION_DOMAIN}
ORGANIZATION_NAME ${Slicer_ORGANIZATION_NAME}
USER_ADDITIONAL_SETTINGS_FILEBASENAME ${SLICER_REVISION_SPECIFIC_USER_SETTINGS_FILEBASENAME}
SPLASH_IMAGE_PATH ${splash_image_path}
SPLASH_IMAGE_INSTALL_SUBDIR ${Slicer_INSTALL_BIN_DIR}
SPLASHSCREEN_HIDE_DELAY_MS 3000
......
......@@ -66,7 +66,7 @@ namespace
void setEnableQtTesting()
{
if (qSlicerApplication::application()->commandOptions()->enableQtTesting() ||
qSlicerApplication::application()->settings()->value("QtTesting/Enabled").toBool())
qSlicerApplication::application()->userSettings()->value("QtTesting/Enabled").toBool())
{
QCoreApplication::setAttribute(Qt::AA_DontUseNativeMenuBar);
}
......
......@@ -823,9 +823,11 @@ void qSlicerAppMainWindow::setupMenuActions()
connect(d->actionLoadDICOM, SIGNAL(triggered()),
this, SLOT(loadDICOMActionTriggered()));
QSettings settings;
qSlicerApplication * app = qSlicerApplication::application();
#ifdef Slicer_BUILD_EXTENSIONMANAGER_SUPPORT
d->actionViewExtensionManager->setVisible(settings.value("Extensions/ManagerEnabled").toBool());
d->actionViewExtensionManager->setVisible(
app->revisionUserSettings()->value("Extensions/ManagerEnabled").toBool());
#else
d->actionViewExtensionManager->setVisible(false);
#endif
......@@ -834,16 +836,15 @@ void qSlicerAppMainWindow::setupMenuActions()
#endif
#if defined Slicer_USE_QtTesting && defined Slicer_BUILD_CLI_SUPPORT
if (qSlicerApplication::application()->commandOptions()->enableQtTesting() ||
settings.value("QtTesting/Enabled").toBool())
if (app->commandOptions()->enableQtTesting() ||
app->userSettings()->value("QtTesting/Enabled").toBool())
{
d->actionEditPlayMacro->setVisible(true);
d->actionEditRecordMacro->setVisible(true);
qSlicerApplication::application()->testingUtility()->addPlayer(
new qSlicerCLIModuleWidgetEventPlayer());
app->testingUtility()->addPlayer(new qSlicerCLIModuleWidgetEventPlayer());
}
#endif
Q_UNUSED(app);
}
#undef qSlicerAppMainWindowCore_connect
......
......@@ -137,6 +137,7 @@ int vtkSlicerApplicationLogicTest1(int , char * [])
TestRowType row;
row.push_back("/home/jchris/Projects/MRIChangeDetector-build/lib/Slicer-X.Y/qt-scripted-modules/MRIChangeDetector.pyc");
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build");
row.push_back("4810");
row.push_back("0");
data.push_back(row);
}
......@@ -144,6 +145,7 @@ int vtkSlicerApplicationLogicTest1(int , char * [])
TestRowType row;
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build/lib/Slicer-X.Y/qt-scripted-modules/MRIChangeDetector.pyc");
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build");
row.push_back("4810");
row.push_back("1");
data.push_back(row);
}
......@@ -151,24 +153,35 @@ int vtkSlicerApplicationLogicTest1(int , char * [])
TestRowType row;
row.push_back("/home/jchris/Projects/Slicer.app/Contents/lib/Slicer-4.1/qt-loadable-modules/libqSlicerAnnotationsModule.dylib");
row.push_back("/home/jchris/Projects/Slicer.app/Contents");
row.push_back("4810");
row.push_back("1");
data.push_back(row);
}
{
TestRowType row;
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build/bin/Slicer.app/Contents/Extensions/Reporting/lib/Slicer-4.1/qt-loadable-modules/Python/vtkSlicerReportingModuleLogic.py");
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build/bin/Slicer.app/Contents/Extensions-4810/Reporting/lib/Slicer-4.1/qt-loadable-modules/Python/vtkSlicerReportingModuleLogic.py");
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build");
row.push_back("4810");
row.push_back("0");
data.push_back(row);
}
{
TestRowType row;
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build/bin/Slicer.app/Contents/Extensions-4810/Reporting/lib/Slicer-4.1/qt-loadable-modules/Python/vtkSlicerReportingModuleLogic.py");
row.push_back("/home/jchris/Projects/Slicer4-Superbuild-Debug/Slicer-build");
row.push_back("4811");
row.push_back("1");
data.push_back(row);
}
for(TestDataType::size_type rowIdx = 0; rowIdx < data.size(); ++rowIdx)
{
std::string filePath(data.at(rowIdx).at(0));
std::string applicationHomeDir(data.at(rowIdx).at(1));
std::string isEmbeddedExpectedAsStr(data.at(rowIdx).at(2));
std::string slicerRevision(data.at(rowIdx).at(2));
std::string isEmbeddedExpectedAsStr(data.at(rowIdx).at(3));
bool isEmbeddedExpected = (isEmbeddedExpectedAsStr == "1");
bool isEmbedded = vtkSlicerApplicationLogic::IsEmbeddedModule(filePath, applicationHomeDir);
bool isEmbedded = vtkSlicerApplicationLogic::IsEmbeddedModule(filePath, applicationHomeDir, slicerRevision);
if (isEmbeddedExpected != isEmbedded)
{
std::cerr << "Line " << __LINE__ << " - Problem with isEmbedded ! - Row:" << rowIdx << "\n"
......
......@@ -1547,7 +1547,9 @@ void vtkSlicerApplicationLogic::ProcessWriteSceneData(WriteDataRequest& req)
}
//----------------------------------------------------------------------------
bool vtkSlicerApplicationLogic::IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir)
bool vtkSlicerApplicationLogic::IsEmbeddedModule(const std::string& filePath,
const std::string& applicationHomeDir,
const std::string& slicerRevision)
{
if (filePath.empty())
{
......@@ -1562,10 +1564,10 @@ bool vtkSlicerApplicationLogic::IsEmbeddedModule(const std::string& filePath, co
std::string extensionPath = itksys::SystemTools::GetFilenamePath(filePath);
bool isEmbedded = itksys::SystemTools::StringStartsWith(extensionPath.c_str(), applicationHomeDir.c_str());
#ifdef Slicer_BUILD_EXTENSIONMANAGER_SUPPORT
// On MacOSX extensions are installed in the "Extensions" folder being a sub directory of the
// application dir, an extra test is required to make sure the tested filePath
// doesn't belong to that "Extensions" folder.
if (isEmbedded && extensionPath.find(Slicer_BUNDLE_LOCATION "/" Slicer_BUNDLE_EXTENSIONS_DIRNAME) != std::string::npos)
// On MacOSX extensions are installed in the "<Slicer_EXTENSIONS_DIRBASENAME>-<slicerRevision>"
// folder being a sub directory of the application dir, an extra test is required to make sure the
// tested filePath doesn't belong to that "<Slicer_EXTENSIONS_DIRBASENAME>-<slicerRevision>" folder.
if (isEmbedded && extensionPath.find(Slicer_BUNDLE_LOCATION "/" Slicer_EXTENSIONS_DIRBASENAME "-" + slicerRevision) != std::string::npos)
{
isEmbedded = false;
}
......
......@@ -133,7 +133,12 @@ class VTK_SLICER_BASE_LOGIC_EXPORT vtkSlicerApplicationLogic
void SetTracingOff () { this->Tracing = 0; }
/// Return True if \a filePath is a descendant of \a applicationHomeDir.
static bool IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir);
/// \note On MacOSX extensions are installed in the "<Slicer_EXTENSIONS_DIRBASENAME>-<slicerRevision>"
/// folder being a sub directory of the application dir, an extra test is performed to make sure the
/// tested filePath doesn't belong to that "<Slicer_EXTENSIONS_DIRBASENAME>-<slicerRevision>" folder.
/// If this is the case, False will be returned.
static bool IsEmbeddedModule(const std::string& filePath, const std::string& applicationHomeDir,
const std::string& slicerRevision);
/// Return \a true if the plugin identified with its \a filePath is loaded from an install tree.
/// \warning Since internally the function looks for the existence of CMakeCache.txt, it will
......
......@@ -100,14 +100,13 @@ void qSlicerApplicationHelper::setupModuleFactoryManager(qSlicerModuleFactoryMan
}
#endif
QSettings settings;
#ifdef Slicer_BUILD_CLI_SUPPORT
if (!options->disableCLIModules() && !options->runPythonAndExit())
{
QString tempDirectory =
qSlicerCoreApplication::application()->coreCommandOptions()->tempDirectory();
bool preferExecutableCLIs =
settings.value("Modules/PreferExecutableCLI", false).toBool();
app->userSettings()->value("Modules/PreferExecutableCLI", false).toBool();
moduleFactoryManager->registerFactory(
new qSlicerCLILoadableModuleFactory(tempDirectory), preferExecutableCLIs ? 0 : 1);
// Option to prefer executable CLIs to limit memory consumption.
......@@ -125,9 +124,9 @@ void qSlicerApplicationHelper::setupModuleFactoryManager(qSlicerModuleFactoryMan
}
#endif
moduleFactoryManager->addSearchPaths(
settings.value("Modules/AdditionalPaths").toStringList());
app->revisionUserSettings()->value("Modules/AdditionalPaths").toStringList());
moduleFactoryManager->setModulesToIgnore(
settings.value("Modules/IgnoreModules").toStringList());
app->revisionUserSettings()->value("Modules/IgnoreModules").toStringList());
moduleFactoryManager->setVerboseModuleDiscovery(app->commandOptions()->verboseModuleDiscovery());
}
......@@ -138,7 +137,7 @@ void qSlicerApplicationHelper::loadTranslations(const QString& dir)
Q_ASSERT(app);
QString localeFilter =
QString( QString("*") + app->settings()->value("language").toString());
QString( QString("*") + app->userSettings()->value("language").toString());
localeFilter.resize(3);
localeFilter += QString(".qm");
......
......@@ -55,7 +55,8 @@ const QStringList qSlicerCLIModuleFactoryHelper::modulePaths()
}
}
QStringList additionalModulePaths = QSettings().value("Modules/AdditionalPaths").toStringList();
QSettings * settings = app->revisionUserSettings();
QStringList additionalModulePaths = settings->value("Modules/AdditionalPaths").toStringList();
QStringList cmdLineModulePaths = additionalModulePaths + defaultCmdLineModulePaths;
foreach(const QString& path, cmdLineModulePaths)
{
......
......@@ -73,7 +73,7 @@ int qSlicerCoreApplicationTest1(int argc, char * argv [] )
return EXIT_FAILURE;
}
QSettings * settings = app.settings();
QSettings * settings = app.userSettings();
if( settings == 0 )
{
std::cerr << "Problem with settings()" << std::endl;
......
......@@ -126,14 +126,14 @@ private slots:
void testIsExtensionEnabled();
void testIsExtensionEnabled_data();
void testSetLauncherSettingsFilePath();
void testSetLauncherSettingsFilePath_data();
void testSetExtensionsSettingsFilePath();
void testSetExtensionsSettingsFilePath_data();
void testExtensionAdditionalPathsSettingsUpdated();
void testExtensionAdditionalPathsSettingsUpdated_data();
void testExtensionLauncherSettingsUpdated();
void testExtensionLauncherSettingsUpdated_data();
void testExtensionExtensionsSettingsUpdated();
void testExtensionExtensionsSettingsUpdated_data();
void testSetSlicerRevision();
void testSetSlicerRevision_data();
......@@ -417,6 +417,7 @@ void qSlicerExtensionsManagerModelTester::testServerUrl()
QSettings().setValue("Extensions/ServerUrl", serverUrl);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerVersion(Slicer_VERSION);
QUrl currentServerUrl = model.serverUrl();
......@@ -503,6 +504,7 @@ void qSlicerExtensionsManagerModelTester::testRetrieveExtensionMetadata()
QFETCH(QString, slicerVersion);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerVersion(slicerVersion);
ExtensionMetadataType extensionMetadata = model.retrieveExtensionMetadata(extensionId);
......@@ -551,6 +553,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive()
QFETCH(QString, inputExtensionName);
QFETCH(QString, inputArchiveFile);
QFETCH(QString, slicerVersion);
QFETCH(QString, slicerRevision);
QFETCH(QStringList, expectedFiles);
QFETCH(QString, operatingSystem);
QFETCH(bool, expectedExtractSuccess);
......@@ -561,6 +564,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive()
QCOMPARE(static_cast<bool>(destinationPath.permissions() & QFile::WriteUser), true);
qSlicerExtensionsManagerModel model;
model.setSlicerRevision(slicerRevision);
model.setSlicerVersion(slicerVersion);
model.setSlicerOs(operatingSystem);
......@@ -606,6 +610,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive_data()
QTest::addColumn<QString>("inputExtensionName");
QTest::addColumn<QString>("inputArchiveFile");
QTest::addColumn<QString>("slicerVersion");
QTest::addColumn<QString>("slicerRevision");
QTest::addColumn<QStringList>("expectedFiles");
QTest::addColumn<QString>("operatingSystem");
QTest::addColumn<bool>("expectedExtractSuccess");
......@@ -621,6 +626,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive_data()
<< "CLIExtensionTemplate"
<< QString(":/extension-%1-0.tar.gz").arg(Slicer_OS_LINUX_NAME)
<< this->slicerVersion(Slicer_OS_LINUX_NAME, 0)
<< "19615"
<< expectedFiles
<< Slicer_OS_LINUX_NAME
<< true /* expectedExtractSuccess */
......@@ -632,6 +638,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive_data()
<< "CLIExtensionTemplate"
<< QString(":/extension-%1-0.tar.gz").arg(Slicer_OS_LINUX_NAME)
<< this->slicerVersion(Slicer_OS_LINUX_NAME, 0)
<< "19615"
<< expectedFiles
<< Slicer_OS_LINUX_NAME
<< false /* expectedExtractSuccess */
......@@ -644,6 +651,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive_data()
<< "CLIExtensionTemplate"
<< QString(":/extension-%1-0.tar.gz").arg(Slicer_OS_LINUX_NAME)
<< this->slicerVersion(Slicer_OS_LINUX_NAME, 0)
<< "19615"
<< expectedFiles
<< Slicer_OS_LINUX_NAME
<< false /* expectedExtractSuccess */
......@@ -662,6 +670,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive_data()
<< "CLIExtensionTemplate"
<< QString(":/extension-%1-0.tar.gz").arg(Slicer_OS_MAC_NAME)
<< this->slicerVersion(Slicer_OS_MAC_NAME, 0)
<< "19615"
<< expectedFiles
<< Slicer_OS_MAC_NAME
<< true /* expectedExtractSuccess */
......@@ -683,6 +692,7 @@ void qSlicerExtensionsManagerModelTester::testExtractExtensionArchive_data()
<< "LoadableExtensionTemplate"
<< QString(":/extension-%1-1.tar.gz").arg(Slicer_OS_MAC_NAME)
<< this->slicerVersion(Slicer_OS_MAC_NAME, 1)
<< "19615"
<< expectedFiles
<< Slicer_OS_MAC_NAME
<< true /* expectedExtractSuccess */
......@@ -751,6 +761,7 @@ void qSlicerExtensionsManagerModelTester::testInstallExtension()
<< "ScriptedLoadableExtensionTemplate" << "SuperBuildLoadableExtensionTemplate";
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
QSignalSpy spyModelUpdated(&model, SIGNAL(modelUpdated()));
......@@ -807,6 +818,7 @@ void qSlicerExtensionsManagerModelTester::testUninstallExtension()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
......@@ -825,6 +837,7 @@ void qSlicerExtensionsManagerModelTester::testUninstallExtension()
}
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.updateModel();
......@@ -874,6 +887,7 @@ void qSlicerExtensionsManagerModelTester::testScheduleExtensionForUninstall()
QFETCH(QString, operatingSystem);
QFETCH(QList<int>, extensionIdsToInstall);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
foreach(int extensionIdToInstall, extensionIdsToInstall)
......@@ -887,6 +901,7 @@ void qSlicerExtensionsManagerModelTester::testScheduleExtensionForUninstall()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
QSignalSpy spyExtensionScheduledForUninstall(&model, SIGNAL(extensionScheduledForUninstall(QString)));
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
......@@ -900,6 +915,7 @@ void qSlicerExtensionsManagerModelTester::testScheduleExtensionForUninstall()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
model.updateModel();
......@@ -956,6 +972,7 @@ void qSlicerExtensionsManagerModelTester::testCancelExtensionScheduledForUninsta
{
QFETCH(QList<int>, extensionIdsToInstall);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
foreach(int extensionIdToInstall, extensionIdsToInstall)
......@@ -967,6 +984,7 @@ void qSlicerExtensionsManagerModelTester::testCancelExtensionScheduledForUninsta
{
QFETCH(QStringList, extensionNamesToScheduleForUninstall);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
model.updateModel();
......@@ -980,6 +998,7 @@ void qSlicerExtensionsManagerModelTester::testCancelExtensionScheduledForUninsta
QFETCH(QStringList, extensionNamesToCancelScheduledForUninstall);
QFETCH(int, expectedSpyExtensionCancelledScheduleForUninstallCount);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
QSignalSpy spyExtensionCancelledScheduleForUninstall(&model, SIGNAL(extensionCancelledScheduleForUninstall(QString)));
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
......@@ -994,6 +1013,7 @@ void qSlicerExtensionsManagerModelTester::testCancelExtensionScheduledForUninsta
{
QFETCH(QStringList, expectedExtensionNamesScheduledForUninstall);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.setSlicerVersion(slicerVersion);
model.updateModel();
......@@ -1056,6 +1076,7 @@ void qSlicerExtensionsManagerModelTester::testUpdateModel()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
QSignalSpy spyModelUpdated(&model, SIGNAL(modelUpdated()));
for (int extensionId = 0; extensionId < 4; ++extensionId)
......@@ -1066,6 +1087,7 @@ void qSlicerExtensionsManagerModelTester::testUpdateModel()
}
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
QSignalSpy spyModelUpdated(&model, SIGNAL(modelUpdated()));
......@@ -1098,6 +1120,7 @@ void qSlicerExtensionsManagerModelTester::testUpdateModel()
}
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
QSignalSpy spyModelUpdated(&model, SIGNAL(modelUpdated()));
......@@ -1162,6 +1185,7 @@ void qSlicerExtensionsManagerModelTester::testIsExtensionInstalled()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
if (extensionIdToInstall != -1)
{
......@@ -1175,6 +1199,7 @@ void qSlicerExtensionsManagerModelTester::testIsExtensionInstalled()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.updateModel();
QCOMPARE(model.isExtensionInstalled(this->expectedExtensionNames().at(0)), isExtensionZeroInstalled);
......@@ -1239,6 +1264,7 @@ void qSlicerExtensionsManagerModelTester::testNumberOfInstalledExtensions()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
foreach(int extensionIdToInstall, extensionIdsToInstall)
{
......@@ -1248,6 +1274,7 @@ void qSlicerExtensionsManagerModelTester::testNumberOfInstalledExtensions()
}
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.updateModel();
QCOMPARE(model.numberOfInstalledExtensions(), expectedNumberOfInstalledExtensions);
......@@ -1304,6 +1331,7 @@ void qSlicerExtensionsManagerModelTester::testInstalledExtensions()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
foreach(int extensionIdToInstall, extensionIdsToInstall)
{
......@@ -1313,6 +1341,7 @@ void qSlicerExtensionsManagerModelTester::testInstalledExtensions()
}
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.updateModel();
QCOMPARE(model.installedExtensions(), expectedInstalledExtensionNames);
......@@ -1373,6 +1402,7 @@ void qSlicerExtensionsManagerModelTester::testIsExtensionEnabled()
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
foreach(int extensionIdToInstall, extensionIdsToInstall)
{
......@@ -1402,6 +1432,7 @@ void qSlicerExtensionsManagerModelTester::testIsExtensionEnabled()
}
{
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.updateModel();
QCOMPARE(model.enabledExtensions(), expectedEnabledExtensionNamesAfterDisable);
......@@ -1478,29 +1509,29 @@ void qSlicerExtensionsManagerModelTester::testIsExtensionEnabled_data()
}
// ----------------------------------------------------------------------------
void qSlicerExtensionsManagerModelTester::testSetLauncherSettingsFilePath()
void qSlicerExtensionsManagerModelTester::testSetExtensionsSettingsFilePath()
{
QFETCH(QString, launcherSettingsFilePath);
QFETCH(QString, expectedLauncherSettingsFilePath);
QFETCH(QString, extensionsSettingsFilePath);
QFETCH(QString, expectedExtensionsSettingsFilePath);
qSlicerExtensionsManagerModel model;
QCOMPARE(model.launcherSettingsFilePath(), QString());
QCOMPARE(model.extensionsSettingsFilePath(), QString());
QSignalSpy spyModelUpdated(&model, SIGNAL(modelUpdated()));
model.setLauncherSettingsFilePath(launcherSettingsFilePath);
QCOMPARE(model.launcherSettingsFilePath(), expectedLauncherSettingsFilePath);
model.setExtensionsSettingsFilePath(extensionsSettingsFilePath);
QCOMPARE(model.extensionsSettingsFilePath(), expectedExtensionsSettingsFilePath);
QCOMPARE(spyModelUpdated.count(), 0);
}
// ----------------------------------------------------------------------------
void qSlicerExtensionsManagerModelTester::testSetLauncherSettingsFilePath_data()
void qSlicerExtensionsManagerModelTester::testSetExtensionsSettingsFilePath_data()
{
QVERIFY(this->resetTmp());
QTest::addColumn<QString>("launcherSettingsFilePath");
QTest::addColumn<QString>("expectedLauncherSettingsFilePath");
QTest::addColumn<QString>("extensionsSettingsFilePath");
QTest::addColumn<QString>("expectedExtensionsSettingsFilePath");
QTest::newRow("existing absolute path - ini extension")
<< this->Tmp.filePath("settings.ini") << this->Tmp.filePath("settings.ini");
......@@ -1529,6 +1560,7 @@ void qSlicerExtensionsManagerModelTester::testExtensionAdditionalPathsSettingsUp
QFETCH(QStringList, modulePaths);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.updateModel();
......@@ -1679,7 +1711,7 @@ void qSlicerExtensionsManagerModelTester::testExtensionAdditionalPathsSettingsUp
}
// ----------------------------------------------------------------------------
void qSlicerExtensionsManagerModelTester::testExtensionLauncherSettingsUpdated()
void qSlicerExtensionsManagerModelTester::testExtensionExtensionsSettingsUpdated()
{
QSettings().setValue("Extensions/ServerUrl", QUrl::fromLocalFile(this->Tmp.absolutePath()));
QSettings().setValue("Extensions/InstallPath", this->Tmp.absolutePath());
......@@ -1694,9 +1726,9 @@ void qSlicerExtensionsManagerModelTester::testExtensionLauncherSettingsUpdated()
QFETCH(QString, pythonPath);
qSlicerExtensionsManagerModel model;
model.setExtensionsSettingsFilePath(QSettings().fileName());
model.setSlicerRequirements(slicerRevision, operatingSystem, architecture);
model.updateModel();
model.setLauncherSettingsFilePath(this->Tmp.filePath("launcherSettings.ini"));
QCOMPARE(model.numberOfInstalledExtensions(), extensionIdToUninstall.second == -1 ? 0 : 1);
if (extensionIdToUninstall.second >= 0)
......@@ -1712,22 +1744,22 @@ void qSlicerExtensionsManagerModelTester::testExtensionLauncherSettingsUpdated()
this->installHelper(&model, extensionIdToInstall.first, extensionIdToInstall.second, this->Tmp.absolutePath());
}
QSettings launcherSettings(model.launcherSettingsFilePath(), QSettings::IniFormat);
QSettings extensionsSettings(model.extensionsSettingsFilePath(), QSettings::IniFormat);
QStringList currentLibraryPath =
qSlicerExtensionsManagerModel::readArrayValues(launcherSettings, "LibraryPaths", "path");
qSlicerExtensionsManagerModel::readArrayValues(extensionsSettings, "LibraryPaths", "path");
QCOMPARE(currentLibraryPath, libraryPaths);
QStringList currentPaths =
qSlicerExtensionsManagerModel::readArrayValues(launcherSettings, "Paths", "path");
qSlicerExtensionsManagerModel::readArrayValues(extensionsSettings, "Paths", "path");
QCOMPARE(currentPaths, paths);
QString currentPythonPath = launcherSettings.value("EnvironmentVariables/PYTHONPATH").toString();
QString currentPythonPath = extensionsSettings.value("EnvironmentVariables/PYTHONPATH").toString();
QCOMPARE(currentPythonPath, pythonPath);
}
// ----------------------------------------------------------------------------
void qSlicerExtensionsManagerModelTester::testExtensionLauncherSettingsUpdated_data()
void qSlicerExtensionsManagerModelTester::testExtensionExtensionsSettingsUpdated_data()
{
QVERIFY(this->resetTmp());
......
......@@ -41,6 +41,9 @@
// - Slicer_BUILD_EXTENSIONMANAGER_SUPPORT
// - Slicer_BUILD_WIN32_CONSOLE
// - Slicer_BUILD_CLI_SUPPORT
// - Slicer_ORGANIZATION_DOMAIN
// - Slicer_ORGANIZATION_NAME
// - SLICER_REVISION_SPECIFIC_USER_SETTINGS_FILEBASENAME
#include "vtkSlicerConfigure.h"
#ifdef Slicer_USE_PYTHONQT
......@@ -101,7 +104,7 @@ qSlicerCoreApplicationPrivate::qSlicerCoreApplicationPrivate(
qSlicerCoreIOManager * coreIOManager) : q_ptr(&object)
{
qRegisterMetaType<qSlicerCoreApplication::ReturnCode>("qSlicerCoreApplication::ReturnCode");
this->Settings = 0;
this->UserSettings = 0;
this->ReturnCode = qSlicerCoreApplication::ExitNotRequested;
this->CoreCommandOptions = QSharedPointer<qSlicerCoreCommandOptions>(coreCommandOptions);
this->CoreIOManager = QSharedPointer<qSlicerCoreIOManager>(coreIOManager);
......@@ -146,8 +149,8 @@ void qSlicerCoreApplicationPrivate::init()
// is udpated solely using 'putenv(...)' function, 'Environment' won't be updated.
this->Environment = QProcessEnvironment::systemEnvironment();