diff options
author | Timothy Pearson <[email protected]> | 2013-08-06 09:20:52 -0500 |
---|---|---|
committer | Timothy Pearson <[email protected]> | 2013-08-06 09:20:52 -0500 |
commit | 49075fd69d70b7850febe2fbc11f81d2d4e62cf1 (patch) | |
tree | d46a25fa952b0ed0b4e355b24b747e814fbcb2f0 /src/kernel/qapplication.cpp | |
parent | d2ab408c068de5c4841e3a7d5fb4dce2e1a66ea9 (diff) | |
download | qt3-49075fd69d70b7850febe2fbc11f81d2d4e62cf1.tar.gz qt3-49075fd69d70b7850febe2fbc11f81d2d4e62cf1.zip |
Allow TQApplication objects to be constructed without a session manager
This relates to Bug 760
Diffstat (limited to 'src/kernel/qapplication.cpp')
-rw-r--r-- | src/kernel/qapplication.cpp | 73 |
1 files changed, 61 insertions, 12 deletions
diff --git a/src/kernel/qapplication.cpp b/src/kernel/qapplication.cpp index 959f850..2a89a90 100644 --- a/src/kernel/qapplication.cpp +++ b/src/kernel/qapplication.cpp @@ -793,10 +793,9 @@ void QApplication::process_cmdline( int* argcptr, char ** argv ) //######### BINARY COMPATIBILITY constructor QApplication::QApplication( 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 @@ QApplication::QApplication( int &argc, char **argv ) QApplication::QApplication( 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 Qt. + + 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 + QApplication app(argc, argv, useGUI); + + if ( useGUI ) { + //start GUI version + ... + } else { + //start non-GUI version + ... + } + return app.exec(); + } +\endcode +*/ + +QApplication::QApplication( int &argc, char **argv, bool GUIenabled, bool SMenabled ) +{ + construct( argc, argv, GUIenabled ? GuiClient : Tty, SMenabled ); } /*! @@ -851,7 +898,7 @@ QApplication::QApplication( int &argc, char **argv, bool GUIenabled ) */ QApplication::QApplication( int &argc, char **argv, Type type ) { - construct( argc, argv, type ); + construct( argc, argv, type, true ); } Q_EXPORT void qt_ucm_initialize( QApplication *theApp ) @@ -860,12 +907,12 @@ Q_EXPORT void qt_ucm_initialize( QApplication *theApp ) return; int argc = theApp->argc(); char **argv = theApp->argv(); - theApp->construct( argc, argv, qApp->type() ); + theApp->construct( argc, argv, qApp->type(), true ); Q_ASSERT( qApp == theApp ); } -void QApplication::construct( int &argc, char **argv, Type type ) +void QApplication::construct( int &argc, char **argv, Type type, bool enable_sm ) { qt_appType = type; qt_is_gui_used = (type != Tty); @@ -880,7 +927,7 @@ void QApplication::construct( int &argc, char **argv, Type type ) qt_init( &argc, argv, type ); // Must be called before initialize() process_cmdline( &argc, argv ); - initialize( argc, argv ); + initialize( argc, argv, enable_sm ); if ( qt_is_gui_used ) qt_maxWindowRect = desktop()->rect(); if ( currentEventLoop() ) @@ -1020,7 +1067,7 @@ void QApplication::init_precmdline() Initializes the QApplication object, called from the constructors. */ -void QApplication::initialize( int argc, char **argv ) +void QApplication::initialize( int argc, char **argv, bool enable_sm ) { #ifdef QT_THREAD_SUPPORT qt_mutex = new QMutex( TRUE ); @@ -1044,10 +1091,12 @@ void QApplication::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 QString; - session_manager = new QSessionManager( qApp, session_id, *session_key ); + if (enable_sm) { + // connect to the session manager + if ( !session_key ) + session_key = new QString; + session_manager = new QSessionManager( qApp, session_id, *session_key ); + } #endif } |