diff options
author | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
---|---|---|
committer | Timothy Pearson <kb9vqf@pearsoncomputing.net> | 2011-11-08 12:31:36 -0600 |
commit | d796c9dd933ab96ec83b9a634feedd5d32e1ba3f (patch) | |
tree | 6e3dcca4f77e20ec8966c666aac7c35bd4704053 /src/inputmethod/qinputcontextfactory.cpp | |
download | tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.tar.gz tqt3-d796c9dd933ab96ec83b9a634feedd5d32e1ba3f.zip |
Test conversion to TQt3 from Qt3 8c6fc1f8e35fd264dd01c582ca5e7549b32ab731
Diffstat (limited to 'src/inputmethod/qinputcontextfactory.cpp')
-rw-r--r-- | src/inputmethod/qinputcontextfactory.cpp | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/src/inputmethod/qinputcontextfactory.cpp b/src/inputmethod/qinputcontextfactory.cpp new file mode 100644 index 000000000..a1ac4f35d --- /dev/null +++ b/src/inputmethod/qinputcontextfactory.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** +** $Id: qinputcontextfactory.cpp,v 1.2 2004/06/20 18:43:11 daisuke Exp $ +** +** Implementation of TQInputContextFactory class +** +** Created : 001103 +** +** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. +** +** This file is part of the widgets module of the TQt GUI Toolkit. +** +** This file may be distributed under the terms of the Q Public License +** as defined by Trolltech AS of Norway and appearing in the file +** LICENSE.TQPL included in the packaging of this file. +** +** This file may be distributed and/or modified under the terms of the +** GNU General Public License version 2 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. +** +** Licensees holding valid TQt Enterprise Edition licenses may use this +** file in accordance with the TQt Commercial License Agreement provided +** with the Software. +** +** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE +** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. +** +** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for +** information about TQt Commercial License Agreements. +** See http://www.trolltech.com/qpl/ for TQPL licensing information. +** See http://www.trolltech.com/gpl/ for GPL licensing information. +** +** Contact info@trolltech.com if any conditions of this licensing are +** not clear to you. +** +**********************************************************************/ + +#include "qinputcontextinterface_p.h" // up here for GCC 2.7.* compatibility +#include "qinputcontextfactory.h" +#include "qinputcontext.h" + +#ifndef QT_NO_IM + +#include "qapplication.h" + +#ifdef QT_THREAD_SUPPORT +#include <private/qmutexpool_p.h> +#endif // QT_THREAD_SUPPORT + +#include <stdlib.h> + +#include "qcleanuphandler.h" +#include <private/qpluginmanager_p.h> +#ifndef QT_NO_COMPONENT + + +static TQPluginManager<TQInputContextFactoryInterface> *manager = 0; +static TQSingleCleanupHandler< TQPluginManager<TQInputContextFactoryInterface> > cleanup_manager; + +static void create_manager() +{ + if( manager ) // already created + return; + +#ifdef QT_THREAD_SUPPORT + // protect manager creation + TQMutexLocker locker( qt_global_mutexpool ? + qt_global_mutexpool->get( &manager ) : 0); + + // we check the manager pointer again to make sure that another thread + // has not created the manager before us. + + if ( manager ) // already created + return; +#endif + + manager = new TQPluginManager<TQInputContextFactoryInterface>( IID_QInputContextFactory, TQApplication::libraryPaths(), "/inputmethods", FALSE ); + + Q_CHECK_PTR( manager ); + cleanup_manager.set( &manager ); +} + +#endif //QT_NO_COMPONENT + + +/*! + This function generates the input context that has the identifier + name which is in agreement with \a key. \a widget is the client + widget of TQInputContext. \a widget may be null. +*/ +TQInputContext *TQInputContextFactory::create( const TQString& key, TQWidget *widget ) +{ + TQInputContext *ret = 0; + TQString inputcontext = key; +#ifndef QT_NO_COMPONENT + // make sure the manager is created + create_manager(); + + TQInterfacePtr<TQInputContextFactoryInterface> iface; + manager->queryInterface( inputcontext, &iface ); + + if ( iface ) { + ret = iface->create( inputcontext ); +#ifdef Q_WS_X11 + if ( ret ) + ret->setHolderWidget( widget ); +#endif + } +#endif + return ret; +} + + +/*! + This function returns the list of the names input methods. + Only input methods included in default and placed under + $QTDIR/plugins/inputmethods are listed. +*/ +TQStringList TQInputContextFactory::keys() +{ + TQStringList list; +#ifndef QT_NO_COMPONENT + // make sure the manager is created + create_manager(); + + list = manager->featureList(); +#endif //QT_NO_COMPONENT + + return list; +} + + +TQStringList TQInputContextFactory::languages( const TQString &key ) +{ + TQStringList result; +#ifndef QT_NO_COMPONENT + // make sure the manager is created + create_manager(); + + TQInterfacePtr<TQInputContextFactoryInterface> iface; + manager->queryInterface( key, &iface ); + + if ( iface ) + result = iface->languages( key ); +#endif //QT_NO_COMPONENT + + return result; +} + + +TQString TQInputContextFactory::displayName( const TQString &key ) +{ + TQString result( "" ); +#ifndef QT_NO_COMPONENT + // make sure the manager is created + create_manager(); + + TQInterfacePtr<TQInputContextFactoryInterface> iface; + manager->queryInterface( key, &iface ); + + if ( iface ) + result = iface->displayName( key ); +#endif //QT_NO_COMPONENT + + return result; +} + + +TQString TQInputContextFactory::description( const TQString &key ) +{ + TQString result( "" ); +#ifndef QT_NO_COMPONENT + // make sure the manager is created + create_manager(); + + TQInterfacePtr<TQInputContextFactoryInterface> iface; + manager->queryInterface( key, &iface ); + + if ( iface ) + result = iface->description( key ); +#endif //QT_NO_COMPONENT + + return result; +} + +#endif // QT_NO_IM |