aResult->setVisible(visible);
aResult->setIconText(iconText);
aResult->setToolTip(toolTip);
- // aResult->setStatusTip(statusTip);
+ aResult->setStatusTip(toolTip);
// aResult->setWhatsThis(whatsThis);
aResult->setShortcut(shortcut);
aResult->setFont(font);
//! \param theValues a list of presentations
virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues) = 0;
+ //! Shows the message in the status bar
+ //! \param theMessage a message
+ virtual void setStatusBarMessage(const QString& theMessage) = 0;
+
/// Update of commands status
virtual void updateCommandStatus() = 0;
#include <QColor>
#include <QApplication>
#include <QMessageBox>
+#include <QAction>
#include <sstream>
#include <string>
theSpin->blockSignals(isBlocked);
}
+QAction* createAction(const QIcon& theIcon, const QString& theText,
+ QObject* theParent, const QObject* theReceiver,
+ const char* theMember, const QString& theToolTip,
+ const QString& theStatusTip)
+{
+ QAction* anAction = new QAction(theIcon, theText, theParent);
+ anAction->setToolTip(theToolTip.isEmpty() ? theText : theToolTip);
+ anAction->setStatusTip(!theStatusTip.isEmpty() ? theStatusTip :
+ (!theToolTip.isEmpty() ? theToolTip : theText));
+ if (theReceiver)
+ QObject::connect(anAction, SIGNAL(triggered(bool)), theReceiver, theMember);
+
+ return anAction;
+}
+
QString objectInfo(const ObjectPtr& theObj, const bool isUseAttributesInfo)
{
QString aFeatureStr = "feature";
#include <Quantity_Color.hxx>
+#include <QIcon>
#include <QPixmap>
#include <map>
class QWidget;
class QLayout;
class QDoubleSpinBox;
+class QAction;
class ModuleBase_ParamIntSpinBox;
class ModuleBase_ParamSpinBox;
class ModuleBase_IWorkshop;
/// \param theText a new value
MODULEBASE_EXPORT void setSpinText(ModuleBase_ParamIntSpinBox* theSpin, const QString& theText);
+/// Creates an action filled with the parameters
+/// \param theIcon an action icon
+/// \param theText an icon text
+/// \param theParent an action object
+/// \param theReceiver an object to process action triggered signal
+/// \param theMember a slot to process the action triggered signal
+/// \param theToolTip an action tool tip information, if empty the text is used
+/// \param theStatusTip an action status tip information, if empty the text is used
+MODULEBASE_EXPORT QAction* createAction(const QIcon& theIcon, const QString& theText,
+ QObject* theParent, const QObject* theReceiver = 0,
+ const char* theMember = "",
+ const QString& theToolTip = QString(),
+ const QString& theStatusTip = QString());
+
/// Converts the object to the feature or a result and generate information string
/// \param theObj an object
/// \param isUseAttributesInfo a flag whether the attribute values information is used
//this->setLayout(aMainLay);
connect(myTypeCombo, SIGNAL(currentIndexChanged(int)), this, SLOT(onSelectionTypeChanged()));
- myCopyAction = new QAction(QIcon(":pictures/copy.png"), tr("Copy"), this);
+ myCopyAction = ModuleBase_Tools::createAction(QIcon(":pictures/copy.png"), tr("Copy"), this,
+ this, SLOT(onCopyItem()));
myCopyAction->setShortcut(QKeySequence::Copy);
myCopyAction->setEnabled(false);
- connect(myCopyAction, SIGNAL(triggered(bool)), SLOT(onCopyItem()));
myListControl->addAction(myCopyAction);
- myDeleteAction = new QAction(QIcon(":pictures/delete.png"), tr("Delete"), this);
+ myDeleteAction = ModuleBase_Tools::createAction(QIcon(":pictures/delete.png"), tr("Delete"), this,
+ this, SLOT(onDeleteItem()));
myDeleteAction->setEnabled(false);
- connect(myDeleteAction, SIGNAL(triggered(bool)), SLOT(onDeleteItem()));
myListControl->addAction(myDeleteAction);
myListControl->setContextMenuPolicy(Qt::ActionsContextMenu);
#include <ModuleBase_OperationAction.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModuleBase_Tools.h>
#include <XGUI_ModuleConnector.h>
#include <XGUI_Workshop.h>
{
QAction* aAction;
- aAction = new QAction(tr("Auxiliary"), this);
+ aAction = ModuleBase_Tools::createAction(QIcon(), tr("Auxiliary"), this);
aAction->setCheckable(true);
addAction("AUXILIARY_CMD", aAction);
- aAction = new QAction(QIcon(":icons/activate.png"), tr("Activate"), this);
- connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePart(bool)));
+ aAction = ModuleBase_Tools::createAction(QIcon(":icons/activate.png"), tr("Activate"), this,
+ this, SLOT(onActivatePart(bool)));
myActions["ACTIVATE_PART_CMD"] = aAction;
// Activate PartSet
- aAction = new QAction(QIcon(":icons/activate.png"), tr("Activate"), this);
- connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onActivatePartSet(bool)));
+ aAction = ModuleBase_Tools::createAction(QIcon(":icons/activate.png"), tr("Activate"), this,
+ this, SLOT(onActivatePartSet(bool)));
myActions["ACTIVATE_PARTSET_CMD"] = aAction;
- aAction = new QAction(QIcon(":icons/edit.png"), tr("Edit..."), this);
- connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onEdit(bool)));
+ aAction = ModuleBase_Tools::createAction(QIcon(":icons/edit.png"), tr("Edit..."), this,
+ this, SLOT(onEdit(bool)));
myActions["EDIT_CMD"] = aAction;
}
#include <ModuleBase_Operation.h>
#include <ModuleBase_OperationFeature.h>
#include <ModuleBase_SelectionValidator.h>
+#include <ModuleBase_Tools.h>
#include <QAction>
switch (theId) {
case Accept:
case AcceptAll: {
- aResult = new QAction(QIcon(":pictures/button_ok.png"), "", theParent);
- aResult->setToolTip("Apply");
+ aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_ok.png"),
+ "", /*empty to show error*/, theParent);
}
break;
case Abort:
case AbortAll: {
- aResult = new QAction(QIcon(":pictures/button_cancel.png"), "", theParent);
- aResult->setToolTip("Cancel");
+ aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_cancel.png"), "Cancel",
+ theParent);
if (theId == Abort) {
aResult->setShortcut(QKeySequence(Qt::Key_Escape));
}
}
break;
case Help: {
- aResult = new QAction(QIcon(":pictures/button_help.png"), "", theParent);
- aResult->setToolTip("Help");
+ aResult = ModuleBase_Tools::createAction(QIcon(":pictures/button_help.png"), "Help",
+ theParent);
}
break;
case Preview: {
- aResult = new QAction("See preview", theParent);
- aResult->setToolTip("Compute preview");
+ aResult = ModuleBase_Tools::createAction(QIcon(), tr("See preview"), theParent, 0, 0, "Compute preview");
+ aResult->setStatusTip(aResult->toolTip());
}
break;
default:
XGUI_ErrorMgr::~XGUI_ErrorMgr()
{
-
}
void XGUI_ErrorMgr::updateActions(const FeaturePtr& theFeature)
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(workshop()->operationMgr()->currentOperation());
if (aFOperation && aFOperation->feature() == theFeature) {
- QAction* anOkAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
-
ModuleBase_ModelWidget* anActiveWidget = activeWidget();
bool isApplyEnabledByActiveWidget = false;
if (anActiveWidget)
if (anError.isEmpty())
anError = aWidgetError;
}
- updateActionState(anOkAction, anError);
+ updateAcceptActionState(anError);
updateToolTip(anActiveWidget, aWidgetError);
+ myWorkshop->setStatusBarMessage(anError);
#ifdef DEBUG_ERROR_STATE
QString anInfo = ModuleBase_Tools::objectInfo(theFeature);
return isEnabled;
}
-void XGUI_ErrorMgr::updateActionState(QAction* theAction, const QString& theError)
+void XGUI_ErrorMgr::updateAcceptActionState(const QString& theError)
{
+ XGUI_ActionsMgr* anActionsMgr = workshop()->actionsMgr();
+ QAction* anAcceptAction = anActionsMgr->operationStateAction(XGUI_ActionsMgr::Accept);
+
bool anEnabled = theError.isEmpty();
- theAction->setEnabled(anEnabled);
- theAction->setToolTip(anEnabled ? myAcceptToolTip : theError);
+ anAcceptAction->setEnabled(anEnabled);
+ anAcceptAction->setToolTip(anEnabled ? myAcceptToolTip : theError);
// some operations have no property panel, so it is important to check that it is not null
if (myPropertyPanel) {
// update controls error information
virtual void onWidgetChanged();
private:
- /// It disables the action if the error message is not empty
+ /// It disables the propety panel Accept action if the error message is not empty
/// The message is set to the header tool tip.
/// \param theAction an action to be changed
/// \param theError an error state
- void updateActionState(QAction* theAction, const QString& theError);
+ void updateAcceptActionState(const QString& theError);
/// It updates the tool tip of the widget controls according to the widget error
/// \param theWidget a widget
}
}
+#include <QMainWindow>
+#include <QStatusBar>
+void XGUI_ModuleConnector::setStatusBarMessage(const QString& theMessage)
+{
+#ifdef HAVE_SALOME
+ //return myWorkshop->salomeConnector()->featureInfo(theId);
+#else
+ QMainWindow* aDesktop = desktop();
+ aDesktop->statusBar()->showMessage(theMessage);
+
+#endif
+}
+
bool XGUI_ModuleConnector::canStartOperation(QString theId)
{
return myWorkshop->operationMgr()->canStartOperation(theId);
//! If the list is empty then selection will be cleared
virtual void setSelected(const QList<std::shared_ptr<ModuleBase_ViewerPrs>>& theValues);
+ //! Shows the message in the status bar
+ //! \param theMessage a message
+ virtual void setStatusBarMessage(const QString& theMessage);
+
/// Update of commands status
virtual void updateCommandStatus();