File indexing completed on 2024-04-28 17:00:48
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2009 by Rajko Albrecht * 0003 * ral@alwins-world.de * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * 0019 ***************************************************************************/ 0020 0021 #include "kdesvn.h" 0022 #include "commandline.h" 0023 #include "kdesvn-config.h" 0024 #include <QApplication> 0025 #include <KAboutData> 0026 0027 #include <QCommandLineParser> 0028 #include <QDir> 0029 #include <klocalizedstring.h> 0030 0031 static const char description[] = 0032 I18N_NOOP("A Subversion Client by KDE (standalone application)"); 0033 0034 int main(int argc, char **argv) 0035 { 0036 QApplication app(argc, argv); 0037 KLocalizedString::setApplicationDomain("kdesvn"); 0038 app.setApplicationName(QStringLiteral("kdesvn")); 0039 app.setApplicationDisplayName(QStringLiteral("kdesvn")); 0040 app.setOrganizationDomain(QStringLiteral("kde.org")); 0041 app.setApplicationVersion(QStringLiteral(KDESVN_VERSION)); 0042 app.setWindowIcon(QIcon::fromTheme(QStringLiteral("kdesvn"), app.windowIcon())); 0043 0044 KAboutData aboutData(QStringLiteral("kdesvn"), i18n("kdesvn"), QStringLiteral(KDESVN_VERSION), i18n(description), 0045 KAboutLicense::GPL, i18n("(C) 2005-2009 Rajko Albrecht,\n(C) 2015-2019 Christian Ehrlicher")); 0046 aboutData.addAuthor(i18n("Rajko Albrecht"), i18n("Developer"), QStringLiteral("ral@alwins-world.de")); 0047 aboutData.addAuthor(i18n("Christian Ehrlicher"), i18n("Developer"), QStringLiteral("ch.ehrlicher@gmx.de")); 0048 aboutData.setHomepage(QStringLiteral("https://commits.kde.org/kdesvn")); 0049 KAboutData::setApplicationData(aboutData); 0050 0051 QCommandLineParser parser; 0052 parser.addVersionOption(); 0053 parser.addHelpOption(); 0054 parser.addOption({QStringLiteral("r"), i18n("Execute single Subversion command on specific revision(-range)"), i18n("startrev[:endrev]")}); 0055 parser.addOption({QStringLiteral("R"), i18n("Ask for revision when executing single command")}); 0056 parser.addOption({QStringLiteral("f"), i18n("Force operation")}); 0057 parser.addOption({QStringLiteral("o"), i18n("Save output of Subversion command (eg \"cat\") into file <file>"), i18n("<file>")}); 0058 parser.addOption({QStringLiteral("l"), i18n("Limit log output to <number>"), i18n("<number>")}); 0059 parser.addPositionalArgument(QStringLiteral("+exec <command>"), i18n("Execute Subversion command (\"exec help\" for more information)")); 0060 parser.addPositionalArgument(QStringLiteral("+[URL]"), i18n("Document to open")); 0061 aboutData.setupCommandLine(&parser); 0062 parser.process(app); 0063 aboutData.processCommandLine(&parser); 0064 0065 // see if we are starting with session management 0066 if (app.isSessionRestored()) { 0067 RESTORE(kdesvn); 0068 } else { 0069 // no session.. just start up normally 0070 if (parser.positionalArguments().isEmpty()) { 0071 kdesvn *widget = new kdesvn; 0072 widget->show(); 0073 widget->checkReload(); 0074 } else { 0075 if (parser.positionalArguments().at(0) == QLatin1String("exec")) { 0076 CommandLine cl(&parser); 0077 return cl.exec(); 0078 } else { 0079 int i = 0; 0080 for (; i < parser.positionalArguments().count(); i++) { 0081 kdesvn *widget = new kdesvn; 0082 widget->show(); 0083 widget->load(QUrl::fromUserInput(parser.positionalArguments().at(i), 0084 QDir::currentPath()), true); 0085 } 0086 } 0087 } 0088 } 0089 return app.exec(); 0090 }