1 // Copyright (C) 2014-2019 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 email : webmaster.salome@opencascade.com
20 #include <ModuleBase_ActionInfo.h>
21 #include <ModuleBase_IconFactory.h>
22 #include <ModuleBase_Tools.h>
24 ModuleBase_ActionInfo::ModuleBase_ActionInfo()
29 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QString &theText)
34 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QIcon & theIcon, const QString &theText)
41 ModuleBase_ActionInfo::~ModuleBase_ActionInfo()
45 void ModuleBase_ActionInfo::initFrom(QAction* theAction)
47 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
48 if (theAction->data().isValid()) {
49 id = theAction->data().toString();
51 checkable = theAction->isCheckable();
52 checked = theAction->isChecked();
53 enabled = theAction->isEnabled();
54 visible = theAction->isVisible();
55 icon = theAction->icon();
56 text = theAction->text();
57 iconText = theAction->iconText();
58 toolTip = theAction->toolTip();
59 // statusTip = theAction->statusTip();
60 // whatsThis = theAction->whatsThis();
61 shortcut = theAction->shortcut();
62 font = theAction->font();
65 void ModuleBase_ActionInfo::initFrom(std::shared_ptr<Config_FeatureMessage> theMessage)
67 id = QString::fromStdString(theMessage->id());
68 iconFile = QString::fromStdString(theMessage->icon());
69 if (!iconFile.isEmpty()) {
70 icon = ModuleBase_IconFactory::loadIcon(iconFile);
72 text = QString::fromUtf8(theMessage->text().c_str());
73 toolTip = QString::fromUtf8(theMessage->tooltip().c_str());
74 toolBar = QString::fromStdString(theMessage->toolBarId());
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();