From: mkr Date: Wed, 20 May 2015 11:31:36 +0000 (+0300) Subject: refs #529: use 'Apply and Close', 'Apply' and 'Close' buttons in HYDRO dialogs. X-Git-Tag: v1.4.1~25^2~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f72f73125cf95dff09f91b2258d955162fc3ec15;p=modules%2Fhydro.git refs #529: use 'Apply and Close', 'Apply' and 'Close' buttons in HYDRO dialogs. --- diff --git a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx index 7f96b26d..8bf96b13 100644 --- a/src/HYDROGUI/HYDROGUI_ChannelOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ChannelOp.cxx @@ -66,15 +66,17 @@ void HYDROGUI_ChannelOp::startOperation() aPanel->reset(); - myEditedObject.Nullify(); + if ( isApplyAndClose() ) + myEditedObject.Nullify(); QString aSelectedGuideLine, aSelectedProfile; QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_CHANNEL_NAME" ) ); if ( myIsEdit ) { - myEditedObject = - Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = + Handle(HYDROData_Channel)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( !myEditedObject.IsNull() ) { anObjectName = myEditedObject->GetName(); diff --git a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx index 5778c6f1..b75b8ca3 100644 --- a/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImmersibleZoneOp.cxx @@ -82,7 +82,8 @@ void HYDROGUI_ImmersibleZoneOp::startOperation() if ( myIsEdit ) { - myEditedObject = Handle(HYDROData_ImmersibleZone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_ImmersibleZone)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if( !myEditedObject.IsNull() ) { anObjectName = myEditedObject->GetName(); diff --git a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx index 3b9b0b87..61165fd3 100644 --- a/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportBathymetryOp.cxx @@ -63,7 +63,8 @@ void HYDROGUI_ImportBathymetryOp::startOperation() if( myIsEdit ) { - myEditedObject = Handle(HYDROData_Bathymetry)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_Bathymetry)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if( !myEditedObject.IsNull() ) { QString aName = myEditedObject->GetName(); diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 12a71ec5..a7f9e98c 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -78,7 +78,8 @@ void HYDROGUI_ImportImageOp::startOperation() if( myIsEdit ) { - myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if( !myEditedObject.IsNull() ) { QImage anImage = myEditedObject->Image(); @@ -262,7 +263,8 @@ void HYDROGUI_ImportImageOp::abortOperation() void HYDROGUI_ImportImageOp::commitOperation() { - closePreview(); + if ( isApplyAndClose() ) + closePreview(); HYDROGUI_Operation::commitOperation(); } @@ -497,14 +499,18 @@ bool HYDROGUI_ImportImageOp::processApply( int& theUpdateFlags, } // must be done after all checks and before calling SetVisible() method below - closePreview(); + if ( isApplyAndClose() ) + closePreview(); if( !myIsEdit ) module()->setObjectVisible( HYDROGUI_Tool::GetActiveGraphicsViewId( module() ), anImageObj, true ); anImageObj->Update(); - theUpdateFlags = UF_Model | UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced; + theUpdateFlags = UF_Model; + if ( isApplyAndClose() ) + theUpdateFlags |= UF_Viewer | UF_GV_Forced | UF_OCCViewer | UF_OCC_Forced; + return true; } @@ -532,7 +538,7 @@ bool HYDROGUI_ImportImageOp::isReferenceCorrect() const return isCorrect; } -void HYDROGUI_ImportImageOp::onApply() +void HYDROGUI_ImportImageOp::apply() { HYDROGUI_ImportImageDlg* aPanel = (HYDROGUI_ImportImageDlg*)inputPanel(); @@ -548,7 +554,7 @@ void HYDROGUI_ImportImageOp::onApply() QMessageBox::Yes | QMessageBox::No, QMessageBox::No ) == QMessageBox::Yes; } if ( aCanApply ) - HYDROGUI_Operation::onApply(); + HYDROGUI_Operation::apply(); else { aPanel->setRefImageName( "" ); onRefImageActivated( aPanel->getRefImageName() ); diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index 365978d7..a3e853a0 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -53,9 +53,12 @@ protected: QStringList& theBrowseObjectsEntries ); bool isReferenceCorrect() const; -protected slots: - virtual void onApply(); + /** + * Apply changes done by this operation. + */ + virtual void apply(); +protected slots: void onCreatePreview( QImage ); void onActivatePointSelection( int ); void onPointCoordChanged( bool, int, bool, int ); diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.cxx b/src/HYDROGUI/HYDROGUI_InputPanel.cxx index a496a82d..a12421f2 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.cxx +++ b/src/HYDROGUI/HYDROGUI_InputPanel.cxx @@ -57,17 +57,20 @@ HYDROGUI_InputPanel::HYDROGUI_InputPanel( HYDROGUI_Module* theModule, const QStr aBtnsLayout->setMargin( 5 ); aBtnsLayout->setSpacing( 5 ); - myCancel = new QPushButton( tr( "CANCEL" ), myBtnFrame ); + myCancel = new QPushButton( tr( "CLOSE" ), myBtnFrame ); myHelp = new QPushButton( tr( "HELP" ), myBtnFrame ); if ( doInitLayout ) { + myApplyAndClose = new QPushButton( tr( "APPLY_AND_CLOSE" ), myBtnFrame ); myApply = new QPushButton( tr( "APPLY" ), myBtnFrame ); + aBtnsLayout->addWidget( myApplyAndClose, 0 ); aBtnsLayout->addWidget( myApply, 0 ); aBtnsLayout->addWidget( myCancel, 0 ); aBtnsLayout->addStretch( 1 ); aBtnsLayout->addWidget( myHelp, 0 ); + connect( myApplyAndClose, SIGNAL( clicked() ), this, SLOT( onApplyAndClose() ) ); connect( myApply, SIGNAL( clicked() ), this, SLOT( onApply() ) ); } connect( myCancel, SIGNAL( clicked() ), this, SLOT( onCancel() ) ); @@ -85,12 +88,18 @@ HYDROGUI_Module* HYDROGUI_InputPanel::module() const bool HYDROGUI_InputPanel::isApplyEnabled() const { - return myApply->isEnabled(); + return myApply->isEnabled(); } void HYDROGUI_InputPanel::setApplyEnabled( bool on ) { - myApply->setEnabled( on ); + myApplyAndClose->setEnabled( on ); + myApply->setEnabled( on ); +} + +void HYDROGUI_InputPanel::onApplyAndClose() +{ + emit panelApplyAndClose(); } void HYDROGUI_InputPanel::onApply() diff --git a/src/HYDROGUI/HYDROGUI_InputPanel.h b/src/HYDROGUI/HYDROGUI_InputPanel.h index b9dadee6..7662bf9c 100644 --- a/src/HYDROGUI/HYDROGUI_InputPanel.h +++ b/src/HYDROGUI/HYDROGUI_InputPanel.h @@ -53,11 +53,13 @@ public: void setApplyEnabled( bool ); signals: + void panelApplyAndClose(); void panelApply(); void panelCancel(); void panelHelp(); protected slots: + void onApplyAndClose(); void onApply(); void onCancel(); void onHelp(); @@ -74,6 +76,7 @@ private: HYDROGUI_Module* myModule; QFrame* myMainFrame; QFrame* myBtnFrame; + QPushButton* myApplyAndClose; QPushButton* myApply; }; diff --git a/src/HYDROGUI/HYDROGUI_Operation.cxx b/src/HYDROGUI/HYDROGUI_Operation.cxx index 38281c81..a218483c 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.cxx +++ b/src/HYDROGUI/HYDROGUI_Operation.cxx @@ -51,7 +51,8 @@ HYDROGUI_Operation::HYDROGUI_Operation( HYDROGUI_Module* theModule ) myIsPrintErrorMessage( true ), myIsTransactionOpened( false ), myPreviewManager( 0 ), - myPreviewZLayer( -1 ) + myPreviewZLayer( -1 ), + myIsApplyAndClose( true ) { connect( this, SIGNAL( helpContextModule( const QString&, const QString&, const QString& ) ), @@ -78,6 +79,7 @@ HYDROGUI_InputPanel* HYDROGUI_Operation::inputPanel() const if( !myPanel ) { ( ( HYDROGUI_Operation* )this )->myPanel = createInputPanel(); + connect( myPanel, SIGNAL( panelApplyAndClose() ), this, SLOT( onApplyAndClose() ) ); connect( myPanel, SIGNAL( panelApply() ), this, SLOT( onApply() ) ); connect( myPanel, SIGNAL( panelCancel() ), this, SLOT( onCancel() ) ); connect( myPanel, SIGNAL( panelHelp() ), this, SLOT( onHelp() ) ); @@ -205,12 +207,76 @@ void HYDROGUI_Operation::restoreCursor() } } +void HYDROGUI_Operation::setIsApplyAndClose( const bool theFlag ) +{ + myIsApplyAndClose = theFlag; +} + +bool HYDROGUI_Operation::isApplyAndClose() const +{ + return myIsApplyAndClose; +} + +void HYDROGUI_Operation::apply() +{ + QApplication::setOverrideCursor( Qt::WaitCursor ); + + startDocOperation(); + + int anUpdateFlags = 0; + QString anErrorMsg; + + bool aResult = false; + QStringList aBrowseObjectsEntries; + + try + { + aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries ); + } + catch ( Standard_Failure ) + { + Handle(Standard_Failure) aFailure = Standard_Failure::Caught(); + anErrorMsg = aFailure->GetMessageString(); + aResult = false; + } + catch ( ... ) + { + aResult = false; + } + + QApplication::restoreOverrideCursor(); + + if ( aResult ) + { + module()->update( anUpdateFlags ); + commitDocOperation(); + commit(); + browseObjects( aBrowseObjectsEntries, myIsApplyAndClose ); + + if ( !myIsApplyAndClose && inputPanel() ) + start(); + } + else + { + // Abort document opeartion only if requested + if ( isToAbortOnApply() ) + abortDocOperation(); + + printErrorMessage( anErrorMsg ); + + // If the operation has no input panel - do abort + if ( !inputPanel() ) { + abort(); + } + } +} + void HYDROGUI_Operation::startOperation() { LightApp_Operation::startOperation(); myModule->getActiveOperations().push( this ); - if( inputPanel() ) + if( myIsApplyAndClose && inputPanel() ) { myModule->getApp()->desktop()->addDockWidget( Qt::RightDockWidgetArea, inputPanel() ); inputPanel()->show(); @@ -226,7 +292,8 @@ void HYDROGUI_Operation::abortOperation() void HYDROGUI_Operation::commitOperation() { LightApp_Operation::commitOperation(); - closeInputPanel(); + if ( myIsApplyAndClose ) + closeInputPanel(); } void HYDROGUI_Operation::stopOperation() @@ -332,55 +399,16 @@ Handle_HYDROData_Document HYDROGUI_Operation::doc() const return HYDROData_Document::Document( myModule->getStudyId() ); } -void HYDROGUI_Operation::onApply() +void HYDROGUI_Operation::onApplyAndClose() { - QApplication::setOverrideCursor( Qt::WaitCursor ); - - startDocOperation(); - - int anUpdateFlags = 0; - QString anErrorMsg; - - bool aResult = false; - QStringList aBrowseObjectsEntries; - - try - { - aResult = processApply( anUpdateFlags, anErrorMsg, aBrowseObjectsEntries ); - } - catch ( Standard_Failure ) - { - Handle(Standard_Failure) aFailure = Standard_Failure::Caught(); - anErrorMsg = aFailure->GetMessageString(); - aResult = false; - } - catch ( ... ) - { - aResult = false; - } - - QApplication::restoreOverrideCursor(); - - if ( aResult ) - { - module()->update( anUpdateFlags ); - commitDocOperation(); - commit(); - browseObjects( aBrowseObjectsEntries ); - } - else - { - // Abort document opeartion only if requested - if ( isToAbortOnApply() ) - abortDocOperation(); + myIsApplyAndClose = true; + apply(); +} - printErrorMessage( anErrorMsg ); - - // If the operation has no input panel - do abort - if ( !inputPanel() ) { - abort(); - } - } +void HYDROGUI_Operation::onApply() +{ + myIsApplyAndClose = false; + apply(); } void HYDROGUI_Operation::setPrintErrorMessage( const bool theIsPrint ) @@ -408,6 +436,9 @@ void HYDROGUI_Operation::onCancel() { processCancel(); abort(); + if ( myPanel ) + abortOperation(); + myIsApplyAndClose = true; } void HYDROGUI_Operation::onHelp() @@ -431,9 +462,9 @@ QString HYDROGUI_Operation::getHelpContext() const return QString(); } -void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries ) +void HYDROGUI_Operation::browseObjects( const QStringList& theBrowseObjectsEntries, + const bool theIsApplyAndClose/* = true*/ ) { - bool isApplyAndClose = true; bool isOptimizedBrowse = true; - module()->getApp()->browseObjects( theBrowseObjectsEntries, isApplyAndClose, isOptimizedBrowse ); + module()->getApp()->browseObjects( theBrowseObjectsEntries, theIsApplyAndClose, isOptimizedBrowse ); } diff --git a/src/HYDROGUI/HYDROGUI_Operation.h b/src/HYDROGUI/HYDROGUI_Operation.h index 89f6c9d2..e3c83506 100644 --- a/src/HYDROGUI/HYDROGUI_Operation.h +++ b/src/HYDROGUI/HYDROGUI_Operation.h @@ -88,10 +88,12 @@ protected: void printErrorMessage( const QString& theErrorMsg ); void setPrintErrorMessage( const bool theIsPrint ); - void browseObjects( const QStringList& theBrowseObjectsEntries ); + void browseObjects( const QStringList& theBrowseObjectsEntries, + const bool theIsApplyAndClose = true ); protected slots: + virtual void onApplyAndClose(); virtual void onApply(); virtual void onCancel(); virtual void onHelp(); @@ -110,11 +112,27 @@ protected: /** * Set specific cursor chosen in preferences for edition operations. */ - virtual void setCursor(); + virtual void setCursor(); /** * Restore the default cursor. */ - virtual void restoreCursor(); + virtual void restoreCursor(); + + /** + * Set flag indicating, if 'Apply and Close' button is clicked on input panel. + * @param theFlag a flag value to be set + */ + virtual void setIsApplyAndClose( const bool theFlag ); + /** + * Get flag indicating, if 'Apply and Close' button is clicked on input panel. + * \return a flag value + */ + virtual bool isApplyAndClose() const; + + /** + * Apply changes done by this operation. + */ + virtual void apply(); private: @@ -127,6 +145,8 @@ private: int myPreviewZLayer; QCursor myCursor; + + bool myIsApplyAndClose; }; #endif diff --git a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx index b158cfb1..09d60392 100644 --- a/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx +++ b/src/HYDROGUI/HYDROGUI_Poly3DOp.cxx @@ -65,7 +65,8 @@ void HYDROGUI_Poly3DOp::startOperation() QString aPoly3DName; if( myIsEdit ) { - myEditedObject = Handle(HYDROData_Polyline3D)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_Polyline3D)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if( !myEditedObject.IsNull() ) aPoly3DName = myEditedObject->GetName(); } diff --git a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx index dff33ecf..9e6737ac 100755 --- a/src/HYDROGUI/HYDROGUI_PolylineOp.cxx +++ b/src/HYDROGUI/HYDROGUI_PolylineOp.cxx @@ -111,7 +111,8 @@ void HYDROGUI_PolylineOp::startOperation() { if( myIsEdit ) { - myEditedObject = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_PolylineXY)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( !myEditedObject.IsNull() && !myEditedObject->IsEditable() ) { // Polyline is imported from GEOM module an is not recognized as @@ -140,7 +141,8 @@ void HYDROGUI_PolylineOp::startOperation() aPanel->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 ); setPreviewManager( aViewManager ); - setCursor(); + if ( isApplyAndClose() ) + setCursor(); QString aPolylineName; if( !myEditedObject.IsNull() ) @@ -200,11 +202,15 @@ void HYDROGUI_PolylineOp::abortOperation() void HYDROGUI_PolylineOp::commitOperation() { - restoreCursor(); + if ( isApplyAndClose() ) + { + restoreCursor(); + + HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); + if ( aPanel ) + aPanel->setOCCViewer( 0 ); + } - HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel(); - if ( aPanel ) - aPanel->setOCCViewer( 0 ); erasePreview(); HYDROGUI_Operation::commitOperation(); diff --git a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx index fd46bc54..a6a99653 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileInterpolateOp.cxx @@ -69,11 +69,14 @@ void HYDROGUI_ProfileInterpolateOp::startOperation() { HYDROGUI_Operation::startOperation(); - HYDROGUI_ProfileInterpolateDlg* aPanel = ::qobject_cast( inputPanel() ); - if ( aPanel ) + if ( isApplyAndClose() ) { + HYDROGUI_ProfileInterpolateDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( aPanel ) + { aPanel->reset(); aPanel->setInterpolators( interpolators() ); + } } } diff --git a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx index 75fbed1e..ff20db08 100644 --- a/src/HYDROGUI/HYDROGUI_ProfileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ProfileOp.cxx @@ -87,7 +87,8 @@ void HYDROGUI_ProfileOp::startOperation() aPanel->reset(); if( myIsEdit ) - myEditedObject = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_Profile)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); QString aProfileName; if( !myEditedObject.IsNull() ) diff --git a/src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx b/src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx index a3b96820..59e5c80c 100644 --- a/src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx +++ b/src/HYDROGUI/HYDROGUI_RiverBottomOp.cxx @@ -60,9 +60,12 @@ void HYDROGUI_RiverBottomOp::startOperation() { HYDROGUI_Operation::startOperation(); - HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast( inputPanel() ); + if ( isApplyAndClose() ) + { + HYDROGUI_RiverBottomDlg* aPanel = ::qobject_cast( inputPanel() ); - aPanel->reset(); + aPanel->reset(); + } } void HYDROGUI_RiverBottomOp::abortOperation() diff --git a/src/HYDROGUI/HYDROGUI_StreamOp.cxx b/src/HYDROGUI/HYDROGUI_StreamOp.cxx index b3615815..2d453d5b 100755 --- a/src/HYDROGUI/HYDROGUI_StreamOp.cxx +++ b/src/HYDROGUI/HYDROGUI_StreamOp.cxx @@ -96,7 +96,8 @@ void HYDROGUI_StreamOp::startOperation() { HYDROGUI_Operation::startOperation(); - myEditedObject.Nullify(); + if ( !myIsEdit || isApplyAndClose() ) + myEditedObject.Nullify(); myHydAxis.clear(); myProfiles.clear(); myProfileParams.clear(); @@ -108,8 +109,9 @@ void HYDROGUI_StreamOp::startOperation() QString anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_STREAM_NAME" ) ); if ( myIsEdit ) { - myEditedObject = - Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = + Handle(HYDROData_Stream)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( !myEditedObject.IsNull() ) { anObjectName = myEditedObject->GetName(); diff --git a/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx b/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx index 5533ea6a..14aaf01c 100644 --- a/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TranslateObstacleOp.cxx @@ -63,7 +63,8 @@ void HYDROGUI_TranslateObstacleOp::startOperation() aPanel->reset(); // Get the edited object - myEditedObject = Handle(HYDROData_Obstacle)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_Obstacle)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if ( myEditedObject.IsNull() ) { abort(); return; diff --git a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx index 50ecc008..9da8d523 100644 --- a/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx +++ b/src/HYDROGUI/HYDROGUI_TwoImagesOp.cxx @@ -88,7 +88,8 @@ void HYDROGUI_TwoImagesOp::startOperation() QString anImageName; if( myIsEdit ) { - myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); + if ( isApplyAndClose() ) + myEditedObject = Handle(HYDROData_Image)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) ); if( !myEditedObject.IsNull() ) anImageName = myEditedObject->GetName(); } diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx index 2f093a20..4d2d847b 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.cxx @@ -63,13 +63,15 @@ HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent, HYDROGUI_Module* t myAllObjects = new QCheckBox( tr( "ALL_OBJECTS" ) ); // Apply and close buttons + myApplyAndClose = new QPushButton( tr("APPLY_AND_CLOSE") ); + myApplyAndClose->setDefault( true ); myApply = new QPushButton( tr("APPLY") ); - myApply->setDefault( true ); myClose = new QPushButton( tr("CLOSE") ); // Layout // apply and close buttons QHBoxLayout* aDlgButtonsLayout = new QHBoxLayout(); + aDlgButtonsLayout->addWidget( myApplyAndClose ); aDlgButtonsLayout->addWidget( myApply ); aDlgButtonsLayout->addWidget( myClose ); aDlgButtonsLayout->addStretch(); @@ -81,6 +83,7 @@ HYDROGUI_ZLevelsDlg::HYDROGUI_ZLevelsDlg( QWidget* theParent, HYDROGUI_Module* t // Connections connect( myAllObjects, SIGNAL( stateChanged( int ) ), this, SLOT( onStateChanged() ) ); + connect( myApplyAndClose, SIGNAL( clicked() ), this, SIGNAL( applyOrderAndClose() ) ); connect( myApply, SIGNAL( clicked() ), this, SIGNAL( applyOrder() ) ); connect( myClose, SIGNAL( clicked() ), this, SLOT( reject() ) ); diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h index 8e7310ea..d4ff2d7d 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h +++ b/src/HYDROGUI/HYDROGUI_ZLevelsDlg.h @@ -50,6 +50,7 @@ public: HYDROGUI_ListModel::ObjectList getObjects() const; signals: + void applyOrderAndClose(); void applyOrder(); private slots: @@ -57,9 +58,10 @@ private slots: private: HYDROGUI_OrderedListWidget* myListWidget; ///< the ordered list widget - QCheckBox* myAllObjects; ///< the show all objects button - QPushButton* myApply; ///< the apply changes button - QPushButton* myClose; ///< the close dialog button + QCheckBox* myAllObjects; ///< the show all objects button + QPushButton* myApplyAndClose; ///< the apply changes and close dialog button + QPushButton* myApply; ///< the apply changes button + QPushButton* myClose; ///< the close dialog button }; #endif diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx index e2b52b87..bfbe5aa7 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.cxx @@ -84,6 +84,7 @@ void HYDROGUI_ZLevelsOp::startOperation() // Show the dialog if ( !myDlg ) { myDlg = new HYDROGUI_ZLevelsDlg( module()->getApp()->desktop(), module() ); + connect( myDlg, SIGNAL( applyOrderAndClose() ), this, SLOT( onApplyAndClose() ) ); connect( myDlg, SIGNAL( applyOrder() ), this, SLOT( onApply() ) ); connect( myDlg, SIGNAL( rejected() ), this, SLOT( onCancel() ) ); } @@ -135,4 +136,11 @@ void HYDROGUI_ZLevelsOp::processCancel() delete myDlg; myDlg = 0; } -} \ No newline at end of file +} + +void HYDROGUI_ZLevelsOp::onApplyAndClose() +{ + HYDROGUI_Operation::onApplyAndClose(); + if ( myDlg ) + myDlg->reject(); +} diff --git a/src/HYDROGUI/HYDROGUI_ZLevelsOp.h b/src/HYDROGUI/HYDROGUI_ZLevelsOp.h index e0497354..49f4308c 100644 --- a/src/HYDROGUI/HYDROGUI_ZLevelsOp.h +++ b/src/HYDROGUI/HYDROGUI_ZLevelsOp.h @@ -47,6 +47,9 @@ protected: QStringList& theBrowseObjectsEntries ); virtual void processCancel(); +protected slots: + virtual void onApplyAndClose(); + private: HYDROGUI_ZLevelsDlg* myDlg; diff --git a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts index 86277845..b45a5d8c 100644 --- a/src/HYDROGUI/resources/HYDROGUI_msg_en.ts +++ b/src/HYDROGUI/resources/HYDROGUI_msg_en.ts @@ -436,6 +436,10 @@ First remove objects which are created on their basis. HYDROGUI_InputPanel + + APPLY_AND_CLOSE + Apply and Close + APPLY Apply @@ -444,6 +448,10 @@ First remove objects which are created on their basis. CANCEL Cancel + + CLOSE + Close + HELP Help @@ -2186,6 +2194,10 @@ Polyline should consist from one not closed curve. ALL_OBJECTS_CHECKED_TLT Exclude hidden objects from the list + + APPLY_AND_CLOSE + Apply and Close + APPLY Apply