]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
PAL12058 - fast way to activate preferences if external browser is unaccessible
authorasl <asl@opencascade.com>
Fri, 7 Apr 2006 08:21:40 +0000 (08:21 +0000)
committerasl <asl@opencascade.com>
Fri, 7 Apr 2006 08:21:40 +0000 (08:21 +0000)
src/LightApp/LightApp_Application.cxx
src/LightApp/LightApp_Application.h
src/LightApp/resources/LightApp_msg_en.po

index 894641483040c1a7884919477aa7bdb8778314a4..b711b24cdf5819a62664ad8906eb2b79c0f73384 100644 (file)
@@ -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 );
+}
index 3f57fd09edaebc9e4e83e50a01a82a1dac10573d..bf54e9bb4ee375355bdfcf9998e8ec6d0565e2fe 100644 (file)
@@ -129,6 +129,8 @@ public:
 
   static int                          studyId();
 
+  virtual bool                        event( QEvent* );
+
 signals:
   void                                studyOpened();
   void                                studySaved();
index 7ec57f7e021c5225a04d06a975a23815d2a8cbf0..3f5476557502f208d3fcb5263c82b0b821b59ca4 100644 (file)
@@ -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"