From 5339ac3f519b59ab37c48f1a6a3f1184a74566d3 Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Tue, 6 Aug 2013 09:21:26 -0500 Subject: [PATCH] Automated update from Qt3 --- src/kernel/ntqapplication.h | 5 ++- src/kernel/qapplication.cpp | 73 +++++++++++++++++++++++++++++++------ 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/src/kernel/ntqapplication.h b/src/kernel/ntqapplication.h index fdf75aa5..eeed8c9e 100644 --- a/src/kernel/ntqapplication.h +++ b/src/kernel/ntqapplication.h @@ -77,6 +77,7 @@ class Q_EXPORT TQApplication : public TQObject public: TQApplication( int &argc, char **argv ); TQApplication( int &argc, char **argv, bool GUIenabled ); + TQApplication( int &argc, char **argv, bool GUIenabled, bool SMenabled ); enum Type { Tty, GuiClient, GuiServer }; TQApplication( int &argc, char **argv, Type ); #if defined(Q_WS_X11) @@ -322,8 +323,8 @@ protected: bool event(TQEvent *); private: - void construct( int &argc, char **argv, Type ); - void initialize( int, char ** ); + void construct( int &argc, char **argv, Type, bool enable_sm ); + void initialize( int, char **, bool enable_sm = true ); void init_precmdline(); void process_cmdline( int* argcptr, char ** argv ); bool internalNotify( TQObject *, TQEvent * ); diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 73b2e44d..feeaf191 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -793,10 +793,9 @@ void TQApplication::process_cmdline( int* argcptr, char ** argv ) //######### BINARY COMPATIBILITY constructor TQApplication::TQApplication( int &argc, char **argv ) { - construct( argc, argv, GuiClient ); + construct( argc, argv, GuiClient, true ); } - /*! Constructs an application object with \a argc command line arguments in \a argv. If \a GUIenabled is TRUE, a GUI application is @@ -838,7 +837,55 @@ TQApplication::TQApplication( int &argc, char **argv ) TQApplication::TQApplication( int &argc, char **argv, bool GUIenabled ) { - construct( argc, argv, GUIenabled ? GuiClient : Tty ); + construct( argc, argv, GUIenabled ? GuiClient : Tty, true ); +} + +/*! + Constructs an application object with \a argc command line arguments + in \a argv. If \a GUIenabled is TRUE, a GUI application is + constructed, otherwise a non-GUI (console) application is created. + If \a SMEnabled is TRUE, session management support is enabled (default). + + Set \a GUIenabled to FALSE for programs without a graphical user + interface that should be able to run without a window system. + + Set \a SMEnabled to FALSE to disable session management. + Session management cannot be enabled at a later time if disabled here. + + On X11, the window system is initialized if \a GUIenabled is TRUE. + If \a GUIenabled is FALSE, the application does not connect to the + X-server. + On Windows and Macintosh, currently the window system is always + initialized, regardless of the value of GUIenabled. This may change in + future versions of TQt. + + The following example shows how to create an application that + uses a graphical interface when available. + \code + int main( int argc, char **argv ) + { +#ifdef Q_WS_X11 + bool useGUI = getenv( "DISPLAY" ) != 0; +#else + bool useGUI = TRUE; +#endif + TQApplication app(argc, argv, useGUI); + + if ( useGUI ) { + //start GUI version + ... + } else { + //start non-GUI version + ... + } + return app.exec(); + } +\endcode +*/ + +TQApplication::TQApplication( int &argc, char **argv, bool GUIenabled, bool SMenabled ) +{ + construct( argc, argv, GUIenabled ? GuiClient : Tty, SMenabled ); } /*! @@ -851,7 +898,7 @@ TQApplication::TQApplication( int &argc, char **argv, bool GUIenabled ) */ TQApplication::TQApplication( int &argc, char **argv, Type type ) { - construct( argc, argv, type ); + construct( argc, argv, type, true ); } Q_EXPORT void tqt_ucm_initialize( TQApplication *theApp ) @@ -860,12 +907,12 @@ Q_EXPORT void tqt_ucm_initialize( TQApplication *theApp ) return; int argc = theApp->argc(); char **argv = theApp->argv(); - theApp->construct( argc, argv, tqApp->type() ); + theApp->construct( argc, argv, tqApp->type(), true ); Q_ASSERT( tqApp == theApp ); } -void TQApplication::construct( int &argc, char **argv, Type type ) +void TQApplication::construct( int &argc, char **argv, Type type, bool enable_sm ) { tqt_appType = type; tqt_is_gui_used = (type != Tty); @@ -880,7 +927,7 @@ void TQApplication::construct( int &argc, char **argv, Type type ) tqt_init( &argc, argv, type ); // Must be called before initialize() process_cmdline( &argc, argv ); - initialize( argc, argv ); + initialize( argc, argv, enable_sm ); if ( tqt_is_gui_used ) tqt_maxWindowRect = desktop()->rect(); if ( currentEventLoop() ) @@ -1020,7 +1067,7 @@ void TQApplication::init_precmdline() Initializes the TQApplication object, called from the constructors. */ -void TQApplication::initialize( int argc, char **argv ) +void TQApplication::initialize( int argc, char **argv, bool enable_sm ) { #ifdef QT_THREAD_SUPPORT tqt_mutex = new TQMutex( TRUE ); @@ -1044,10 +1091,12 @@ void TQApplication::initialize( int argc, char **argv ) is_app_running = TRUE; // no longer starting up #ifndef QT_NO_SESSIONMANAGER - // connect to the session manager - if ( !session_key ) - session_key = new TQString; - session_manager = new TQSessionManager( tqApp, session_id, *session_key ); + if (enable_sm) { + // connect to the session manager + if ( !session_key ) + session_key = new TQString; + session_manager = new TQSessionManager( tqApp, session_id, *session_key ); + } #endif }