joachim99@8: /*************************************************************************** joachim99@8: main.cpp - Where everything starts. joachim99@8: ------------------- joachim99@8: begin : Don Jul 11 12:31:29 CEST 2002 joachim99@77: copyright : (C) 2002-2007 by Joachim Eibl joachim99@69: email : joachim.eibl at gmx.de joachim99@8: ***************************************************************************/ joachim99@8: joachim99@8: /*************************************************************************** joachim99@8: * * joachim99@8: * This program is free software; you can redistribute it and/or modify * joachim99@8: * it under the terms of the GNU General Public License as published by * joachim99@8: * the Free Software Foundation; either version 2 of the License, or * joachim99@8: * (at your option) any later version. * joachim99@8: * * joachim99@8: ***************************************************************************/ joachim99@8: joachim99@8: #include joachim99@8: #include joachim99@8: #include joachim99@40: #include "kdiff3_shell.h" joachim99@69: #include friseb123@16: #include "version.h" joachim99@53: #include joachim99@69: #include joachim99@69: #include joachim99@70: #include joachim99@75: #include joachim99@80: #include joachim99@69: #include joachim99@8: joachim99@66: #ifdef KREPLACEMENTS_H joachim99@66: #include "optiondialog.h" joachim99@66: #endif joachim99@69: #include "common.h" joachim99@8: joachim99@8: joachim99@80: // static KCmdLineOptions options[] = joachim99@80: // { joachim99@80: // { "m", 0, 0 }, joachim99@80: // { "merge", I18N_NOOP("Merge the input."), 0 }, joachim99@80: // { "b", 0, 0 }, joachim99@80: // { "base file", I18N_NOOP("Explicit base file. For compatibility with certain tools."), 0 }, joachim99@80: // { "o", 0, 0 }, joachim99@80: // { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 }, joachim99@80: // { "out file", I18N_NOOP("Output file, again. (For compatibility with certain tools.)"), 0 }, joachim99@80: // { "auto", I18N_NOOP("No GUI if all conflicts are auto-solvable. (Needs -o file)"), 0 }, joachim99@80: // { "qall", I18N_NOOP("Don't solve conflicts automatically. (For compatibility...)"), 0 }, joachim99@80: // { "L1 alias1", I18N_NOOP("Visible name replacement for input file 1 (base)."), 0 }, joachim99@80: // { "L2 alias2", I18N_NOOP("Visible name replacement for input file 2."), 0 }, joachim99@80: // { "L3 alias3", I18N_NOOP("Visible name replacement for input file 3."), 0 }, joachim99@80: // { "L", 0, 0 }, joachim99@80: // { "fname alias", I18N_NOOP("Alternative visible name replacement. Supply this once for every input."), 0 }, joachim99@80: // { "cs string", I18N_NOOP("Override a config setting. Use once for every setting. E.g.: --cs \"AutoAdvance=1\""), 0 }, joachim99@80: // { "confighelp", I18N_NOOP("Show list of config settings and current values."), 0 }, joachim99@80: // { "config file", I18N_NOOP("Use a different config file."), 0 } joachim99@80: // }; joachim99@80: // static KCmdLineOptions options2[] = joachim99@80: // { joachim99@80: // { "+[File1]", I18N_NOOP("file1 to open (base, if not specified via --base)"), 0 }, joachim99@80: // { "+[File2]", I18N_NOOP("file2 to open"), 0 }, joachim99@80: // { "+[File3]", I18N_NOOP("file3 to open"), 0 } joachim99@80: // }; joachim99@80: // joachim99@8: joachim99@80: // void initialiseCmdLineArgs(std::vector& vOptions, QStringList& ignorableOptions) joachim99@80: // { joachim99@80: // vOptions.insert( vOptions.end(), options, (KCmdLineOptions*)((char*)options+sizeof(options))); joachim99@80: // QString configFileName = KStandardDirs().findResource("config","kdiff3rc"); joachim99@80: // QFile configFile( configFileName ); joachim99@80: // if ( configFile.open( QIODevice::ReadOnly ) ) joachim99@80: // { joachim99@80: // QTextStream ts( &configFile ); joachim99@80: // while(!ts.atEnd()) joachim99@80: // { joachim99@80: // QString line = ts.readLine(); joachim99@80: // if ( line.startsWith("IgnorableCmdLineOptions=") ) joachim99@80: // { joachim99@80: // int pos = line.indexOf('='); joachim99@80: // if (pos>=0) joachim99@80: // { joachim99@80: // QString s = line.mid(pos+1); joachim99@80: // QStringList sl = s.split( '|' ); joachim99@80: // if (!sl.isEmpty()) joachim99@80: // { joachim99@80: // ignorableOptions = sl.front().split( ';' ); joachim99@80: // for (QStringList::iterator i=ignorableOptions.begin(); i!=ignorableOptions.end(); ++i) joachim99@80: // { joachim99@80: // KCmdLineOptions ignoreOption; joachim99@80: // (*i).remove('-'); joachim99@80: // if (!(*i).isEmpty()) joachim99@80: // { joachim99@80: // ignoreOption.name = (new QByteArray( (*i).toLatin1() ))->constData(); joachim99@80: // ignoreOption.description = I18N_NOOP("Ignored. (User defined.)"); joachim99@80: // ignoreOption.def = 0; joachim99@80: // vOptions.push_back(ignoreOption); joachim99@80: // } joachim99@80: // } joachim99@80: // } joachim99@80: // } joachim99@80: // break; joachim99@80: // } joachim99@80: // } joachim99@80: // } joachim99@80: // vOptions.insert(vOptions.end(),options2,(KCmdLineOptions*)((char*)options2+sizeof(options2))); joachim99@80: // joachim99@80: // KCmdLineOptions last = KCmdLineLastOption; joachim99@80: // vOptions.push_back(last); joachim99@80: // KCmdLineArgs::addCmdLineOptions( &vOptions[0] ); // Add our own options. joachim99@80: // } joachim99@69: joachim99@8: #ifdef _WIN32 joachim99@8: #include joachim99@8: // This command checks the comm joachim99@8: static bool isOptionUsed(const QString& s, int argc, char* argv[]) joachim99@8: { joachim99@8: for(int j=0; j vOptions; joachim99@80: // QStringList ignorableOptions; joachim99@80: // initialiseCmdLineArgs(vOptions, ignorableOptions); joachim99@8: joachim99@53: KApplication app; joachim99@69: joachim99@53: #ifdef KREPLACEMENTS_H joachim99@66: QString locale; joachim99@69: joachim99@66: locale = app.config()->readEntry("Language", "Auto"); joachim99@75: int spacePos = locale.indexOf(' '); joachim99@66: if (spacePos>0) locale = locale.left(spacePos); joachim99@80: ContextFreeTranslator kdiff3Translator( 0 ); joachim99@53: QTranslator qtTranslator( 0 ); joachim99@66: if (locale != "en_orig") joachim99@66: { joachim99@66: if ( locale == "Auto" || locale.isEmpty() ) joachim99@75: locale = locale = QLocale::system().name().left(2); joachim99@66: joachim99@66: QString translationDir = getTranslationDir(); joachim99@66: kdiff3Translator.load( QString("kdiff3_")+locale, translationDir ); joachim99@66: app.installTranslator( &kdiff3Translator ); joachim99@66: joachim99@66: qtTranslator.load( QString("qt_")+locale, translationDir ); joachim99@66: app.installTranslator( &qtTranslator ); joachim99@66: } joachim99@53: #endif joachim99@8: joachim99@80: if (app.isSessionRestored()) joachim99@8: { joachim99@8: RESTORE(KDiff3Shell); joachim99@8: } joachim99@8: else joachim99@8: { joachim99@80: KDiff3Shell* p = new KDiff3Shell(); joachim99@80: p->show(); joachim99@8: } joachim99@80: //app.installEventFilter( new CFilter ); joachim99@69: int retVal = app.exec(); joachim99@69: return retVal; joachim99@8: } joachim99@53: joachim99@53: // Suppress warning with --enable-final joachim99@53: #undef VERSION