1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 * ModuleBase_ActionInfo.cpp
5 * Created on: Feb 4, 2015
9 #include <ModuleBase_ActionInfo.h>
10 #include <ModuleBase_IconFactory.h>
11 #include <ModuleBase_Tools.h>
13 ModuleBase_ActionInfo::ModuleBase_ActionInfo()
18 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QString &theText)
23 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QIcon & theIcon, const QString &theText)
30 ModuleBase_ActionInfo::~ModuleBase_ActionInfo()
34 void ModuleBase_ActionInfo::initFrom(QAction* theAction)
36 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
37 if (theAction->data().isValid()) {
38 id = theAction->data().toString();
40 checkable = theAction->isCheckable();
41 checked = theAction->isChecked();
42 enabled = theAction->isEnabled();
43 visible = theAction->isVisible();
44 icon = theAction->icon();
45 text = theAction->text();
46 iconText = theAction->iconText();
47 toolTip = theAction->toolTip();
48 // statusTip = theAction->statusTip();
49 // whatsThis = theAction->whatsThis();
50 shortcut = theAction->shortcut();
51 font = theAction->font();
54 void ModuleBase_ActionInfo::initFrom(std::shared_ptr<Config_FeatureMessage> theMessage)
56 id = QString::fromStdString(theMessage->id());
57 iconFile = QString::fromStdString(theMessage->icon());
58 if (!iconFile.isEmpty()) {
59 icon = ModuleBase_IconFactory::loadIcon(iconFile);
61 text = QString::fromUtf8(theMessage->text().c_str());
62 toolTip = QString::fromUtf8(theMessage->tooltip().c_str());
63 QString aShortcutStr = QString::fromStdString(theMessage->keysequence());
64 if (!aShortcutStr.isEmpty()) {
65 shortcut = QKeySequence(aShortcutStr);
67 // If feature requires PropertyPannel for input, it should be checkable
68 checkable = theMessage->isUseInput();
69 // If Feature requires modal Dialog box for input
70 modal = theMessage->isModal();
73 void ModuleBase_ActionInfo::initDefault()
85 // statusTip = QString();
86 // whatsThis = QString();
87 shortcut = QKeySequence();