<commit_before>/*=========================================================================

  Program:   Monteverdi2
  Language:  C++


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See Copyright.txt for details.

  Monteverdi2 is distributed under the CeCILL licence version 2. See
  Licence_CeCILL_V2-en.txt or
  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"


/*****************************************************************************/
/* INCLUDE SECTION                                                           */

//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QPixmap>
#include <QSplashScreen>

//
// System includes (sorted by alphabetic order)
#include <exception>

//
// ITK includes (sorted by alphabetic order)
#include "itksys/SystemTools.hxx"

//
// OTB includes (sorted by alphabetic order)

//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdApplication.h"
#include "mvdMainWindow.h"

/*****************************************************************************/
/* FUNCTIONS DECLARATION                                                     */


/*****************************************************************************/
/* MAIN                                                                      */

int
main( int argc, char* argv[] )
{
  QApplication qtApp( argc, argv );

  // 0. Splash-screen.
#if !defined( _DEBUG )
  QPixmap pixmap(QLatin1String( ":/images/application_splash" ));
  QSplashScreen splash(pixmap);
  splash.show();
  qtApp.processEvents();//This is used to accept a click on the screen so that user can cancel the screen
#endif

  // 1. Initialize application and sync settings.
  mvd::Application application( &qtApp );
  application.Initialize();

  // 2. Initialize main-window (UI).
  mvd::MainWindow mainWindow;
  mainWindow.Initialize();

  // 3. Initialize cache directory.
  try
    {
    mainWindow.SetupCacheDir();
    }
  catch( std::exception& exc )
    {
    QMessageBox::critical(
      &mainWindow,
      QCoreApplication::translate(
	PROJECT_NAME,
	PROJECT_NAME " - Critical error!"
      ),
      QCoreApplication::translate(
	PROJECT_NAME,
	"Error when creating repository cache-directory:\n"
	"%1\n"
	"Application will exit!"
      )
      .arg( exc.what() )
    );

    return -1;
    }

  // 4. Initialize database.
  mvd::CountType nb = application.OpenDatabase();
  if( nb > 0 )
    {
#if defined( _DEBUG )
    QMessageBox::StandardButton button =
#endif
      QMessageBox::warning(
  &mainWindow,
  QCoreApplication::translate(
    PROJECT_NAME,
    PROJECT_NAME " " Monteverdi2_VERSION_STRING " - Warning! "
  ),
  QCoreApplication::translate(
    PROJECT_NAME,
    "There are %1 outdated dataset(s) in cache-directory.\n\n"
    "Please remove cache-directory '%2' and restart "
    PROJECT_NAME ".\n\n"
    "Do you to delete cache-directory '%2' before quitting " PROJECT_NAME "?"
  ).arg( nb ).arg( application.GetCacheDir().path() ),
  QMessageBox::Yes | QMessageBox::No,
  QMessageBox::Yes
      );

    if( button==QMessageBox::Yes )
      {
      if( application.GetCacheDir()==QDir::home() )
	{<commit_msg>COMP: Fixed bad #if defined( _DEBUG ) statement.<commit_after>/*=========================================================================

  Program:   Monteverdi2
  Language:  C++


  Copyright (c) Centre National d'Etudes Spatiales. All rights reserved.
  See Copyright.txt for details.

  Monteverdi2 is distributed under the CeCILL licence version 2. See
  Licence_CeCILL_V2-en.txt or
  http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt for more details.

  This software is distributed WITHOUT ANY WARRANTY; without even
  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  PURPOSE.  See the above copyright notices for more information.

=========================================================================*/

//
// Configuration include.
//// Included at first position before any other ones.
#include "ConfigureMonteverdi2.h"


/*****************************************************************************/
/* INCLUDE SECTION                                                           */

//
// Qt includes (sorted by alphabetic order)
//// Must be included before system/custom includes.
#include <QPixmap>
#include <QSplashScreen>

//
// System includes (sorted by alphabetic order)
#include <exception>

//
// ITK includes (sorted by alphabetic order)
#include "itksys/SystemTools.hxx"

//
// OTB includes (sorted by alphabetic order)

//
// Monteverdi includes (sorted by alphabetic order)
#include "mvdApplication.h"
#include "mvdMainWindow.h"

/*****************************************************************************/
/* FUNCTIONS DECLARATION                                                     */


/*****************************************************************************/
/* MAIN                                                                      */

int
main( int argc, char* argv[] )
{
  QApplication qtApp( argc, argv );

  // 0. Splash-screen.
#if !defined( _DEBUG )
  QPixmap pixmap(QLatin1String( ":/images/application_splash" ));
  QSplashScreen splash(pixmap);
  splash.show();
  qtApp.processEvents();//This is used to accept a click on the screen so that user can cancel the screen
#endif

  // 1. Initialize application and sync settings.
  mvd::Application application( &qtApp );
  application.Initialize();

  // 2. Initialize main-window (UI).
  mvd::MainWindow mainWindow;
  mainWindow.Initialize();

  // 3. Initialize cache directory.
  try
    {
    mainWindow.SetupCacheDir();
    }
  catch( std::exception& exc )
    {
    QMessageBox::critical(
      &mainWindow,
      QCoreApplication::translate(
	PROJECT_NAME,
	PROJECT_NAME " - Critical error!"
      ),
      QCoreApplication::translate(
	PROJECT_NAME,
	"Error when creating repository cache-directory:\n"
	"%1\n"
	"Application will exit!"
      )
      .arg( exc.what() )
    );

    return -1;
    }

  // 4. Initialize database.
  mvd::CountType nb = application.OpenDatabase();
  if( nb > 0 )
    {
    QMessageBox::StandardButton button =
      QMessageBox::warning(
	&mainWindow,
	QCoreApplication::translate(
	  PROJECT_NAME,
	  PROJECT_NAME " " Monteverdi2_VERSION_STRING " - Warning! "
	),
	QCoreApplication::translate(
	  PROJECT_NAME,
	  "There are %1 outdated dataset(s) in cache-directory.\n\n"
	  "Please remove cache-directory '%2' and restart "
	  PROJECT_NAME ".\n\n"
	  "Do you to delete cache-directory '%2' before quitting " PROJECT_NAME "?"
	).arg( nb ).arg( application.GetCacheDir().path() ),
	QMessageBox::Yes | QMessageBox::No,
	QMessageBox::Yes
      );

    if( button==QMessageBox::Yes )
      {
      if( application.GetCacheDir()==QDir::home() )
	{
{'fraction_non_alphanumeric': 0.20654877037855762, 'fraction_numerical': 0.005250069079856314, 'mean_word_length': 3.1177474402730376, 'pattern_counts': {'":': 2, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 14, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7470366', 'n_tokens_mistral': 2115, 'n_tokens_neox': 1986, 'n_words': 548}