Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

main.cpp

Go to the documentation of this file.
00001 /* OPIE */
00002 #include <oappinterface.h>
00003 #include <oappplugin.h>
00004 #include <opie2/odebug.h>
00005 #include <opie2/otabwidget.h>
00006 #include <qpe/qpeapplication.h>
00007 #include <qpe/qlibrary.h>
00008 using namespace Opie::Core;
00009 using namespace Opie::Ui;
00010 
00011 /* QT */
00012 #include <qdir.h>
00013 
00014 int main( int argc, char **argv )
00015 {
00016     QPEApplication a( argc, argv );
00017 
00018     OTabWidget *tabwidget = new OTabWidget(0, "tab widget");
00019 
00020     QString path = QPEApplication::qpeDir() + "plugins/app";
00021     QDir dir( path, "lib*.so" );
00022 
00023     QStringList list = dir.entryList();
00024     QStringList::Iterator it;
00025 
00026     QInterfacePtr<OAppInterface> iface;
00027     for ( it = list.begin(); it != list.end(); ++it ) {
00028         QLibrary *lib = new QLibrary( path + "/" + *it );
00029 
00030     odebug << "querying: " << QString( path + "/" + *it ) << "" << oendl;
00031         if ( lib->queryInterface( IID_OAppInterface, (QUnknownInterface**)&iface ) == QS_OK ) {
00032         odebug << "accepted: " << QString( path + "/" + *it ) << "" << oendl;
00033 
00034         QList<QWidget> list = iface->widgets();
00035             QWidget *widget;
00036             for ( widget = list.first(); widget != 0; widget = list.next() )
00037                 tabwidget->addTab(widget, QString(*it), QString(*it));
00038 
00039             QString lang = getenv( "LANG" );
00040         if (lang.isNull())
00041         lang = "en";
00042         QTranslator *trans = new QTranslator(qApp);
00043         QString type = (*it).left( (*it).find(".") );
00044         if (type.left(3) == "lib")
00045          type = type.mid(3);
00046         type = type.right( type.find("lib") );
00047         QString tfn = QPEApplication::qpeDir()+"i18n/"+lang+"/"+type+".qm";
00048         if ( trans->load( tfn ))
00049         qApp->installTranslator( trans );
00050         else
00051         delete trans;
00052     }
00053     }
00054 
00055     a.showMainDocumentWidget(tabwidget);
00056     return a.exec();
00057 }

Generated on Sat Nov 5 16:15:25 2005 for OPIE by  doxygen 1.4.2