1 #include "XGUI_MenuGroupPanel.h"
2 #include "XGUI_Command.h"
7 #include <QResizeEvent>
12 XGUI_MenuGroupPanel::XGUI_MenuGroupPanel(QWidget *parent)
18 myLayout = new QGridLayout(this);
19 myLayout->setSpacing(0);
20 myLayout->setMargin(0);
21 myLayout->setContentsMargins(0, 0, 0, 0);
22 setFrameShape(QFrame::NoFrame);
25 void XGUI_MenuGroupPanel::addCommand(XGUI_Command* theAction)
27 myActions.append(theAction);
28 QWidget* aWdg = theAction->requestWidget(this);
29 myActionWidget.append(aWdg);
33 void XGUI_MenuGroupPanel::placeWidget(QWidget* theWgt)
35 if (myMaxRow == myNewRow) {
39 myLayout->addWidget(theWgt, myNewRow, myNewCol);
40 myLayout->setRowStretch(myNewRow, 0);
44 void XGUI_MenuGroupPanel::addWidget(QWidget* theWgt)
49 void XGUI_MenuGroupPanel::resizeEvent(QResizeEvent* theEvent)
51 QWidget::resizeEvent(theEvent);
52 if (myActions.size() == 0)
55 int aH = theEvent->size().height();
56 int aMaxRow = (int) floor(double(aH / MIN_BUTTON_HEIGHT));
57 if (aMaxRow == myMaxRow)
63 foreach(QWidget* eachWidget, myActionWidget)
65 placeWidget(eachWidget);
67 myLayout->setRowStretch(myMaxRow + 1, 1);
70 XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId,
71 const QString& theTip,
72 const QString& theTitle,
74 const QKeySequence& theKeys)
76 return addFeature(theId, theTip, theTitle, theIcon, QString(), theKeys, false);
79 XGUI_Command* XGUI_MenuGroupPanel::addFeature(const QString& theId,
80 const QString& theTitle,
81 const QString& theTip,
83 const QString& theDocumentKind,
84 const QKeySequence& theKeys,
87 XGUI_Command* aCommand = new XGUI_Command(theId, theDocumentKind, theIcon,
88 theTitle, this, isCheckable);
89 aCommand->setToolTip(theTip);
90 if (!theKeys.isEmpty()) {
91 aCommand->setShortcut(theKeys);
97 XGUI_Command* XGUI_MenuGroupPanel::feature(const QString& theId) const
99 foreach (XGUI_Command* aCmd, myActions)
101 if (aCmd->data().toString() == theId)