#include <QPushButton>
-ModuleBase_Dialog::ModuleBase_Dialog(ModuleBase_IWorkshop* theParent, const QString& theId,
- const std::string& theDescription) :
+ModuleBase_Dialog::ModuleBase_Dialog(ModuleBase_IWorkshop* theParent,
+ const std::string& theDescription) :
QDialog(theParent->desktop(),
Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint),
- myId(theId),
myDescription(theDescription),
myWorkshop(theParent),
myActiveWidget(0)
{
+ Config_WidgetAPI aApi(myDescription, "");
+ myId = aApi.getProperty("id");
+
+ std::shared_ptr<Config_FeatureMessage> aFeatureInfo = myWorkshop->featureInfo(myId.c_str());
+ myHelpPage = aFeatureInfo->helpFileName();
+
ModuleBase_WidgetFactory aFactory(myDescription, myWorkshop);
QString aTitle = ModuleBase_Tools::translate("ModuleBase_Dialog",
aFactory.widgetAPI()->getProperty(FEATURE_TEXT));
SessionPtr aMgr = ModelAPI_Session::get();
std::shared_ptr<ModelAPI_Document> aDoc = aMgr->activeDocument();
- myFeature = aDoc->addFeature(myId.toStdString());
+ myFeature = aDoc->addFeature(myId);
if (!myFeature.get())
return;
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
QVBoxLayout* aLayout = new QVBoxLayout(this);
aLayout->setContentsMargins(0, 0, 0, 0);
aLayout->setSpacing(1);
- //setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred));
ModuleBase_PageWidget* aPage = new ModuleBase_PageWidget(this);
aLayout->addWidget(aPage);
ModuleBase_Tools::adjustMargins(aBtnLayout);
myButtonsBox = new QDialogButtonBox(
- QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, aFrame);
+ QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Help,
+ Qt::Horizontal, aFrame);
aBtnLayout->addWidget(myButtonsBox);
myButtonsBox->button(QDialogButtonBox::Ok)->setIcon(QIcon(":pictures/button_ok.png"));
myButtonsBox->button(QDialogButtonBox::Cancel)->setIcon(QIcon(":pictures/button_cancel.png"));
+ myButtonsBox->button(QDialogButtonBox::Help)->setIcon(QIcon(":pictures/button_help.png"));
connect(myButtonsBox, SIGNAL(accepted()), this, SLOT(accept()));
connect(myButtonsBox, SIGNAL(rejected()), this, SLOT(reject()));
+ connect(myButtonsBox, SIGNAL(helpRequested()), this, SLOT(onHelpRequest()));
foreach (ModuleBase_ModelWidget* aWidget, myWidgets) {
initializeWidget(aWidget);
}
QDialog::accept();
}
+
+void ModuleBase_Dialog::onHelpRequest()
+{
+ myWorkshop->showHelpPage(myHelpPage.c_str());
+}
/// \param theParent a workshop object instance
/// \param theId an Id of a feature
/// \param theDescription an XML description of the feature
- ModuleBase_Dialog(ModuleBase_IWorkshop* theParent, const QString& theId,
- const std::string& theDescription);
+ ModuleBase_Dialog(ModuleBase_IWorkshop* theParent, const std::string& theDescription);
/// Redefinition of virtual method
virtual void accept();
/// Redefinition of virtual method
virtual void showEvent(QShowEvent* theEvent);
+private slots:
+ void onHelpRequest();
+
private:
/// Initialising of the widget
void initializeWidget(ModuleBase_ModelWidget* theWidget);
/// Id of the feature
- QString myId;
+ std::string myId;
/// XML description of the feature
std::string myDescription;
/// Buttons of the dialog
QDialogButtonBox* myButtonsBox;
+
+ std::string myHelpPage;
};
#endif
SessionPtr aMgr = ModelAPI_Session::get();
aMgr->startOperation(theCmdId.toStdString());
- ModuleBase_Dialog aDlg(myWorkshop, theCmdId, aXmlCfg);
+ ModuleBase_Dialog aDlg(myWorkshop, aXmlCfg);
if (aDlg.exec() == QDialog::Accepted)
aMgr->finishOperation();
else
//! Returns current state of cancel button
virtual bool isCancelEnabled() const = 0;
+ //! Show help of a current operation
+ virtual void showHelpPage(const QString& thePage) const = 0;
+
signals:
/// Signal selection changed.
void selectionChanged();
}
return isEnabled;
}
+
+void XGUI_ModuleConnector::showHelpPage(const QString& thePage) const
+{
+ workshop()->showHelpPage(thePage);
+}
//! Returns current state of cancel button
virtual bool isCancelEnabled() const;
+ //! Show help of a current operation
+ virtual void showHelpPage(const QString& thePage) const;
+
private:
QObjectPtrList activeObjects(const QObjectPtrList& theObjList) const;
//******************************************************
-void XGUI_Workshop::onHelpActionClicked()
+void XGUI_Workshop::onHelpActionClicked() const
{
XGUI_OperationMgr* anOperationMgr = operationMgr();
if (anOperationMgr) {
ModuleBase_Operation* aOperation = anOperationMgr->currentOperation();
if (aOperation) {
- QString aHelpPage = aOperation->helpFileName();
- if (!aHelpPage.isEmpty()) {
- QString aDocDir;
- const QChar aSep = QDir::separator();
+ showHelpPage(aOperation->helpFileName());
+ }
+ }
+}
+
+void XGUI_Workshop::showHelpPage(const QString& thePage) const
+{
+ if (!thePage.isEmpty()) {
+ QString aDocDir;
+ const QChar aSep = QDir::separator();
// QString platform;
// SUIT_ResourceMgr* aResMgr = ModuleBase_Preferences::resourceMgr();
//#ifdef WIN32
// QString aBrowserName = aResMgr->stringValue("ExternalBrowser", platform);
#ifdef HAVE_SALOME
- QString aDir(getenv("SHAPER_ROOT_DIR"));
- if (!aDir.isEmpty()) {
- aDocDir = aDir + aSep + "share" + aSep + "doc" + aSep +
- "salome" + aSep + "gui" + aSep + "SHAPER";
- }
+ QString aDir(getenv("SHAPER_ROOT_DIR"));
+ if (!aDir.isEmpty()) {
+ aDocDir = aDir + aSep + "share" + aSep + "doc" + aSep +
+ "salome" + aSep + "gui" + aSep + "SHAPER";
+ }
#else
- QString aDir(getenv("CADBUILDER_ROOT_DIR"));
- aDocDir = aDir + aSep + "doc" + aSep + "gui";
+ QString aDir(getenv("CADBUILDER_ROOT_DIR"));
+ aDocDir = aDir + aSep + "doc" + aSep + "gui";
#endif
- QString aFileName = aDocDir + aSep + aHelpPage;
- if (QFile::exists(aFileName)) {
- QUrl aUrl = QUrl::fromLocalFile(aFileName);
- QDesktopServices::openUrl(aUrl);
- }
- }
+ QString aFileName = aDocDir + aSep + thePage;
+ if (QFile::exists(aFileName)) {
+ QUrl aUrl = QUrl::fromLocalFile(aFileName);
+ QDesktopServices::openUrl(aUrl);
}
}
}
/// The method updates a Color Scale object in the viewer
void updateColorScaleVisibility();
+ void showHelpPage(const QString& thePage) const;
+
signals:
/// Emitted when selection happens in Salome viewer
void salomeViewerSelection();
void onPreviewActionClicked();
/// Called on help button clicked in the property panel.
- void onHelpActionClicked();
+ void onHelpActionClicked() const;
//! The slot is called only once on resizing of Object Browser
void onDockSizeChanged();