Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <signal.h>
00022 #include <QApplication>
00023 #include <QCoreApplication>
00024 #include <QTextCodec>
00025 #include <QTranslator>
00026 #include <QString>
00027 #include <QLocale>
00028 #include <QLibraryInfo>
00029 #include <QDebug>
00030 #include <iostream>
00031 #include <stdexcept>
00032 #include "MainWindow.h"
00033 #include "HelpViewer.h"
00034 #include "../transport/dashel_plugins/dashel-plugins.h"
00035
00036 using namespace std;
00037
00038 void usage(const char *execName)
00039 {
00040 cout << "Usage: " << execName << " (OPTIONS|TARGET)* " << endl;
00041 cout << " where" << endl;
00042 cout << "OPTION is one of:" << endl;
00043 cout << " -h this help" << endl;
00044 cout << " -ar auto memory refresh enabled by default" << endl;
00045 cout << " -doc show documentation instead of studio" << endl;
00046 cout << "TARGET is a Dashel target (the last one is always considered)" << endl;
00047 }
00048
00053 int main(int argc, char *argv[])
00054 {
00055 bool autoRefresh(false);
00056 bool showDoc(false);
00057 QApplication app(argc, argv);
00058 Dashel::initPlugins();
00059
00060
00061 QCoreApplication::setOrganizationName("EPFL-LSRO-Mobots");
00062 QCoreApplication::setOrganizationDomain("mobots.epfl.ch");
00063 QCoreApplication::setApplicationName("Aseba Studio");
00064
00065 QTextCodec::setCodecForTr(QTextCodec::codecForName("UTF-8"));
00066 QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));
00067
00068
00069 signal(SIGTERM, SIG_DFL);
00070 signal(SIGINT, SIG_DFL);
00071
00072 QString commandLineTarget;
00073 for (int i = 1; i < argc; ++i)
00074 {
00075 if (argv[i][0] != '-')
00076 {
00077 commandLineTarget = argv[i];
00078 break;
00079 }
00080 else if (argv[i][1] != 0)
00081 {
00082 QString cmd(&(argv[i][1]));
00083 if (cmd == "h")
00084 {
00085 usage(argv[0]);
00086 return 0;
00087 }
00088 else if (cmd == "ar")
00089 {
00090 autoRefresh = true;
00091 }
00092 else if (cmd == "doc")
00093 {
00094 showDoc = true;
00095 }
00096 }
00097 }
00098
00099
00100 QTranslator qtTranslator;
00101 app.installTranslator(&qtTranslator);
00102
00103 QTranslator translator;
00104 app.installTranslator(&translator);
00105
00106 QTranslator compilerTranslator;
00107 app.installTranslator(&compilerTranslator);
00108
00109 if (showDoc)
00110 {
00111
00112 Aseba::HelpViewer helpViewer;
00113 helpViewer.setLanguage(QLocale::system().name());
00114 helpViewer.show();
00115 return app.exec();
00116 }
00117 else
00118 {
00119
00120 try
00121 {
00122 QVector<QTranslator*> translators;
00123 translators.push_back(&qtTranslator);
00124 translators.push_back(&translator);
00125 translators.push_back(&compilerTranslator);
00126 Aseba::MainWindow window(translators, commandLineTarget, autoRefresh);
00127 window.show();
00128 return app.exec();
00129 }
00130 catch (std::runtime_error e)
00131 {
00132 std::cerr << "Program terminated with runtime error: " << e.what() << std::endl;
00133 return -1;
00134 }
00135 }
00136 }
00137
00138