1 #include "SUIT_PagePrefShortcutTreeItem.h"
3 #include "SUIT_ShortcutTree.h"
4 #include "SUIT_ShortcutMgr.h"
8 \brief Creates preference item for editing of key bindings
9 \param theParent parent preference item. Must not be nullptr.
11 SUIT_PagePrefShortcutTreeItem::SUIT_PagePrefShortcutTreeItem(QtxPreferenceItem* theParent)
12 : QtxPagePrefItem(QString(), theParent)
14 auto container = std::shared_ptr<SUIT_ShortcutContainer>();
15 const auto itContainers = SUIT_PagePrefShortcutTreeItem::shortcutContainers.find(rootItem());
16 if (itContainers == SUIT_PagePrefShortcutTreeItem::shortcutContainers.end()) {
17 container.reset(new SUIT_ShortcutContainer());
18 SUIT_PagePrefShortcutTreeItem::shortcutContainers.emplace(rootItem(), container);
21 container = itContainers->second.lock();
23 container.reset(new SUIT_ShortcutContainer());
24 itContainers->second = container;
28 SUIT_ShortcutTree* tree = new SUIT_ShortcutTree(container);
29 tree->myModuleIDs = SUIT_ShortcutMgr::get()->getShortcutModuleIDs();
34 \brief Retrieves shortcut preferences from ShortcutMgr.
35 Updates UI of controlling widget.
38 void SUIT_PagePrefShortcutTreeItem::retrieve()
40 static_cast<SUIT_ShortcutTree*>(widget())->setShortcutsFromManager();
44 \brief Retrieves shortcut preferences from resource files, ignoring user preferences.
45 Updates UI of controlling widget.
48 void SUIT_PagePrefShortcutTreeItem::retrieveDefault()
50 static_cast<SUIT_ShortcutTree*>(widget())->setDefaultShortcuts();
54 \brief Applies modified shortcut preferences to ShortcutMgr.
55 Updates UI of controlling widget.
56 And ShortcutMgr, in turn, serilizes shortcut preferences using the resource manager.
59 void SUIT_PagePrefShortcutTreeItem::store()
61 static_cast<SUIT_ShortcutTree*>(widget())->applyChangesToShortcutMgr();
64 /*static*/ std::map<QtxPreferenceItem*, std::weak_ptr<SUIT_ShortcutContainer>> SUIT_PagePrefShortcutTreeItem::shortcutContainers =
65 std::map<QtxPreferenceItem*, std::weak_ptr<SUIT_ShortcutContainer>>();