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