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 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /externals/g4tools/include/toolx/Qt/session (Version 11.3.0) and /externals/g4tools/include/toolx/Qt/session (Version 10.0.p4)


  1 // Copyright (C) 2010, Guy Barrand. All rights    
  2 // See the file tools.license for terms.          
  3                                                   
  4 #ifndef toolx_Qt_session                          
  5 #define toolx_Qt_session                          
  6                                                   
  7 // pure Qt code, no GL.                           
  8                                                   
  9 #include "s2q"                                    
 10                                                   
 11 #include <QtCore/qnamespace.h>                    
 12                                                   
 13 #if QT_VERSION < 0x050000                         
 14 #include <QtGui/qapplication.h>                   
 15 #include <QtGui/qwidget.h>                        
 16 #else                                             
 17 #include <QtWidgets/qapplication.h>               
 18 #include <QtWidgets/qwidget.h>                    
 19 #endif                                            
 20                                                   
 21 #include <ostream>                                
 22 #include <vector>                                 
 23                                                   
 24 namespace toolx {                                 
 25 namespace Qt {                                    
 26                                                   
 27 class session {                                   
 28 public:                                           
 29   session(std::ostream& a_out,int& a_argc,char    
 30   :m_out(a_out)                                   
 31   ,m_qapp(0)                                      
 32   ,m_own_qapp(false)                              
 33   {                                               
 34     if(qApp) {                                    
 35       m_qapp = qApp;                              
 36       m_own_qapp = false;                         
 37     } else {                                      
 38       m_qapp = new QApplication(a_argc,a_argv)    
 39       m_own_qapp = true;                          
 40     }                                             
 41   }                                               
 42   session(std::ostream& a_out,QApplication* a_    
 43   :m_out(a_out)                                   
 44   ,m_qapp(a_qapp)                                 
 45   ,m_own_qapp(false)                              
 46   {}                                              
 47   virtual ~session() {                            
 48     if(m_own_qapp && m_qapp) delete m_qapp;       
 49     m_qapp = 0;                                   
 50     m_own_qapp = false;                           
 51   }                                               
 52 protected:                                        
 53   session(const session& a_from)                  
 54   :m_out(a_from.m_out)                            
 55   ,m_qapp(0)                                      
 56   ,m_own_qapp(false)                              
 57   {}                                              
 58   session& operator=(const session& a_from){      
 59     if(&a_from==this) return *this;               
 60     return *this;                                 
 61   }                                               
 62 public:                                           
 63   std::ostream& out() const {return m_out;}       
 64   bool is_valid() const {return m_qapp?true:fa    
 65   bool steer() {                                  
 66     if(!m_qapp) return false;                     
 67     m_qapp->exec();                               
 68     return true;                                  
 69   }                                               
 70   bool sync() {                                   
 71     if(!m_qapp) return false;                     
 72     m_qapp->processEvents();                      
 73     return true;                                  
 74   }                                               
 75 public:                                           
 76   QApplication* qapp() const {return m_qapp;}     
 77   QWidget* create_window(const char* a_title,i    
 78     if(!m_qapp) return 0;                         
 79 #if defined(_MSC_VER) || defined(__MINGW32__)     
 80     if(a_y<=0) a_y = 60;                          
 81 #endif                                            
 82     QWidget* top = new QWidget();                 
 83     top->setWindowFlags(::Qt::CustomizeWindowH    
 84                       | ::Qt::WindowTitleHint     
 85                       | ::Qt::WindowMinMaxButt    
 86 //                    | ::Qt::WindowSystemMenu    
 87 //          | ::Qt::WindowFullscreenButtonHint    
 88     );                                            
 89     top->setGeometry(a_x,a_y,a_width,a_height)    
 90     top->setWindowTitle(s2q(a_title));            
 91   //top->setAttribute(Qt::WA_DeleteOnClose,fal    
 92     return top;                                   
 93   }                                               
 94   void delete_window(QWidget* a_window) const     
 95     if(!m_qapp) return;                           
 96     delete a_window;                              
 97   }                                               
 98 protected:                                        
 99   std::ostream& m_out;                            
100   QApplication* m_qapp;                           
101   bool m_own_qapp;                                
102 };                                                
103                                                   
104 }}                                                
105                                                   
106                                                   
107 #endif                                            
108