Salome HOME
Merge branch 'master' of newgeom:newgeom.git
[modules/shaper.git] / src / XGUI / XGUI_MenuGroupPanel.cpp
index 4f447117c97e1c6021f99d2aee9ba0a5777762e3..a1883f26baec7d7eb14dce73bb02302f07784e91 100644 (file)
@@ -7,14 +7,19 @@
 #include <QResizeEvent>
 
 #include <math.h>
+#include <iostream>
 
 XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent)
-    : QWidget(parent), myNewRow(0), myNewCol(0), myMaxRow(1)
+    : QFrame(parent),
+      myNewRow(0),
+      myNewCol(0),
+      myMaxRow(1)
 {
   myLayout = new QGridLayout(this);
   myLayout->setSpacing(0);
   myLayout->setMargin(0);
   myLayout->setContentsMargins(0, 0, 0, 0);
+  setFrameShape(QFrame::NoFrame);
 }
 
 void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
@@ -31,7 +36,8 @@ void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
     myNewRow = 0;
     myNewCol++;
   }
-  myLayout->addWidget(theWgt, myNewRow, myNewCol, Qt::AlignLeft);
+  myLayout->addWidget(theWgt, myNewRow, myNewCol);
+  myLayout->setRowStretch(myNewRow, 0);
   myNewRow++;
 }
 
@@ -54,20 +60,46 @@ void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
   myMaxRow = aMaxRow;
   myNewRow = 0;
   myNewCol = 0;
-  foreach(QWidget* eachWidget, myActionWidget) {
+  foreach(QWidget* eachWidget, myActionWidget)
+  {
     placeWidget(eachWidget);
   }
+  myLayout->setRowStretch(myMaxRow + 1, 1);
 }
 
-XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle,
-                                              const QString& theTip, const QIcon& theIcon,
+XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId,
+                                              const QString& theTip,
+                                              const QString& theTitle,
+                                              const QIcon& theIcon,
                                               const QKeySequence& theKeys)
 {
-  XGUI_Command* aCommand = new XGUI_Command(theId, theIcon, theTitle, this);
+  return addFeature(theId, theTip, theTitle, theIcon, QString(), theKeys, false);
+}
+
+XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId,
+                                              const QString& theTitle,
+                                              const QString& theTip,
+                                              const QIcon& theIcon,
+                                              const QString& theDocumentKind,
+                                              const QKeySequence& theKeys,
+                                              bool isCheckable)
+{
+  XGUI_Command* aCommand = new XGUI_Command(theId, theDocumentKind, theIcon,
+                                            theTitle, this, isCheckable);
   aCommand->setToolTip(theTip);
-  if (!theKeys.isEmpty())
+  if (!theKeys.isEmpty()) {
     aCommand->setShortcut(theKeys);
-
+  }
   addCommand(aCommand);
   return aCommand;
 }
+
+XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const
+{
+  foreach (XGUI_Command* aCmd, myActions)
+  {
+    if (aCmd->data().toString() == theId)
+      return aCmd;
+  }
+  return 0;
+}