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@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: static const char *description = joachim99@68: I18N_NOOP("Tool for Comparison and Merge of Files and Directories"); joachim99@8: joachim99@8: static KCmdLineOptions options[] = joachim99@8: { joachim99@8: { "m", 0, 0 }, joachim99@8: { "merge", I18N_NOOP("Merge the input."), 0 }, joachim99@8: { "b", 0, 0 }, joachim99@8: { "base file", I18N_NOOP("Explicit base file. For compatibility with certain tools."), 0 }, joachim99@8: { "o", 0, 0 }, joachim99@8: { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 }, joachim99@8: { "out file", I18N_NOOP("Output file, again. (For compatibility with certain tools.)"), 0 }, joachim99@8: { "auto", I18N_NOOP("No GUI if all conflicts are auto-solvable. (Needs -o file)"), 0 }, joachim99@8: { "qall", I18N_NOOP("Don't solve conflicts automatically. (For compatibility...)"), 0 }, joachim99@66: { "L1 alias1", I18N_NOOP("Visible name replacement for input file 1 (base)."), 0 }, joachim99@66: { "L2 alias2", I18N_NOOP("Visible name replacement for input file 2."), 0 }, joachim99@66: { "L3 alias3", I18N_NOOP("Visible name replacement for input file 3."), 0 }, joachim99@66: { "L", 0, 0 }, joachim99@66: { "fname alias", I18N_NOOP("Alternative visible name replacement. Supply this once for every input."), 0 }, joachim99@69: { "cs string", I18N_NOOP("Override a config setting. Use once for every setting. E.g.: --cs \"AutoAdvance=1\""), 0 }, joachim99@69: { "confighelp", I18N_NOOP("Show list of config settings and current values."), 0 }, joachim99@69: { "config file", I18N_NOOP("Use a different config file."), 0 } joachim99@69: }; joachim99@69: static KCmdLineOptions options2[] = joachim99@69: { joachim99@8: { "+[File1]", I18N_NOOP("file1 to open (base, if not specified via --base)"), 0 }, joachim99@8: { "+[File2]", I18N_NOOP("file2 to open"), 0 }, joachim99@69: { "+[File3]", I18N_NOOP("file3 to open"), 0 } joachim99@8: }; joachim99@8: joachim99@8: joachim99@69: void initialiseCmdLineArgs(std::vector& vOptions, QStringList& ignorableOptions) joachim99@69: { joachim99@69: vOptions.insert( vOptions.end(), options, (KCmdLineOptions*)((char*)options+sizeof(options))); joachim99@69: QString configFileName = KStandardDirs().findResource("config","kdiff3rc"); joachim99@69: QFile configFile( configFileName ); joachim99@70: if ( configFile.open( QIODevice::ReadOnly ) ) joachim99@69: { joachim99@69: QTextStream ts( &configFile ); joachim99@69: while(!ts.atEnd()) joachim99@69: { joachim99@69: QString line = ts.readLine(); joachim99@69: if ( line.startsWith("IgnorableCmdLineOptions=") ) joachim99@69: { joachim99@75: int pos = line.indexOf('='); joachim99@69: if (pos>=0) joachim99@69: { joachim99@69: QString s = line.mid(pos+1); joachim99@75: QStringList sl = s.split( '|' ); joachim99@69: if (!sl.isEmpty()) joachim99@69: { joachim99@75: ignorableOptions = sl.front().split( ';' ); joachim99@69: for (QStringList::iterator i=ignorableOptions.begin(); i!=ignorableOptions.end(); ++i) joachim99@69: { joachim99@69: KCmdLineOptions ignoreOption; joachim99@69: (*i).remove('-'); joachim99@69: if (!(*i).isEmpty()) joachim99@69: { joachim99@75: ignoreOption.name = (new QByteArray( (*i).toLatin1() ))->constData(); joachim99@69: ignoreOption.description = I18N_NOOP("Ignored. (User defined.)"); joachim99@69: ignoreOption.def = 0; joachim99@69: vOptions.push_back(ignoreOption); joachim99@69: } joachim99@69: } joachim99@69: } joachim99@69: } joachim99@69: break; joachim99@69: } joachim99@69: } joachim99@69: } joachim99@69: vOptions.insert(vOptions.end(),options2,(KCmdLineOptions*)((char*)options2+sizeof(options2))); joachim99@69: joachim99@69: KCmdLineOptions last = KCmdLineLastOption; joachim99@69: vOptions.push_back(last); joachim99@69: KCmdLineArgs::addCmdLineOptions( &vOptions[0] ); // Add our own options. joachim99@69: } joachim99@69: 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@69: QStringList ignorableOptions; joachim99@69: 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@53: QTranslator 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@8: if (app.isRestored()) joachim99@8: { joachim99@8: RESTORE(KDiff3Shell); joachim99@8: } joachim99@8: else joachim99@8: { joachim99@8: new KDiff3Shell(); joachim99@8: } joachim99@8: 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