Salome HOME
updated copyright message
[modules/gui.git] / src / HelpBrowser / HelpBrowser.cxx
index f2e26aca161317d835d0a6690dac9b836c1a0034..a9237a271beb7f0cb13f4d3c1051e735ffe05d0d 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2014  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 //
 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
@@ -6,7 +6,7 @@
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
 // License as published by the Free Software Foundation; either
-// version 2.1 of the License.
+// version 2.1 of the License, or (at your option) any later version.
 //
 // This library is distributed in the hope that it will be useful,
 // but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -19,6 +19,7 @@
 //
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
+
 // File   : HelpBrowser.cxx
 // Author : Vadim SANDLER, OpenCASCADE S.A.S. (vadim.sandler@opencascade.com)
 //          Maxim GLIBIN, OpenCASCADE S.A.S. (maxim.glibin@opencascade.com)
 
 #include <iostream>
 
+#ifdef WIN32
+#include <windows.h>
+#endif
+
+
 namespace
 {
   void printHelp()
@@ -48,7 +54,7 @@ namespace
     std::cout << std::endl;
     std::cout << "SALOME Help Browser" << std::endl;
     std::cout << std::endl;
-    std::cout << "usage: " << qPrintable( fi.fileName() ) << " [options] file" << std::endl;
+    std::cout << "usage: " << qUtf8Printable( fi.fileName() ) << " [options] file" << std::endl;
     std::cout << "    file is a help file to be opened" << std::endl;
     std::cout << std::endl;
     std::cout << "Options:" << std::endl;
@@ -101,15 +107,17 @@ public:
   }
   void load( const QString& url )
   {
-    QtxWebBrowser::load( url );
-    RaiseWindowHelper* helper = new RaiseWindowHelper( this );
+       if( ! url.startsWith("--remove") ) {
+         QtxWebBrowser::load( url );
+      RaiseWindowHelper* helper = new RaiseWindowHelper( this );
+       }
   }
 };
 
 int main( int argc, char **argv )
 {
   // Set application name (for preferences)
-  HelpBrowser_Application::setApplicationName( "salome" );
+  HelpBrowser_Application::setApplicationName("salome");
 
   // Specify application identifier via its name
   QFileInfo fi( argv[0] );
@@ -151,6 +159,15 @@ int main( int argc, char **argv )
     }
   }
 
+#if defined(WIN32) && defined(UNICODE)                   
+  LPWSTR *szArglist = NULL;
+  int nArgs;
+  szArglist = CommandLineToArgvW(GetCommandLineW(), &nArgs);         
+  helpfile = QString::fromWCharArray(szArglist[nArgs-1]);
+  // Free memory allocated for CommandLineToArgvW arguments.
+  LocalFree(szArglist);
+#endif
+
   // Show help and exit if '--help' or '-h' option has been specified via command line
   if ( showHelp )
   {
@@ -220,7 +237,8 @@ int main( int argc, char **argv )
       // Clear file system watcher if one has have path
       instance.clearWatcher();
 
-      if ( aFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
+      QFileInfo wfi( aFile.fileName() );
+      if ( QDir().mkpath( wfi.absolutePath() ) && aFile.open( QIODevice::WriteOnly | QIODevice::Text ) )
       {
         // Write date and time when the file was created
         QTextStream aOutStream( &aFile );
@@ -233,6 +251,9 @@ int main( int argc, char **argv )
     }
   }
 
+  if ( removeId )
+    return 0;
+
   // Load translations
   QtxTranslator tqt, tsal;
   if ( !language.isEmpty() ) {
@@ -257,7 +278,7 @@ int main( int argc, char **argv )
 
   // Load file specified via command line
   if ( helpfile.isEmpty() ) {
-    QString docdir = qgetenv( "DOCUMENTATION_ROOT_DIR" );
+    QString docdir = Qtx::getenv( "DOCUMENTATION_ROOT_DIR" );
     if ( !docdir.isEmpty() )
       helpfile = QDir::toNativeSeparators( QString( "%1/index.html" ).arg( docdir ) );
   }