X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FModuleBase%2FModuleBase_ToolBox.cpp;h=1ab883c86e13653ada9d70bf36bf1c98dec7d87b;hb=eef14b29d313b9dd16453d12f20aa02383ee139c;hp=0af3267b19d008747769ebfd4543156172258d97;hpb=41695176c748943485f8844fea6e89cef9a0b6f5;p=modules%2Fshaper.git diff --git a/src/ModuleBase/ModuleBase_ToolBox.cpp b/src/ModuleBase/ModuleBase_ToolBox.cpp index 0af3267b1..1ab883c86 100644 --- a/src/ModuleBase/ModuleBase_ToolBox.cpp +++ b/src/ModuleBase/ModuleBase_ToolBox.cpp @@ -5,6 +5,8 @@ // Author: Alexandre SOLOVYOV #include +#include + #include #include #include @@ -23,7 +25,7 @@ ModuleBase_ToolBox::ModuleBase_ToolBox( QWidget* theParent ) aMainLayout->addWidget( myButtonsFrame, 0 ); aMainLayout->addWidget( myStack, 1 ); - myButtonsGroup = new QButtonGroup(); + myButtonsGroup = new QButtonGroup(this); myButtonsGroup->setExclusive( true ); myButtonsLayout = new QHBoxLayout( myButtonsFrame ); myButtonsLayout->setMargin( 0 ); @@ -38,16 +40,19 @@ ModuleBase_ToolBox::~ModuleBase_ToolBox() { } -void ModuleBase_ToolBox::addItem( QWidget* thePage, const QString& theName, const QIcon& theIcon ) +void ModuleBase_ToolBox::addItem( QWidget* thePage, const QString& theName, const QPixmap& theIcon ) { int anOldCount = myStack->count(); myStack->addWidget( thePage ); QToolButton* aButton = new QToolButton( myButtonsFrame ); + aButton->setFocusPolicy(Qt::StrongFocus); aButton->setCheckable( true ); aButton->setIcon( theIcon ); + aButton->setIconSize( theIcon.size() ); aButton->setToolTip( theName ); + aButton->setObjectName( theName ); myButtonsGroup->addButton( aButton, anOldCount ); myButtonsLayout->insertWidget( anOldCount, aButton ); } @@ -73,3 +78,26 @@ void ModuleBase_ToolBox::onButton( int theIndex ) myStack->setCurrentIndex( theIndex ); } +bool ModuleBase_ToolBox::isOffToolBoxParent(ModuleBase_ModelWidget* theWidget) +{ + bool isOffToolBox = false; + + QList aControls = theWidget->getControls(); + if (aControls.size() > 0) { + QWidget* aFirstControl = aControls.first(); + + QWidget* aWidget = aFirstControl; + QWidget* aParent = (QWidget*)aFirstControl->parent(); + while (aParent) { + QStackedWidget* aStackedWidget = dynamic_cast(aParent); + if (aStackedWidget) { + int anIndex = aStackedWidget->currentIndex(); + isOffToolBox = aStackedWidget->currentWidget() != aWidget; + break; + } + aWidget = aParent; + aParent = (QWidget*)aWidget->parent(); + } + } + return isOffToolBox; +}