3 * ModuleBase_ActionInfo.cpp
5 * Created on: Feb 4, 2015
9 #include <ModuleBase_ActionInfo.h>
11 ModuleBase_ActionInfo::ModuleBase_ActionInfo()
16 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QString &theText)
21 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QIcon & theIcon, const QString &theText)
28 ModuleBase_ActionInfo::~ModuleBase_ActionInfo()
32 void ModuleBase_ActionInfo::initFrom(QAction* theAction)
34 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
35 if (theAction->data().isValid()) {
36 id = theAction->data().toString();
38 checkable = theAction->isCheckable();
39 checked = theAction->isChecked();
40 enabled = theAction->isEnabled();
41 visible = theAction->isVisible();
42 icon = theAction->icon();
43 text = theAction->text();
44 iconText = theAction->iconText();
45 toolTip = theAction->toolTip();
46 // statusTip = theAction->statusTip();
47 // whatsThis = theAction->whatsThis();
48 shortcut = theAction->shortcut();
49 font = theAction->font();
52 void ModuleBase_ActionInfo::initFrom(std::shared_ptr<Config_FeatureMessage> theMessage)
54 id = QString::fromStdString(theMessage->id());
55 iconFile = QString::fromStdString(theMessage->icon());
56 if (!iconFile.isEmpty()) {
57 icon = QIcon(iconFile);
59 text = QString::fromStdString(theMessage->text());
60 toolTip = QString::fromStdString(theMessage->tooltip());
61 QString aShortcutStr = QString::fromStdString(theMessage->keysequence());
62 if (!aShortcutStr.isEmpty()) {
63 shortcut = QKeySequence(aShortcutStr);
65 // If feature requires PropertyPannel for input, it should be checkable
66 checkable = theMessage->isUseInput();
69 QAction* ModuleBase_ActionInfo::makeAction(QObject* theParent)
71 QAction* aResult = new QAction(icon, text, theParent);
72 aResult->setCheckable(checkable);
73 aResult->setChecked(checked);
74 aResult->setEnabled(enabled);
75 aResult->setVisible(visible);
76 aResult->setIconText(iconText);
77 aResult->setToolTip(toolTip);
78 // aResult->setStatusTip(statusTip);
79 // aResult->setWhatsThis(whatsThis);
80 aResult->setShortcut(shortcut);
81 aResult->setFont(font);
82 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
87 void ModuleBase_ActionInfo::initDefault()
99 // statusTip = QString();
100 // whatsThis = QString();
101 shortcut = QKeySequence();