Version: 9.15.0
SUIT_ShortcutHistorian Class Reference

Sometimes developers change IDs of actions. And at the moment of release of these changes users may already have cutomized shortcuts. SUIT_ShortcutHistorian assits with user defined shorcut settings' migrations. It retrieves keysequences, assigned to actions by user using older Salome versions, which operated with old action ID sets. "Action ID set" is also referred as AIDS for brevity. More...

#include <SUIT_ShortcutMgr.h>

Classes

class  AIDSMutation
 Describes how action IDs evolved between consequtive versions of action ID sets. PS. Once upon a time I also wanted to cure AIDS. But instead I spawned new ones. With mutations. More...
 

Public Member Functions

 SUIT_ShortcutHistorian ()
 
bool doOldShortcutPreferencesExist () const
 
QString getActionID (const QString &theOldActionID, const QString &theOldSectionPrefix) const
 Evolves theOldActionID defined in section theOldSectionPrefix. More...
 
std::pair< bool, QKeySequence > getOldUserDefinedKeySequence (const QString &theActionID) const
 
const SUIT_ShortcutContainergetContainerWithOldShortcuts () const
 
void removeOldShortcutPreferences ()
 Removes old shortcut sections from preference files and clears myShortcutContainers. More...
 

Static Public Attributes

static const std::vector< QString > SECTION_PREFIX_EVOLUTION = {"shortcuts_vA1.0", "shortcuts"}
 {name prefix of a section in user preference files}[]. More...
 

Private Member Functions

void parseMutations ()
 
std::pair< bool, QKeySequence > getKeySequenceFromSection (const QString &theActionID, const QString &theSectionPrefix) const
 

Private Attributes

std::list< std::pair< QString, SUIT_ShortcutHistorian::AIDSMutation > > myOldPrefixToMutationList
 {sectionNamePrefixOld, mutation}[]. More...
 
std::map< QString, SUIT_ShortcutContainermyShortcutContainers
 {sectionNamePrefixOld, shortcutContainer}[]. More...
 
SUIT_ShortcutContainer myShortcutContainer
 Merged myShortcutContainers. More...
 

Detailed Description

Sometimes developers change IDs of actions. And at the moment of release of these changes users may already have cutomized shortcuts. SUIT_ShortcutHistorian assits with user defined shorcut settings' migrations. It retrieves keysequences, assigned to actions by user using older Salome versions, which operated with old action ID sets. "Action ID set" is also referred as AIDS for brevity.

HOW TO USE Use the guide, if action IDs have been changed or some action have been removed. If new actions have been added, no need to make anything related to SUIT_ShortcutHistorian.

1) Go to action_assets.json files and change assets accordingly. Remove assets of removed actions.

2) Come up with a new prefix for shortcut sections' name in preference files. At the moment of writing, the prefix is "shortcuts_vA1.0". The prefix must not contain ":" character - the character delimits prefix from module ID. Append the new prefix to SUIT_ShortcutHistorian::SECTION_PREFIX_EVOLUTION list. All prefixes in the list must be unique.

3) Go to default preference files (.xml, or .xml.in). Change an old prefix to the new one. Change old action IDs to new ones. Remove shorcuts of removed actions.

4) Compose/modify action_id_mutations.json files. Add an entry, structured as shown below, to "mutations" array. A) <OLD_SHORTCUT_PREFIX> and <NEW_SHORTCUT_PREFIX> must be consecutive prefixes from SUIT_ShortcutHistorian::SECTION_PREFIX_EVOLUTION. B) Sorting or mutations array does not matter. C) If no IDs were changed/removed between shortcut versions "L" and "N", there is no need to add mutations "L==>L+1", "L+1==>L+2", ..., "N-1==>N". D) Mutations also handle move of an action to another module: "oldToNewActionIDMap" contains action IDs, which are composed of a moduleID and an inModuleActionID. E) If an action has been removed, put an empty ID after its <moduleID/inModuleActionID>.

{ "sectionPrefixOld": "OLD_SHORTCUT_PREFIX", "sectionPrefixNew": "NEW_SHORTCUT_PREFIX, "oldToNewActionIDMap": { "MODULE_ID_1/OLD_IN_MODULE_ACTION_ID_1" : "MODULE_ID_1/MODIFIED_IN_MODULE_ACTION_ID_1", "MODULE_ID_1/OLD_IN_MODULE_ACTION_ID_2" : "MODULE_ID_2/MODIFIED_IN_MODULE_ACTION_ID_2", "MODULE_ID_1/REMOVED_IN_MODULE_ACTION_ID" : "" } }

5) If action_id_mutations.json has just been created, put a path to it into a default preference file, section "actionID_mutations", e.g.:

<section name="actionID_mutations"> <parameter name="%GEOM_ROOT_DIR%/share/salome/resources/geom/action_id_mutations.json" value=""> </section> HOW IT WORKS 1) During the SUIT_ShortcutMgr initialization an instance of SUIT_ShortcutHistorian is created. 2) The SUIT_ShortcutHistorian instance goes through the SUIT_ShortcutHistorian::SECTION_PREFIX_EVOLUTION and parses old shortcut sections of user preference file (~/.config/salome/SalomeApprc.9.11.0 on Linux). 3) Using mutation data, it replaces old action IDs with actual ones, and merges them into single SUIT_ShortcutContainer. Newer shortcuts override older ones. 4) Merges migrated shortcut container into an actual one. Migrated shortcuts override actual ones. 5) Updates actual shortcut section of user preference file. 6) Erases old shortcut sections of user preference file.

Constructor & Destructor Documentation

◆ SUIT_ShortcutHistorian()

Member Function Documentation

◆ doOldShortcutPreferencesExist()

bool SUIT_ShortcutHistorian::doOldShortcutPreferencesExist ( ) const
Returns
True, if myShortcutContainers has at least one shortcut.

◆ getActionID()

QString SUIT_ShortcutHistorian::getActionID ( const QString &  theOldActionID,
const QString &  theOldSectionPrefix 
) const

Evolves theOldActionID defined in section theOldSectionPrefix.

Returns
Empty string, if theOldSectionPrefix is not defined in SUIT_ShortcutHistorian::SECTION_PREFIX_EVOLUTION.

References SECTION_NAME_PREFIX.

◆ getContainerWithOldShortcuts()

const SUIT_ShortcutContainer& SUIT_ShortcutHistorian::getContainerWithOldShortcuts ( ) const
inline

◆ getKeySequenceFromSection()

std::pair< bool, QKeySequence > SUIT_ShortcutHistorian::getKeySequenceFromSection ( const QString &  theActionID,
const QString &  theSectionPrefix 
) const
private
Parameters
theSectionPrefixUser preferences' section name with shortcuts.
Returns
{false, _ }, is the shortcut is not defined in the section.

References SUIT_ShortcutMgr::splitIntoModuleIDAndInModuleID().

◆ getOldUserDefinedKeySequence()

std::pair< bool, QKeySequence > SUIT_ShortcutHistorian::getOldUserDefinedKeySequence ( const QString &  theActionID) const
Parameters
theActionIDAction ID in latest version (as elsewhere in ShortcutMgr code).
Returns
{false, _ }, if shortcut is not defined in any outdated shortcut section of user preference files.

ID of the same action before a mutation (migration) happened.

◆ parseMutations()

◆ removeOldShortcutPreferences()

void SUIT_ShortcutHistorian::removeOldShortcutPreferences ( )

Removes old shortcut sections from preference files and clears myShortcutContainers.

References QtxResourceMgr::remove(), SUIT_Session::resourceMgr(), QtxResourceMgr::sectionsToken(), SUIT_Session::session(), ShCutDbg(), and Warning().

Member Data Documentation

◆ myOldPrefixToMutationList

std::list<std::pair<QString, SUIT_ShortcutHistorian::AIDSMutation> > SUIT_ShortcutHistorian::myOldPrefixToMutationList
private

{sectionNamePrefixOld, mutation}[].

Sorted from the newest to the oldest.

◆ myShortcutContainer

SUIT_ShortcutContainer SUIT_ShortcutHistorian::myShortcutContainer
private

Merged myShortcutContainers.

Merge is performed from the oldest to the newest, newer shortcuts override older ones.

◆ myShortcutContainers

std::map<QString, SUIT_ShortcutContainer> SUIT_ShortcutHistorian::myShortcutContainers
private

{sectionNamePrefixOld, shortcutContainer}[].

◆ SECTION_PREFIX_EVOLUTION

const std::vector< QString > SUIT_ShortcutHistorian::SECTION_PREFIX_EVOLUTION = {"shortcuts_vA1.0", "shortcuts"}
static

{name prefix of a section in user preference files}[].

Sorted from the newest to the oldest. The list is hardcoded. Update it every time, a new AIDS and appropriate AIDSMutation are added.


The documentation for this class was generated from the following files: