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 const std::string& theParentId)
23 : ModuleBase_PagedContainer(theParent, theData, theParentId)
25 QVBoxLayout* aMainLayout = new QVBoxLayout(this);
26 ModuleBase_Tools::zeroMargins(aMainLayout);
27 myToolBox = new ModuleBase_ToolBox(this);
28 // Dark-grey rounded tabs with button-like border #and bold font
29 // TODO: apply style to custom widget
30 QString css = "QToolBox::tab{background-color:#c8c8c8;"
34 "border-color:#fff #505050 #505050 #fff;}";
35 myToolBox->setStyleSheet(css);
36 // default vertical size policy is preferred
37 aMainLayout->addWidget(myToolBox);
39 connect(myToolBox, SIGNAL(currentChanged(int)), this, SLOT(onPageChanged()));
42 ModuleBase_WidgetToolbox::~ModuleBase_WidgetToolbox()
46 int ModuleBase_WidgetToolbox::addPage(ModuleBase_PageBase* thePage,
47 const QString& theName,
48 const QString& theCaseId,
49 const QPixmap& theIcon )
51 ModuleBase_PagedContainer::addPage(thePage, theName, theCaseId, theIcon);
52 QFrame* aFrame = dynamic_cast<QFrame*>(thePage);
53 aFrame->setFrameShape(QFrame::Box);
54 aFrame->setFrameStyle(QFrame::Sunken);
55 myToolBox->addItem(aFrame, theName, theIcon );
56 return myToolBox->count();
59 int ModuleBase_WidgetToolbox::currentPageIndex() const
61 return myToolBox->currentIndex();
64 void ModuleBase_WidgetToolbox::setCurrentPageIndex(int theIndex)
66 bool isSignalsBlocked = myToolBox->blockSignals(true);
67 myToolBox->setCurrentIndex(theIndex);
68 myToolBox->blockSignals(isSignalsBlocked);