00001 #include "gui.h"
00002 #include "modules.h"
00003
00004 using namespace std;
00005
00007 int batchRun(const vector<const char*> &fileNames);
00008
00009
00010 struct TestOpt: public unary_function<const char*,bool> {
00011 bool operator()(const char *str) const
00012 { return *str=='-'; }
00013 };
00014
00015 void autoTranslation(QCoreApplication &app,QTranslator &trans) {
00016 if ( trans.load("lang-"+QLocale::system().name(),app.applicationDirPath()) )
00017 app.installTranslator(&trans);
00018 }
00019
00020
00021 int main(int argc,char **argv) {
00022 int result;
00023 ModuleFactory::init();
00024
00025 QTranslator trans;
00026
00027 vector<const char*> fileNames;
00028 remove_copy_if( argv+1, argv+argc, back_inserter(fileNames), TestOpt() );
00029
00030 if ( fileNames.empty() ) {
00031 QApplication app(argc,argv);
00032 autoTranslation(app,trans);
00033 {
00034 ImageViewer viewer(app,trans);
00035 viewer.show();
00036 result= app.exec();
00037 }
00038 } else {
00039 QCoreApplication app(argc,argv);
00040 autoTranslation(app,trans);
00041 result= batchRun(fileNames);
00042 }
00043
00044 ModuleFactory::destroy();
00045 return result;
00046 }