#include <XGUI_PropertyPanel.h>
#include <XGUI_ActionsMgr.h>
+#include <XGUI_OperationMgr.h>
//#include <AppElements_Constants.h>
#include <ModuleBase_WidgetMultiSelector.h>
#include <ModuleBase_Tools.h>
#include <iostream>
#endif
-XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent)
+XGUI_PropertyPanel::XGUI_PropertyPanel(QWidget* theParent, XGUI_OperationMgr* theMgr)
: ModuleBase_IPropertyPanel(theParent),
myActiveWidget(NULL),
myPreselectionWidget(NULL),
- myPanelPage(NULL)
+ myPanelPage(NULL),
+ myOperationMgr(theMgr)
{
this->setWindowTitle(tr("Property Panel"));
QAction* aViewAct = this->toggleViewAction();
aLast = myWidgets.end();
for (; anIt != aLast; anIt++) {
QWidget* aWidget = *anIt;
- if (aWidget)
+ if (aWidget) {
aWidget->blockSignals(true);
+ }
}
myWidgets.clear();
connect(aWidget, SIGNAL(keyReleased(QKeyEvent*)),
this, SIGNAL(keyReleased(QKeyEvent*)));
}
- ModuleBase_ModelWidget* aLastWidget = theWidgets.last();
- if (aLastWidget) {
- QList<QWidget*> aControls = aLastWidget->getControls();
- if (!aControls.empty()) {
- QWidget* aLastControl = aControls.last();
-
- QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
- QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
- setTabOrder(aLastControl, anOkBtn);
- setTabOrder(anOkBtn, aCancelBtn);
+ QWidget* aLastControl = 0;
+ QList<QWidget*> aControls;
+ for (int i = myWidgets.size()-1; i >= 0 && !aLastControl; i--) {
+ aControls = myWidgets[i]->getControls();
+ for (int j = aControls.size()-1; j >= 0 && !aLastControl; j--) {
+ if (aControls[j]->focusPolicy() != Qt::NoFocus)
+ aLastControl = aControls[j];
}
}
+ if (aLastControl) {
+ QToolButton* anOkBtn = findChild<QToolButton*>(PROP_PANEL_OK);
+ QToolButton* aCancelBtn = findChild<QToolButton*>(PROP_PANEL_CANCEL);
+
+ setTabOrder(aLastControl, anOkBtn);
+ setTabOrder(anOkBtn, aCancelBtn);
+ }
}
const QList<ModuleBase_ModelWidget*>& XGUI_PropertyPanel::modelWidgets() const
activateWidget(NULL);
return;
}
- ModuleBase_ModelWidget* aNextWidget = 0;
QList<ModuleBase_ModelWidget*>::const_iterator anIt = myWidgets.begin(), aLast = myWidgets.end();
bool isFoundWidget = false;
activateWindow();
- for (; anIt != aLast && !aNextWidget; anIt++) {
+ for (; anIt != aLast; anIt++) {
if (isFoundWidget || !theWidget) {
if ((*anIt)->focusTo()) {
- aNextWidget = *anIt;
+ return;
}
}
- isFoundWidget = (*anIt) == theWidget;
- }
- // Normaly focusTo is enough to activate widget
- // here is a special case on mouse click in the viewer
- if(aNextWidget == NULL) {
- activateWidget(aNextWidget);
+ isFoundWidget = isFoundWidget || (*anIt) == theWidget;
}
+ activateWidget(NULL);
}
void XGUI_PropertyPanel::activateNextWidget()
emit widgetActivated(theWidget);
} else if (!isEditingMode()) {
emit noMoreWidgets();
+ setFocusOnOkButton();
}
}
{
myPreselectionWidget = theWidget;
}
+
+
+void XGUI_PropertyPanel::closeEvent(QCloseEvent* theEvent)
+{
+ ModuleBase_Operation* aOp = myOperationMgr->currentOperation();
+ if (aOp) {
+ if (myOperationMgr->canStopOperation(aOp)) {
+ myOperationMgr->abortAllOperations();
+ theEvent->accept();
+ } else
+ theEvent->ignore();
+ } else
+ ModuleBase_IPropertyPanel::closeEvent(theEvent);
+}
\ No newline at end of file