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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 11.1)


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