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

kdeuniquecelestia.cpp

Go to the documentation of this file.
00001 /***************************************************************************
00002                           kdeuniquecelestia.cpp  -  description
00003                              -------------------
00004     begin                : Mon Aug 5 2002
00005     copyright            : (C) 2002 by chris
00006     email                : chris@tux.teyssier.org
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 #include "kdeuniquecelestia.h"
00018 #include <kcmdlineargs.h>
00019 #include <qfile.h>
00020 #include <qdir.h>
00021 #include <string>
00022 #include <vector>
00023 #include <klocale.h>
00024 
00025 KdeUniqueCelestia::KdeUniqueCelestia() {
00026 
00027     bindtextdomain(PACKAGE, LOCALEDIR);
00028     bind_textdomain_codeset(PACKAGE, "UTF-8");
00029     textdomain(PACKAGE);
00030 
00031     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00032     std::vector<std::string> validDirs;
00033     std::string config, dir;
00034     bool fullscreen = false;
00035 
00036     if (args->isSet("conf")) {
00037         if (QFile::exists(args->getOption("conf")))
00038             config = std::string((const char*)args->getOption("conf"));
00039         else
00040             std::cerr << i18n("File %1 does not exist, using default configuration file %2/celestia.cfg")
00041                     .arg(args->getOption("conf"))
00042                     .arg(CONFIG_DATA_DIR) << std::endl;
00043     }
00044 
00045     if (args->isSet("dir")) {
00046         QDir d(args->getOption("dir"));
00047         if (d.exists())
00048             dir = std::string((const char*)args->getOption("dir"));
00049         else 
00050             std::cerr << i18n("Directory %1 does not exist, using default %2")
00051                     .arg(args->getOption("dir"))
00052                     .arg(CONFIG_DATA_DIR)  << std::endl;
00053     }
00054 
00055     if (args->isSet("extrasdir")) {
00056         QCStringList dirs = args->getOptionList("extrasdir");
00057         for (QCStringList::Iterator i = dirs.begin(); i != dirs.end(); ++i) {
00058             QDir d(*i);
00059             if (d.exists()) 
00060                 validDirs.push_back(std::string((const char*)*i));
00061             else 
00062                 std::cerr << i18n("Extras directory %1 does not exist").arg(*i) << std::endl;
00063         }
00064     }
00065 
00066     if (args->isSet("fullscreen")) fullscreen = true;
00067 
00068     app = new KdeApp(config, dir, validDirs, fullscreen, !args->isSet("s"));
00069 
00070     if (args->count() != 0) {
00071         app->setStartURL(args->url(0));
00072     }
00073 
00074     setMainWidget(app);
00075     app->show();
00076     
00077 }
00078 
00079 int KdeUniqueCelestia::newInstance() {
00080     KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
00081     if (args->count() != 0) {
00082         app->goToURL(args->url(0));
00083         app->showNormal();
00084         app->setActiveWindow();
00085         app->raise();
00086     }
00087     return 0;
00088 }
00089 
00090 

Generated on Sat Jan 14 22:30:31 2006 for Celestia by  doxygen 1.4.1