From f15587f1c484f3d15bd8ddbe39fd12d3fa3a182d Mon Sep 17 00:00:00 2001 From: stv Date: Tue, 22 Nov 2005 08:13:29 +0000 Subject: [PATCH] STD_Application::onSaveAs(): Saving error message box was added. --- src/STD/STD_Application.cxx | 71 ++++++++++++++++++++++----------- src/STD/resources/STD_msg_en.po | 3 ++ 2 files changed, 50 insertions(+), 24 deletions(-) diff --git a/src/STD/STD_Application.cxx b/src/STD/STD_Application.cxx index c53af663d..e3ef0126c 100755 --- a/src/STD/STD_Application.cxx +++ b/src/STD/STD_Application.cxx @@ -215,6 +215,8 @@ void STD_Application::createActions() /*!Opens new application*/ void STD_Application::onNewDoc() { + QApplication::setOverrideCursor( Qt::waitCursor ); + if ( !activeStudy() ) { createEmptyStudy(); @@ -232,6 +234,8 @@ void STD_Application::onNewDoc() aApp->activeStudy()->createDocument(); } } + + QApplication::restoreOverrideCursor(); } /*!Put file name from file dialog to onOpenDoc(const QString&) function*/ @@ -248,6 +252,8 @@ void STD_Application::onOpenDoc() /*! \retval true, if document was opened successful, else false.*/ bool STD_Application::onOpenDoc( const QString& aName ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + bool res = true; if ( !activeStudy() ) { @@ -278,6 +284,9 @@ bool STD_Application::onOpenDoc( const QString& aName ) else aApp->desktop()->setActiveWindow(); } + + QApplication::restoreOverrideCursor(); + return res; } @@ -331,11 +340,10 @@ void STD_Application::afterCloseDoc() } /*!Close document, if it's possible.*/ -void STD_Application::onCloseDoc(bool ask) +void STD_Application::onCloseDoc( bool ask ) { - if (ask) - if ( !isPossibleToClose() ) - return; + if ( ask && !isPossibleToClose() ) + return; SUIT_Study* study = activeStudy(); @@ -397,7 +405,7 @@ bool STD_Application::isPossibleToClose() case 2: break; case 3: - myClosePermanently = false; + myClosePermanently = false; break; case 4: default: @@ -418,16 +426,22 @@ void STD_Application::onSaveDoc() bool isOk = false; if ( activeStudy()->isSaved() ) { - putInfo(tr("INF_DOC_SAVING") + activeStudy()->studyName()); + putInfo( tr( "INF_DOC_SAVING" ) + activeStudy()->studyName() ); + + QApplication::setOverrideCursor( Qt::waitCursor ); + isOk = activeStudy()->saveDocument(); - if ( !isOk ) { - putInfo(""); + + QApplication::restoreOverrideCursor(); + + if ( !isOk ) + { + putInfo( "" ); SUIT_MessageBox::error1( desktop(), tr( "TIT_FILE_SAVEAS" ), - tr( "MSG_CANT_SAVE" ).arg( activeStudy()->studyName() ), - tr( "BUT_OK" ) ); - } else { - putInfo(tr("INF_DOC_SAVED").arg("")); + tr( "MSG_CANT_SAVE" ).arg( activeStudy()->studyName() ), tr( "BUT_OK" ) ); } + else + putInfo( tr( "INF_DOC_SAVED" ).arg( "" ) ); } if ( isOk ) @@ -443,17 +457,26 @@ bool STD_Application::onSaveAsDoc() if ( !study ) return false; - QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 ); - if ( aName.isNull() ) - return false; + bool isOk = false; + while ( !isOk ) + { + QString aName = getFileName( false, study->studyName(), getFileFilter(), QString::null, 0 ); + if ( aName.isNull() ) + return false; - putInfo(tr("INF_DOC_SAVING") + aName); - bool isOk = study->saveDocumentAs( aName ); + QApplication::setOverrideCursor( Qt::waitCursor ); - if (isOk) - putInfo(tr("INF_DOC_SAVED").arg(aName)); - else - putInfo(""); + putInfo( tr( "INF_DOC_SAVING" ) + aName ); + isOk = study->saveDocumentAs( aName ); + + putInfo( isOk ? tr( "INF_DOC_SAVED" ).arg( aName ) : "" ); + + QApplication::restoreOverrideCursor(); + + if ( !isOk ) + SUIT_MessageBox::error1( desktop(), tr( "ERROR" ), + tr( "INF_DOC_SAVING_FAILS" ).arg( aName ), tr( "BUT_OK" ) ); + } updateDesktopTitle(); updateCommandsStatus(); @@ -464,9 +487,9 @@ bool STD_Application::onSaveAsDoc() /*!Closing session.*/ void STD_Application::onExit() { - int aAnswer = SUIT_MessageBox::info2(desktop(), tr("INF_DESK_EXIT"), tr("QUE_DESK_EXIT"), - tr ("BUT_OK"), tr ("BUT_CANCEL"), 1, 2, 2); - if (aAnswer == 1) + int aAnswer = SUIT_MessageBox::info2( desktop(), tr( "INF_DESK_EXIT" ), tr( "QUE_DESK_EXIT" ), + tr( "BUT_OK" ), tr( "BUT_CANCEL" ), 1, 2, 2 ); + if ( aAnswer == 1 ) SUIT_Session::session()->closeSession(); } diff --git a/src/STD/resources/STD_msg_en.po b/src/STD/resources/STD_msg_en.po index 3765f846e..a88cd6ece 100755 --- a/src/STD/resources/STD_msg_en.po +++ b/src/STD/resources/STD_msg_en.po @@ -323,6 +323,9 @@ msgstr "Study %1 saved" msgid "STD_Application::INF_DOC_SAVING" msgstr "Saving study " +msgid "STD_Application::INF_DOC_SAVING_FAILS" +msgstr "Can't save file \"%1\".\nPossible reason is permission denied or disc full.\nTry to use another file name." + msgid "CLOSE_DLG_SAVE_CLOSE" msgstr "&Save&&Close" -- 2.39.2