1 #include "XGUI_MenuGroupPanel.h"
2 #include "XGUI_Command.h"
7 #include <QResizeEvent>
12 XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent)
13 : QFrame(parent), myNewRow(0), myNewCol(0), myMaxRow(1)
15 myLayout = new QGridLayout(this);
16 myLayout->setSpacing(0);
17 myLayout->setMargin(0);
18 myLayout->setContentsMargins(0, 0, 0, 0);
19 setFrameShape(QFrame::NoFrame);
24 void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
26 myActions.append(theAction);
27 QWidget* aWdg = theAction->requestWidget(this);
28 myActionWidget.append(aWdg);
32 void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
34 if (myMaxRow == myNewRow) {
38 myLayout->addWidget(theWgt, myNewRow, myNewCol);
39 myLayout->setRowStretch(myNewRow, 0);
43 void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt)
48 void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
50 QWidget::resizeEvent(theEvent);
51 if (myActions.size() == 0)
54 int aH = theEvent->size().height();
55 int aMaxRow = (int) floor(double(aH / MIN_BUTTON_HEIGHT));
56 if (aMaxRow == myMaxRow)
62 foreach(QWidget* eachWidget, myActionWidget) {
63 placeWidget(eachWidget);
65 myLayout->setRowStretch(myMaxRow + 1, 1);
68 XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId, const QString& theTitle,
69 const QString& theTip, const QIcon& theIcon,
70 const QKeySequence& theKeys, bool isCheckable)
72 XGUI_Command* aCommand = new XGUI_Command(theId, theIcon, theTitle, this, isCheckable);
73 aCommand->setToolTip(theTip);
74 if (!theKeys.isEmpty()) {
75 aCommand->setShortcut(theKeys);
82 XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const
84 foreach (XGUI_Command* aCmd, myActions) {
85 if (aCmd->data().toString() == theId)