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 email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
21 * ModuleBase_ActionInfo.cpp
23 * Created on: Feb 4, 2015
27 #include <ModuleBase_ActionInfo.h>
28 #include <ModuleBase_IconFactory.h>
29 #include <ModuleBase_Tools.h>
31 ModuleBase_ActionInfo::ModuleBase_ActionInfo()
36 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QString &theText)
41 ModuleBase_ActionInfo::ModuleBase_ActionInfo(const QIcon & theIcon, const QString &theText)
48 ModuleBase_ActionInfo::~ModuleBase_ActionInfo()
52 void ModuleBase_ActionInfo::initFrom(QAction* theAction)
54 // By convenience, QAction for a feature keeps feature's id as data (QVariant);
55 if (theAction->data().isValid()) {
56 id = theAction->data().toString();
58 checkable = theAction->isCheckable();
59 checked = theAction->isChecked();
60 enabled = theAction->isEnabled();
61 visible = theAction->isVisible();
62 icon = theAction->icon();
63 text = theAction->text();
64 iconText = theAction->iconText();
65 toolTip = theAction->toolTip();
66 // statusTip = theAction->statusTip();
67 // whatsThis = theAction->whatsThis();
68 shortcut = theAction->shortcut();
69 font = theAction->font();
72 void ModuleBase_ActionInfo::initFrom(std::shared_ptr<Config_FeatureMessage> theMessage)
74 id = QString::fromStdString(theMessage->id());
75 iconFile = QString::fromStdString(theMessage->icon());
76 if (!iconFile.isEmpty()) {
77 icon = ModuleBase_IconFactory::loadIcon(iconFile);
79 text = QString::fromUtf8(theMessage->text().c_str());
80 toolTip = QString::fromUtf8(theMessage->tooltip().c_str());
81 QString aShortcutStr = QString::fromStdString(theMessage->keysequence());
82 if (!aShortcutStr.isEmpty()) {
83 shortcut = QKeySequence(aShortcutStr);
85 // If feature requires PropertyPannel for input, it should be checkable
86 checkable = theMessage->isUseInput();
87 // If Feature requires modal Dialog box for input
88 modal = theMessage->isModal();
91 void ModuleBase_ActionInfo::initDefault()
100 iconText = QString();
101 iconFile = QString();
103 // statusTip = QString();
104 // whatsThis = QString();
105 shortcut = QKeySequence();