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

main.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2003 Hans Karlsson <karlsson.h@home.se>
00003  */
00004 
00005 
00006 #include <kapplication.h>
00007 #include <kfiledialog.h>
00008 #include <kaboutdata.h>
00009 #include <kcmdlineargs.h>
00010 #include <klocale.h>
00011 #include <kconfig.h>
00012 #include <ksimpleconfig.h>
00013 #include <kstandarddirs.h>
00014 
00015 #include <qurl.h>
00016 #include <qfileinfo.h>
00017 #include <qstringlist.h>
00018 
00019 #include "karamba.h"
00020 #include "karambaconf.h"
00021 #include <kconfigdialog.h>
00022 
00023 
00024 static const char *description = I18N_NOOP("A KDE Eye-candy Application");
00025 
00026 static const char *version = "0.23";
00027 
00028 static KCmdLineOptions options[] ={{ "s", 0, 0 },{ "setup", I18N_NOOP("Configure KarambaR."), 0 },{ "+file", I18N_NOOP("Theme to open."), 0 },{ 0, 0, 0 }};
00029 
00030 int main(int argc, char **argv){
00031     KAboutData about("karamba", I18N_NOOP("karamba"), version, description,
00032     KAboutData::License_GPL, "(C) 2003 Hans Karlsson", 0, 0, "karlsson.h@home.se");
00033     about.addAuthor( "Hans Karlsson", 0, "karlsson.h@home.se" );
00034     about.addAuthor( "Bosselut Cyril",I18N_NOOP("Karamba Replica") , "bosselut@b1project.com" );
00035     about.setTranslator(I18N_NOOP("INSERT YOUR NAME HERE"),I18N_NOOP("INSERT YOUR EMAIL ADDRESS"));
00036     KCmdLineArgs::init(argc, argv, &about);
00037     KCmdLineArgs::addCmdLineOptions( options );
00038 
00039     KApplication app;
00040     karamba *mainWin = 0;
00041 
00042     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00043 
00044     KSimpleConfig conf("karambarc",true);
00045     conf.setGroup("karamba");
00046     QString dDir =  conf.readEntry("ThemeDir", locateLocal("data", "karamba/themes/"));
00047     QString dTheme =  conf.readEntry("DefaultTheme", "");
00048     if(args->isSet("setup")){
00049       KarambaConf *kc = 0;
00050       kc = new KarambaConf(0, "karconf", false, 0);
00051       kc->exec();
00052     }
00053     else{
00054       bool OK = false;
00055       if(args->count() > 0){
00056           for (int i = 0; i < (args->count()); i++){
00057               if( args->arg(i) != "" ){
00058                   QFileInfo file( args->arg(i) );
00059                   if( file.exists() && !file.isDir() ){
00060                       mainWin = new karamba( 0, ( args->arg(i) ) );
00061                       OK = true;
00062                   }
00063               }
00064           }
00065 
00066           int ret = 0;
00067           if( OK )
00068               ret = app.exec();
00069           return ret;
00070       }
00071       else if(dTheme != ""){
00072         QUrl url(dTheme); //make QUrl from QString
00073         QString dir = url.dirPath (); //resolve the absolute path
00074         QString fn = (dir == ".")?dDir + "/" + dTheme:dTheme; //verify if the theme is in default dir
00075         QFileInfo file( fn );
00076         if( file.exists() && !file.isDir() ){ //verify if theme exist
00077           mainWin = new karamba( 0, fn );
00078           OK = true;
00079         }
00080         int ret = 0;
00081         if( OK ){
00082             ret = app.exec();
00083         }
00084         return ret;
00085       }
00086       else{
00087           QStringList fileNames;
00088           fileNames = KFileDialog::getOpenFileNames(dDir, "*.theme", 0, "Open configurations");
00089           for ( QStringList::Iterator it = fileNames.begin(); it != fileNames.end(); ++it ){
00090               QFileInfo file( *it );
00091               if( file.exists() && !file.isDir() ){
00092                   mainWin = new karamba( 0, *it );
00093                   OK = true;
00094               }
00095           }
00096           int ret = 0;
00097           if( OK ){
00098               ret = app.exec();
00099           }
00100           return ret;
00101       }
00102     }
00103     args->clear();
00104     return 0;
00105 
00106 }

Generated on Mon May 16 13:59:20 2005 for karamba by  doxygen 1.3.9.1