+
+
+bool XGUI_MainMenu::eventFilter(QObject *theWatched, QEvent *theEvent)
+{
+ if (theWatched == myGeneralPage) {
+ if (theEvent->type() == QEvent::Show) {
+ myGeneralPage->parentWidget()->setMaximumWidth(16777215);
+ myGeneralPage->removeEventFilter(this);
+ }
+ }
+ return QObject::eventFilter(theWatched, theEvent);
+}
+
+void XGUI_MainMenu::insertConsole(QWidget* theConsole)
+{
+ int aConsoleTabId = myMenuTabs->addTab(theConsole, "Console");
+
+ QTabBar* aTabBar = myMenuTabs->findChild<QTabBar*>();
+ QPushButton* aCloseTabButton = new QPushButton();
+ aCloseTabButton->setFixedSize(16, 16);
+ aCloseTabButton->setIcon(QIcon(":pictures/wnd_close.png"));
+ aCloseTabButton->setFlat(true);
+ aTabBar->setTabButton(aConsoleTabId,
+ QTabBar::RightSide,
+ aCloseTabButton);
+
+ connect(aCloseTabButton, SIGNAL(clicked()),
+ myDesktop, SLOT(dockPythonConsole()));
+}
+
+void XGUI_MainMenu::removeConsole()
+{
+ const int kLastTab = myMenuTabs->count() - 1;
+ myMenuTabs->removeTab(kLastTab);
+}
+
+XGUI_Command* XGUI_MainMenu::feature(const QString& theId) const
+{
+ XGUI_Command* result;
+ result = myGeneralPage->feature(theId);
+ if (!result) {
+ for (int aTabIdx = 0; aTabIdx < myMenuTabs->count(); ++aTabIdx) {
+ XGUI_Workbench* aWbn = static_cast<XGUI_Workbench*>(myMenuTabs->widget(aTabIdx));
+ result = aWbn->feature(theId);
+ if (result) break;
+ }
+ }
+ return result;
+}
+
+QList<XGUI_Command*> XGUI_MainMenu::features() const
+{
+ QList<XGUI_Command*> aList = myGeneralPage->features();
+ for (int aTabIdx = 0; aTabIdx < myMenuTabs->count(); ++aTabIdx) {
+ XGUI_Workbench* aWbn = static_cast<XGUI_Workbench*>(myMenuTabs->widget(aTabIdx));
+ aList.append(aWbn->features());
+ }
+ return aList;
+}
+
+int XGUI_MainMenu::menuItemSize() const
+{
+ //TODO(sbh, vsv): get this value from the preferences
+ static const ItemSize DEFAULT_ITEM_SIZE = Medium;
+ return (int) DEFAULT_ITEM_SIZE;
+}
+
+int XGUI_MainMenu::menuHeight() const
+{
+ // Default group has no tabs above --> one extra row
+ int rows = menuItemRowsCount() + 1;
+ const int kMarginsSpacings = 4;
+ return rows * menuItemSize() + kMarginsSpacings;
+}
+
+int XGUI_MainMenu::menuItemRowsCount() const
+{
+ //TODO(sbh, vsv): get this value from the preferences
+ static const int DEFAULT_ITEM_ROWS_COUNT = 3;
+ return DEFAULT_ITEM_ROWS_COUNT;
+}