From 76718abdb2138623102398a10f3228e576dd0ae8 Mon Sep 17 00:00:00 2001 From: tpearson Date: Wed, 10 Feb 2010 01:27:27 +0000 Subject: Added abandoned KDE3 version of kdiff3 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kdiff3@1088041 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- src/main.cpp | 236 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 236 insertions(+) create mode 100644 src/main.cpp (limited to 'src/main.cpp') diff --git a/src/main.cpp b/src/main.cpp new file mode 100644 index 0000000..6e19b58 --- /dev/null +++ b/src/main.cpp @@ -0,0 +1,236 @@ +/*************************************************************************** + main.cpp - Where everything starts. + ------------------- + begin : Don Jul 11 12:31:29 CEST 2002 + copyright : (C) 2002-2007 by Joachim Eibl + email : joachim.eibl at gmx.de + ***************************************************************************/ + +/*************************************************************************** + * * + * This program is free software; you can redistribute it and/or modify * + * it under the terms of the GNU General Public License as published by * + * the Free Software Foundation; either version 2 of the License, or * + * (at your option) any later version. * + * * + ***************************************************************************/ + +#include +#include +#include +#include "kdiff3_shell.h" +#include +#include "version.h" +#include +#include +#include +#include + +#ifdef KREPLACEMENTS_H +#include "optiondialog.h" +#endif +#include "common.h" + +static const char *description = + I18N_NOOP("Tool for Comparison and Merge of Files and Directories"); + +static KCmdLineOptions options[] = +{ + { "m", 0, 0 }, + { "merge", I18N_NOOP("Merge the input."), 0 }, + { "b", 0, 0 }, + { "base file", I18N_NOOP("Explicit base file. For compatibility with certain tools."), 0 }, + { "o", 0, 0 }, + { "output file", I18N_NOOP("Output file. Implies -m. E.g.: -o newfile.txt"), 0 }, + { "out file", I18N_NOOP("Output file, again. (For compatibility with certain tools.)"), 0 }, + { "auto", I18N_NOOP("No GUI if all conflicts are auto-solvable. (Needs -o file)"), 0 }, + { "qall", I18N_NOOP("Don't solve conflicts automatically. (For compatibility...)"), 0 }, + { "L1 alias1", I18N_NOOP("Visible name replacement for input file 1 (base)."), 0 }, + { "L2 alias2", I18N_NOOP("Visible name replacement for input file 2."), 0 }, + { "L3 alias3", I18N_NOOP("Visible name replacement for input file 3."), 0 }, + { "L", 0, 0 }, + { "fname alias", I18N_NOOP("Alternative visible name replacement. Supply this once for every input."), 0 }, + { "cs string", I18N_NOOP("Override a config setting. Use once for every setting. E.g.: --cs \"AutoAdvance=1\""), 0 }, + { "confighelp", I18N_NOOP("Show list of config settings and current values."), 0 }, + { "config file", I18N_NOOP("Use a different config file."), 0 } +}; +static KCmdLineOptions options2[] = +{ + { "+[File1]", I18N_NOOP("file1 to open (base, if not specified via --base)"), 0 }, + { "+[File2]", I18N_NOOP("file2 to open"), 0 }, + { "+[File3]", I18N_NOOP("file3 to open"), 0 } +}; + + +void initialiseCmdLineArgs(std::vector& vOptions, QStringList& ignorableOptions) +{ + vOptions.insert( vOptions.end(), options, (KCmdLineOptions*)((char*)options+sizeof(options))); + QString configFileName = KStandardDirs().findResource("config","kdiff3rc"); + QFile configFile( configFileName ); + if ( configFile.open( IO_ReadOnly ) ) + { + QTextStream ts( &configFile ); + while(!ts.atEnd()) + { + QString line = ts.readLine(); + if ( line.startsWith("IgnorableCmdLineOptions=") ) + { + int pos = line.find('='); + if (pos>=0) + { + QString s = line.mid(pos+1); + QStringList sl = QStringList::split( '|', s ); + if (!sl.isEmpty()) + { + ignorableOptions = QStringList::split( ';', sl.front() ); + for (QStringList::iterator i=ignorableOptions.begin(); i!=ignorableOptions.end(); ++i) + { + KCmdLineOptions ignoreOption; + (*i).remove('-'); + if (!(*i).isEmpty()) + { + ignoreOption.name = (*i).latin1(); + ignoreOption.description = I18N_NOOP("Ignored. (User defined.)"); + ignoreOption.def = 0; + vOptions.push_back(ignoreOption); + } + } + } + } + break; + } + } + } + vOptions.insert(vOptions.end(),options2,(KCmdLineOptions*)((char*)options2+sizeof(options2))); + + KCmdLineOptions last = KCmdLineLastOption; + vOptions.push_back(last); + KCmdLineArgs::addCmdLineOptions( &vOptions[0] ); // Add our own options. +} + + +#ifdef _WIN32 +#include +// This command checks the comm +static bool isOptionUsed(const QString& s, int argc, char* argv[]) +{ + for(int j=0; j vOptions; + QStringList ignorableOptions; + initialiseCmdLineArgs(vOptions, ignorableOptions); + + KApplication app; + +#ifdef KREPLACEMENTS_H + QString locale; + + locale = app.config()->readEntry("Language", "Auto"); + int spacePos = locale.find(' '); + if (spacePos>0) locale = locale.left(spacePos); + QTranslator kdiff3Translator( 0 ); + QTranslator qtTranslator( 0 ); + if (locale != "en_orig") + { + if ( locale == "Auto" || locale.isEmpty() ) + locale = QTextCodec::locale(); + + QString translationDir = getTranslationDir(); + kdiff3Translator.load( QString("kdiff3_")+locale, translationDir ); + app.installTranslator( &kdiff3Translator ); + + qtTranslator.load( QString("qt_")+locale, translationDir ); + app.installTranslator( &qtTranslator ); + } +#endif + + if (app.isRestored()) + { + RESTORE(KDiff3Shell); + } + else + { + new KDiff3Shell(); + } + + int retVal = app.exec(); + return retVal; +} + +// Suppress warning with --enable-final +#undef VERSION -- cgit v1.2.1