QtApplicationHandler.cpp
Go to the documentation of this file.
00001 // ****************************************************************************
00002 // Filename:  QtApplicationHandler.cpp
00003 // Author:    Florian Hecht
00004 // Date:      2008
00005 // ****************************************************************************
00006 
00007 
00008 #include "QtApplicationHandler.h"
00009 
00010 #include <qapplication.h>
00011 
00012 static char app_name[] = "IVT_APPLICATION\0";
00013 static int my_argc = 1;
00014 static char *my_argv[2] = { app_name, NULL};
00015 
00016 CQtApplicationHandler *CQtApplicationHandler::m_pQtApplicationHandler = NULL;
00017 
00018 CQtApplicationHandler::CQtApplicationHandler(int argc, char **argv)
00019 {
00020         m_pApplication = 0;
00021         m_bExit = false;
00022         
00023         if (argc == 0 && argv == NULL)
00024         {
00025                 m_pApplication = new QApplication(my_argc, my_argv);
00026         }
00027         else
00028         {
00029                 my_argc = argc;
00030                 m_pApplication = new QApplication(my_argc, argv);
00031         }
00032         
00033         m_pApplication->connect(m_pApplication, SIGNAL(lastWindowClosed()), this, SLOT(Exit()));
00034 
00035         m_pQtApplicationHandler = this;
00036         
00037         // undo the setting of the locale by Qt
00038         // this makes dialogs appear in english on any system
00039         // but it doesn't screw with sscanf and fscanf, which
00040         // is more important to us
00041         setlocale(LC_ALL, "C");
00042 }
00043 
00044 CQtApplicationHandler::~CQtApplicationHandler()
00045 {
00046         if (m_pApplication)
00047                 delete m_pApplication;
00048 
00049         m_pQtApplicationHandler = NULL;
00050 }
00051 
00052 bool CQtApplicationHandler::ProcessEventsAndGetExit()
00053 {
00054         #ifdef QT_THREAD_SUPPORT
00055         
00056         m_pApplication->lock();
00057         m_pApplication->processEvents();
00058         m_pApplication->unlock();
00059         
00060         #else
00061         
00062         m_pApplication->processEvents();
00063         
00064         #endif
00065         
00066         return m_bExit;
00067 }
00068 
00069 void CQtApplicationHandler::Reset()
00070 {
00071         if (!m_pApplication)
00072         {
00073                 m_pApplication = new QApplication(my_argc, my_argv);
00074                 m_pApplication->connect(m_pApplication, SIGNAL(lastWindowClosed()), this, SLOT(Exit()));
00075         }
00076         
00077         m_bExit = false;
00078 }


asr_ivt
Author(s): Allgeyer Tobias, Hutmacher Robin, Kleinert Daniel, Meißner Pascal, Scholz Jonas, Stöckle Patrick
autogenerated on Thu Jun 6 2019 21:46:58