// Author: Alexandre SOLOVYOV
#include <ModuleBase_ToolBox.h>
+#include <ModuleBase_ModelWidget.h>
+
#include <QButtonGroup>
#include <QStackedWidget>
#include <QHBoxLayout>
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 );
{
}
-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 );
}
myStack->setCurrentIndex( theIndex );
}
+bool ModuleBase_ToolBox::isOffToolBoxParent(ModuleBase_ModelWidget* theWidget)
+{
+ bool isOffToolBox = false;
+
+ QList<QWidget*> 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<QStackedWidget*>(aParent);
+ if (aStackedWidget) {
+ int anIndex = aStackedWidget->currentIndex();
+ isOffToolBox = aStackedWidget->currentWidget() != aWidget;
+ break;
+ }
+ aWidget = aParent;
+ aParent = (QWidget*)aWidget->parent();
+ }
+ }
+ return isOffToolBox;
+}