2 * ModuleBase_WidgetToolbox.cpp
4 * Created on: Feb 27, 2015
8 #include <ModuleBase_WidgetToolbox.h>
9 #include <ModuleBase_PageBase.h>
10 #include <ModuleBase_ModelWidget.h>
11 #include <ModuleBase_Tools.h>
12 #include <ModuleBase_ToolBox.h>
14 #include <ModelAPI_AttributeString.h>
18 #include <QVBoxLayout>
21 ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData)
22 : ModuleBase_PagedContainer(theParent, theData)
24 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
25 ModuleBase_Tools::zeroMargins(aMainLayout);
27 bool aHasContainerParent = false;
28 QWidget* aParent = dynamic_cast<QWidget*>(parent());
29 while(aParent && !aHasContainerParent) {
30 ModuleBase_PagedContainer* aPagedContainer = dynamic_cast<ModuleBase_PagedContainer*>(aParent);
31 aHasContainerParent = aPagedContainer;
32 aParent = dynamic_cast<QWidget*>(aParent->parent());
34 myToolBox = new ModuleBase_ToolBox(this, aHasContainerParent);
35 // Dark-grey rounded tabs with button-like border #and bold font
36 // TODO: apply style to custom widget
37 QString css = "QToolBox::tab{background-color:#c8c8c8;"
41 "border-color:#fff #505050 #505050 #fff;}";
42 myToolBox->setStyleSheet(css);
43 // default vertical size policy is preferred
44 aMainLayout->addWidget(myToolBox);
46 connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged()));
49 ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox()
53 int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
54 const QString& theName,
55 const QString& theCaseId,
56 const QPixmap& theIcon )
58 ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
59 QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
60 myToolBox->addItem(aFrame, theName, theIcon );
61 return myToolBox->count();
64 int ModuleBase_WidgetToolbox::currentPageIndex() const
66 return myToolBox->currentIndex();
69 void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex)
71 bool isSignalsBlocked = myToolBox->blockSignals(true);
72 myToolBox->setCurrentIndex(theIndex);
73 myToolBox->blockSignals(isSignalsBlocked);