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>
13 #include <ModelAPI_AttributeString.h>
17 #include <QVBoxLayout>
19 ModuleBase_WidgetToolbox::ModuleBase_WidgetToolbox(QWidget* theParent, const Config_WidgetAPI* theData,
20 const std::string& theParentId)
21 : ModuleBase_PagedContainer(theParent, theData, theParentId)
23 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
24 ModuleBase_Tools::zeroMargins(aMainLayout);
25 myToolBox = new QToolBox(this);
26 // Dark-grey rounded tabs with button-like border #and bold font
27 QString css = "QToolBox::tab{background-color:#c8c8c8;"
31 "border-color:#fff #505050 #505050 #fff;}";
32 myToolBox->setStyleSheet(css);
33 // default vertical size policy is preferred
34 aMainLayout->addWidget(myToolBox);
36 connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged()));
39 ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox()
43 int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
44 const QString& theName, const QString& theCaseId)
46 ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId);
47 QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
48 aFrame->setFrameShape(QFrame::Box);
49 aFrame->setFrameStyle(QFrame::Sunken);
50 myToolBox->addItem(aFrame, theName);
51 return myToolBox->count();
54 int ModuleBase_WidgetToolbox::currentPageIndex() const
56 return myToolBox->currentIndex();
59 void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex)
61 bool isSignalsBlocked = myToolBox->blockSignals(true);
62 myToolBox->setCurrentIndex(theIndex);
63 myToolBox->blockSignals(isSignalsBlocked);