1 // Copyright (C) 2014-2017 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or
18 // email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 #include <ModuleBase_ActionInfo.h>
22 #include <ModuleBase_IconFactory.h>
23 #include <ModuleBase_Tools.h>
25 ModuleBase_ActionInfo::ModuleBase_ActionInfo()
30 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QString &theText)
35 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QIcon & theIcon, const QString &theText)
42 ModuleBase_ActionInfo::~ModuleBase_ActionInfo()
46 void ModuleBase_ActionInfo::initFrom(QAction* theAction)
48 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
49 if (theAction->data().isValid()) {
50 id = theAction->data().toString();
52 checkable = theAction->isCheckable();
53 checked = theAction->isChecked();
54 enabled = theAction->isEnabled();
55 visible = theAction->isVisible();
56 icon = theAction->icon();
57 text = theAction->text();
58 iconText = theAction->iconText();
59 toolTip = theAction->toolTip();
60 // statusTip = theAction->statusTip();
61 // whatsThis = theAction->whatsThis();
62 shortcut = theAction->shortcut();
63 font = theAction->font();
66 void ModuleBase_ActionInfo::initFrom(std::shared_ptr<Config_FeatureMessage> theMessage)
68 id = QString::fromStdString(theMessage->id());
69 iconFile = QString::fromStdString(theMessage->icon());
70 if (!iconFile.isEmpty()) {
71 icon = ModuleBase_IconFactory::loadIcon(iconFile);
73 text = QString::fromUtf8(theMessage->text().c_str());
74 toolTip = QString::fromUtf8(theMessage->tooltip().c_str());
75 QString aShortcutStr = QString::fromStdString(theMessage->keysequence());
76 if (!aShortcutStr.isEmpty()) {
77 shortcut = QKeySequence(aShortcutStr);
79 // If feature requires PropertyPannel for input, it should be checkable
80 checkable = theMessage->isUseInput();
81 // If Feature requires modal Dialog box for input
82 modal = theMessage->isModal();
85 void ModuleBase_ActionInfo::initDefault()
97 // statusTip = QString();
98 // whatsThis = QString();
99 shortcut = QKeySequence();