00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
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