HomePhabricator
Diffusion MITK 207ecdb75531

Move BlueBerry preferences to MITK Core services

Description

Move BlueBerry preferences to MITK Core services

Summary:
The preferences core service completely replaces the current preferences service of BlueBerry,
making preferences finally available in modules.

Migration is straight forward, as the interface of the core preferences service is as equal as
possible to the BlueBerry preferences service.

The only difference is the replacement of Qt types with std types, in particular the replacement of
QString with std::string.

You may want to adapt your string types when migrating to the new service or use methods like
QString::fromStdString() and QString::toStdString(). In other occasions where std strings
have been used already, you can remove conversions like std::string::c_str() that are
not necessary anymore.

While migrating the BlueBerry preferences we noticed that quite a few functionalities were
never fully implemented, erroneous, or completely unused. We took the opportunity to remove
them. In the uncertain case you miss such a previous "feature" that you assumed to work fine
for you, give us a note to double check.

Retrieving and using the new core preferences service is easy:

#include <mitkCoreServices.h>
#include <mitkIPreferencesService.h>
#include <mitkIPreferences.h>

auto* preferencesService = mitk::CoreServices::GetPreferencesService();
auto* preferences = preferencesService->GetSystemPreferences();

auto myPreference = preferences->Get("my preference", "default value"); // std::string

When you use the core preferences service in an MITK plugin, make sure that you initialize the CppMicroServices. The perfect location for this is in a plugin activator class:

PluginActivator.cpp
#include <usModuleInitialization.h>

US_INITIALIZE_MODULE

Fixes T29025

Test Plan: Monkey test preferences in several plugins and the preferences dialog.

Reviewers: O3 MITK Reviewer Group II!, O1 MITK Reviewer Group I!

Subscribers: floca, kalali

Tags: Breaking Change

Maniphest Tasks: T29025

Differential Revision: https://phabricator.mitk.org/D763

Details

Provenance
kislinskAuthored on Dec 13 2022, 10:21 AM
kislinskPushed on Dec 13 2022, 10:22 AM
Differential Revision
Restricted Differential Revision
Parents
rMITK952b9648480a: Move BlueBerry preferences to MITK Core services
rMITKefe2ad43c5eb: Make CanHandle functions more consistent
Branches
Unknown
Tags
Unknown
Tasks
T29025: Preference service (access) based on cpp microservices