const static char* DOUBLE_WDG_DEFAULT_COMPUTED = "computed";
// WDG_TOOLBOX/WDG_SWITCH properties
const static char* CONTAINER_PAGE_NAME = "title";
+const static char* CONTAINER_PAGE_ICON = "icon";
/*
* Hardcoded xml entities of plugins.xml
<source>
<toolbox id="CreationMethod">
- <box id="AxisByPointsCase" title="By two points">
+ <box id="AxisByPointsCase" title="By two points" icon=":icons/point.png">
<shape_selector id="FirstPoint"
label="First point"
icon=":icons/point.png"
<validator id="PartSet_DifferentShapes"/>
</shape_selector>
</box>
- <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face">
+ <box id="AxisByCylindricalFaceCase" title="As axis of cylindrical face" icon=":icons/circle.png">
<shape_selector id="CylindricalFace"
label="Main object"
icon=":icons/circle.png"
<validator id="PartSet_SketchEntityValidator" parameters="Sketch"/>
</multi_selector>
<toolbox id="CreationMethod">
- <box id="BySizes" title="By sizes">
+ <box id="BySizes" title="By sizes" icon=":icons/dimension_up.png">
<groupbox>
<doublevalue
id="to_size"
</doublevalue>
</groupbox>
</box>
- <box id="ByPlanesAndOffsets" title="By bounding planes and offsets">
+ <box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted.png">
<groupbox title="To">
<shape_selector id="to_object"
icon=":icons/plane_inverted.png"
tooltip="Create or edit a sketch">
</sketch_launcher>
<toolbox id="CreationMethod">
- <box id="BySizes" title="By sizes">
+ <box id="BySizes" title="By sizes" icon=":icons/dimension_up.png">
<groupbox>
<doublevalue
id="to_size"
</doublevalue>
</groupbox>
</box>
- <box id="ByPlanesAndOffsets" title="By bounding planes and offsets">
+ <box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted.png">
<groupbox title="To">
<shape_selector id="to_object"
icon=":icons/plane_inverted.png"
tooltip="Create or edit a sketch">
</sketch_launcher>
<toolbox id="CreationMethod">
- <box id="BySizes" title="By sizes">
+ <box id="BySizes" title="By sizes" icon=":icons/dimension_up.png">
<groupbox>
<doublevalue
id="to_size"
</doublevalue>
</groupbox>
</box>
- <box id="ByPlanesAndOffsets" title="By bounding planes and offsets">
+ <box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted.png">
<groupbox title="To">
<shape_selector id="to_object"
icon=":icons/plane_inverted.png"
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
<toolbox id="CreationMethod">
- <box id="ByAngles" title="By angles">
+ <box id="ByAngles" title="By angles" icon=":icons/angle_up.png">
<groupbox>
<doublevalue
id="to_angle"
</doublevalue>
</groupbox>
</box>
- <box id="ByPlanesAndOffsets" title="By bounding planes and offsets">
+ <box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted.png">
<groupbox title="To">
<shape_selector id="to_object"
icon=":icons/plane_inverted.png"
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
<toolbox id="CreationMethod">
- <box id="ByAngles" title="By angles">
+ <box id="ByAngles" title="By angles" icon=":icons/angle_up.png">
<groupbox>
<doublevalue
id="to_angle"
</doublevalue>
</groupbox>
</box>
- <box id="ByPlanesAndOffsets" title="By bounding planes and offsets">
+ <box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted.png">
<groupbox title="To">
<shape_selector id="to_object"
icon=":icons/plane_inverted.png"
<validator id="GeomValidators_ShapeType" parameters="line"/>
</shape_selector>
<toolbox id="CreationMethod">
- <box id="ByAngles" title="By angles">
+ <box id="ByAngles" title="By angles" icon=":icons/angle_up.png">
<groupbox>
<doublevalue
id="to_angle"
</doublevalue>
</groupbox>
</box>
- <box id="ByPlanesAndOffsets" title="By bounding planes and offsets">
+ <box id="ByPlanesAndOffsets" title="By bounding planes and offsets" icon=":icons/plane_inverted.png">
<groupbox title="To">
<shape_selector id="to_object"
icon=":icons/plane_inverted.png"
ModuleBase_Preferences.h
ModuleBase_ResultPrs.h
ModuleBase_SelectionValidator.h
+ ModuleBase_ToolBox.h
ModuleBase_Tools.h
ModuleBase_ViewerFilters.h
ModuleBase_ViewerPrs.h
ModuleBase_Preferences.cpp
ModuleBase_ResultPrs.cpp
ModuleBase_SelectionValidator.cpp
+ ModuleBase_ToolBox.cpp
ModuleBase_Tools.cpp
ModuleBase_ViewerFilters.cpp
ModuleBase_ViewerPrs.cpp
}
int ModuleBase_PagedContainer::addPage(ModuleBase_PageBase* thePage,
- const QString& theName, const QString& theCaseId)
+ const QString& theName, const QString& theCaseId,
+ const QIcon& theIcon )
{
if (!myPages.count()) {
setDefaultValue(theCaseId.toStdString());
const std::string& theParentId);
virtual ~ModuleBase_PagedContainer();
- virtual int addPage(ModuleBase_PageBase* theWidget,
- const QString& theName, const QString& theCaseId);
+ virtual int addPage( ModuleBase_PageBase* theWidget,
+ const QString& theName,
+ const QString& theCaseId,
+ const QIcon& theIcon );
+
// ModuleBase_ModelWidget
virtual QList<QWidget*> getControls() const;
virtual bool focusTo();
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ToolBox.cpp
+// Created: 10 August 2015
+// Author: Alexandre SOLOVYOV
+
+#include <ModuleBase_ToolBox.h>
+#include <QButtonGroup>
+#include <QStackedWidget>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QToolButton>
+
+ModuleBase_ToolBox::ModuleBase_ToolBox( QWidget* theParent )
+ : QFrame( theParent )
+{
+ QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+ aMainLayout->setMargin( 0 );
+ aMainLayout->setSpacing( 0 );
+
+ myButtonsFrame = new QFrame( this );
+ myStack = new QStackedWidget( this );
+ aMainLayout->addWidget( myButtonsFrame, 0 );
+ aMainLayout->addWidget( myStack, 1 );
+
+ myButtonsGroup = new QButtonGroup();
+ myButtonsGroup->setExclusive( true );
+ myButtonsLayout = new QHBoxLayout( myButtonsFrame );
+ myButtonsLayout->setMargin( 0 );
+ myButtonsLayout->setSpacing( 5 );
+ myButtonsLayout->addStretch( 1 );
+
+ connect( myStack, SIGNAL( currentChanged( int ) ), this, SIGNAL( currentChanged( int ) ) );
+ connect( myButtonsGroup, SIGNAL( buttonPressed( int ) ), this, SLOT( onButton( int ) ) );
+}
+
+ModuleBase_ToolBox::~ModuleBase_ToolBox()
+{
+}
+
+void ModuleBase_ToolBox::addItem( QWidget* thePage, const QString& theName, const QIcon& theIcon )
+{
+ int anOldCount = myStack->count();
+
+ myStack->addWidget( thePage );
+
+ QToolButton* aButton = new QToolButton( myButtonsFrame );
+ aButton->setCheckable( true );
+ aButton->setIcon( theIcon );
+ aButton->setToolTip( theName );
+ myButtonsGroup->addButton( aButton, anOldCount );
+ myButtonsLayout->insertWidget( anOldCount, aButton );
+}
+
+int ModuleBase_ToolBox::count() const
+{
+ return myStack->count();
+}
+
+int ModuleBase_ToolBox::currentIndex() const
+{
+ return myStack->currentIndex();
+}
+
+void ModuleBase_ToolBox::setCurrentIndex( const int theIndex )
+{
+ myStack->setCurrentIndex( theIndex );
+ myButtonsGroup->button( theIndex )->setChecked( true );
+}
+
+void ModuleBase_ToolBox::onButton( int theIndex )
+{
+ myStack->setCurrentIndex( theIndex );
+}
+
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_ToolBox.h
+// Created: 10 August 2015
+// Author: Alexandre SOLOVYOV
+
+#ifndef ModuleBase_ToolBox_H
+#define ModuleBase_ToolBox_H
+
+#include <ModuleBase.h>
+#include <QFrame>
+
+class QButtonGroup;
+class QFrame;
+class QHBoxLayout;
+class QStackedWidget;
+
+class MODULEBASE_EXPORT ModuleBase_ToolBox : public QFrame
+{
+ Q_OBJECT
+
+public:
+ ModuleBase_ToolBox( QWidget* theParent );
+ virtual ~ModuleBase_ToolBox();
+
+ void addItem( QWidget* thePage, const QString& theName, const QIcon& theIcon );
+ int count() const;
+ int currentIndex() const;
+ void setCurrentIndex( const int );
+
+signals:
+ void currentChanged( int );
+
+private slots:
+ void onButton( int );
+
+private:
+ QButtonGroup* myButtonsGroup;
+ QFrame* myButtonsFrame;
+ QHBoxLayout* myButtonsLayout;
+ QStackedWidget* myStack;
+};
+#endif
createWidget(aPage);
if (aWdgType == WDG_SWITCH || aWdgType == WDG_TOOLBOX) {
ModuleBase_PagedContainer* aContainer = qobject_cast<ModuleBase_PagedContainer*>(aWidget);
- aContainer->addPage(aPage, aPageName, aCaseId);
+
+ QString anIconPath = qs( myWidgetApi->getProperty( CONTAINER_PAGE_ICON ) );
+ QIcon anIcon( anIconPath );
+ aContainer->addPage( aPage, aPageName, aCaseId, anIcon );
}
} while (myWidgetApi->toNextWidget());
}
int ModuleBase_WidgetSwitch::addPage(ModuleBase_PageBase* thePage, const QString& theName,
- const QString& theCaseId)
+ const QString& theCaseId,
+ const QIcon& theIcon )
{
- int aSuperCount = ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId);
+ int aSuperCount = ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
myCombo->addItem(theName);
int aResultCount = myCombo->count();
if (aResultCount == 2)
/// Add a page to the widget
/// \param theWidget a page widget
/// \param theName a name of page
- virtual int addPage(ModuleBase_PageBase* theWidget,
- const QString& theName, const QString& theCaseId);
+ virtual int addPage( ModuleBase_PageBase* theWidget,
+ const QString& theName,
+ const QString& theCaseId,
+ const QIcon& theIcon );
protected:
virtual int currentPageIndex() const;
#include <ModuleBase_PageBase.h>
#include <ModuleBase_ModelWidget.h>
#include <ModuleBase_Tools.h>
+#include <ModuleBase_ToolBox.h>
#include <ModelAPI_AttributeString.h>
#include <QWidget>
#include <QList>
#include <QVBoxLayout>
+#include <QIcon>
ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData,
const std::string& theParentId)
{
QVBoxLayout* aMainLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aMainLayout);
- myToolBox = new QToolBox(this);
+ myToolBox = new ModuleBase_ToolBox(this);
// Dark-grey rounded tabs with button-like border #and bold font
+ // TODO: apply style to custom widget
QString css = "QToolBox::tab{background-color:#c8c8c8;"
"border-radius:5px;"
"border:1px inset;"
}
int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
- const QString& theName, const QString& theCaseId)
+ const QString& theName,
+ const QString& theCaseId,
+ const QIcon& theIcon )
{
- ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId);
+ ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
aFrame->setFrameShape(QFrame::Box);
aFrame->setFrameStyle(QFrame::Sunken);
- myToolBox->addItem(aFrame, theName);
+ myToolBox->addItem(aFrame, theName, theIcon );
return myToolBox->count();
}
#include <ModuleBase.h>
#include <ModuleBase_PagedContainer.h>
-#include <QToolBox>
-
class ModuleBase_PageBase;
+class ModuleBase_ToolBox;
class MODULEBASE_EXPORT ModuleBase_WidgetToolbox : public ModuleBase_PagedContainer
{
virtual bool canSetValue() const { return false; };
/// Overrides ModuleBase_PagedContainer
- int addPage(ModuleBase_PageBase* theWidget,
- const QString& theName, const QString& theCaseId);
+ virtual int addPage( ModuleBase_PageBase* theWidget,
+ const QString& theName,
+ const QString& theCaseId,
+ const QIcon& theIcon );
protected:
/// Implements ModuleBase_PagedContainer
virtual void setCurrentPageIndex(int);
private:
- QToolBox* myToolBox;
+ ModuleBase_ToolBox* myToolBox;
};
#endif /* MODULEBASE_WIDGETTOOLBOX_H_ */