From 0c68b686445350de395a11747fc7b15f2cc24702 Mon Sep 17 00:00:00 2001 From: asl Date: Fri, 7 Apr 2006 08:21:40 +0000 Subject: [PATCH] PAL12058 - fast way to activate preferences if external browser is unaccessible --- src/LightApp/LightApp_Application.cxx | 58 +++++++++++++++-------- src/LightApp/LightApp_Application.h | 2 + src/LightApp/resources/LightApp_msg_en.po | 4 +- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index 894641483..b711b24cd 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -824,14 +824,17 @@ void LightApp_Application::updateCommandsStatus() class RunBrowser: public QThread { public: - RunBrowser(QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL): + RunBrowser( LightApp_Application* app, QString theApp, QString theParams, QString theHelpFile, QString theContext=NULL): myApp(theApp), myParams(theParams), #ifdef WIN32 myHelpFile("file://" + theHelpFile + theContext), #else myHelpFile("file:" + theHelpFile + theContext), #endif - myStatus(0) {}; + myStatus(0), + myLApp( app ) +{ +}; virtual void run() { @@ -843,18 +846,12 @@ public: myStatus = system(aCommand); if(myStatus != 0) { - QCustomEvent* ce2000 = new QCustomEvent (2000); - postEvent (qApp, ce2000); + QCustomEvent* ce2000 = new QCustomEvent( 2000 ); + QString* msg = new QString( QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").arg(myApp).arg(myHelpFile) ); + ce2000->setData( msg ); + postEvent( myLApp, ce2000 ); } } - if( myStatus != 0) - { - qApp->lock(); - SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), - QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").arg(myApp).arg(myHelpFile), - QObject::tr("BUT_OK")); - qApp->unlock(); - } } private: @@ -862,7 +859,7 @@ private: QString myParams; QString myHelpFile; int myStatus; - + LightApp_Application* myLApp; }; //======================================================================= @@ -885,13 +882,14 @@ void LightApp_Application::onHelpContentsModule() QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); if (!anApp.isEmpty()) { - RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); + RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile ); rs->start(); } else { - SUIT_MessageBox::warn1(desktop(), tr("WRN_WARNING"), + if( SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"), tr("DEFINE_EXTERNAL_BROWSER"), - tr("BUT_OK")); + tr("BUT_OK"),tr("BUT_CANCEL"),0,1,0 )==0 ) + onPreferences(); } } @@ -910,13 +908,14 @@ void LightApp_Application::onHelpContextModule(const QString& theComponentName, QString aParams = resMgr->stringValue("ExternalBrowser", "parameters"); if (!anApp.isEmpty()) { - RunBrowser* rs = new RunBrowser(anApp, aParams, helpFile); + RunBrowser* rs = new RunBrowser( this, anApp, aParams, helpFile ); rs->start(); } else { - SUIT_MessageBox::warn1(desktop(), tr("WRN_WARNING"), - tr("DEFINE_EXTERNAL_BROWSER"), - tr("BUT_OK")); + if( SUIT_MessageBox::warn2(desktop(), tr("WRN_WARNING"), + tr("DEFINE_EXTERNAL_BROWSER"), + tr("BUT_OK"), tr("BUT_CANCEL"),0,1,0)==0 ) + onPreferences(); } } @@ -1159,7 +1158,7 @@ void LightApp_Application::updateObjectBrowser( const bool updateModels ) } if( objectBrowser() ) - objectBrowser()->setAutoUpdate( true ); + objectBrowser()->setAutoUpdate( isAutoUpdate ); } if ( objectBrowser() ) { @@ -2220,3 +2219,20 @@ void LightApp_Application::onVisibilityChanged( bool visible ) return; } } + +bool LightApp_Application::event( QEvent* e ) +{ + if( e && e->type()==2000 ) + { + QCustomEvent* ce = ( QCustomEvent* )e; + QString* d = ( QString* )ce->data(); + if( SUIT_MessageBox::warn2(0, tr("WRN_WARNING"), + d ? *d : "", + tr("BUT_OK"), tr("BUT_CANCEL"), 0, 1, 0 )==0 ) + onPreferences(); + if( d ) + delete d; + return true; + } + return CAM_Application::event( e ); +} diff --git a/src/LightApp/LightApp_Application.h b/src/LightApp/LightApp_Application.h index 3f57fd09e..bf54e9bb4 100644 --- a/src/LightApp/LightApp_Application.h +++ b/src/LightApp/LightApp_Application.h @@ -129,6 +129,8 @@ public: static int studyId(); + virtual bool event( QEvent* ); + signals: void studyOpened(); void studySaved(); diff --git a/src/LightApp/resources/LightApp_msg_en.po b/src/LightApp/resources/LightApp_msg_en.po index 7ec57f7e0..3f5476557 100644 --- a/src/LightApp/resources/LightApp_msg_en.po +++ b/src/LightApp/resources/LightApp_msg_en.po @@ -81,10 +81,10 @@ msgid "LightApp_Application::INF_CANCELLED" msgstr "Module activation cancelled" msgid "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" -msgstr "External browser \"%1\" can not show help page \"%2\"" +msgstr "External browser \"%1\" can not show help page \"%2\". Do you want to change it in preferences?" msgid "LightApp_Application::DEFINE_EXTERNAL_BROWSER" -msgstr "Define external browser in preferences" +msgstr "External browser is not found. Do you want to define it in preferences?" msgid "LightApp_Application::DATA_MODELS" msgstr "Data models" -- 2.39.2