2 * ModuleBase_ActionInfo.cpp
4 * Created on: Feb 4, 2015
8 #include <ModuleBase_ActionInfo.h>
10 ModuleBase_ActionInfo::ModuleBase_ActionInfo()
15 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QString &theText)
20 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QIcon & theIcon, const QString &theText)
27 ModuleBase_ActionInfo::~ModuleBase_ActionInfo()
31 void ModuleBase_ActionInfo::initFrom(QAction* theAction)
33 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
34 if (theAction->data().isValid()) {
35 id = theAction->data().toString();
37 checkable = theAction->isCheckable();
38 checked = theAction->isChecked();
39 enabled = theAction->isEnabled();
40 visible = theAction->isVisible();
41 icon = theAction->icon();
42 text = theAction->text();
43 iconText = theAction->iconText();
44 toolTip = theAction->toolTip();
45 // statusTip = theAction->statusTip();
46 // whatsThis = theAction->whatsThis();
47 shortcut = theAction->shortcut();
48 font = theAction->font();
51 void ModuleBase_ActionInfo::initFrom(std::shared_ptr<Config_FeatureMessage> theMessage)
53 id = QString::fromStdString(theMessage->id());
54 iconFile = QString::fromStdString(theMessage->icon());
55 if (!iconFile.isEmpty()) {
56 icon = QIcon(iconFile);
58 text = QString::fromStdString(theMessage->text());
59 toolTip = QString::fromStdString(theMessage->tooltip());
60 QString aShortcutStr = QString::fromStdString(theMessage->keysequence());
61 if (!aShortcutStr.isEmpty()) {
62 shortcut = QKeySequence(aShortcutStr);
64 // If feature requires PropertyPannel for input, it should be checkable
65 checkable = theMessage->isUseInput();
68 QAction* ModuleBase_ActionInfo::makeAction(QObject* theParent)
70 QAction* aResult = new QAction(icon, text, theParent);
71 aResult->setCheckable(checkable);
72 aResult->setChecked(checked);
73 aResult->setEnabled(enabled);
74 aResult->setVisible(visible);
75 aResult->setIconText(iconText);
76 aResult->setToolTip(toolTip);
77 // aResult->setStatusTip(statusTip);
78 // aResult->setWhatsThis(whatsThis);
79 aResult->setShortcut(shortcut);
80 aResult->setFont(font);
81 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
86 void ModuleBase_ActionInfo::initDefault()
98 // statusTip = QString();
99 // whatsThis = QString();
100 shortcut = QKeySequence();