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);
26 myToolBox = new ModuleBase_ToolBox(this);
27 // Dark-grey rounded tabs with button-like border #and bold font
28 // TODO: apply style to custom widget
29 QString css = "QToolBox::tab{background-color:#c8c8c8;"
33 "border-color:#fff #505050 #505050 #fff;}";
34 myToolBox->setStyleSheet(css);
35 // default vertical size policy is preferred
36 aMainLayout->addWidget(myToolBox);
38 connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged()));
41 ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox()
45 int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
46 const QString& theName,
47 const QString& theCaseId,
48 const QPixmap& theIcon )
50 ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
51 QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
52 aFrame->setFrameStyle(QFrame::Box | QFrame::Raised);
53 myToolBox->addItem(aFrame, theName, theIcon );
54 return myToolBox->count();
57 int ModuleBase_WidgetToolbox::currentPageIndex() const
59 return myToolBox->currentIndex();
62 void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex)
64 bool isSignalsBlocked = myToolBox->blockSignals(true);
65 myToolBox->setCurrentIndex(theIndex);
66 myToolBox->blockSignals(isSignalsBlocked);