Exemplo n.º 1
0
extern "C" KDE_EXPORT int kdemain(int argc, char **argv)
{
    KAboutData about("cervisia", 0, ki18n("Cervisia"), CERVISIA_VERSION,
                     ki18n("A CVS frontend"), KAboutData::License_GPL,
                     ki18n("Copyright (c) 1999-2002 Bernd Gehrmann\n"
                           "Copyright (c) 2002-2008 the Cervisia authors"), KLocalizedString(),
                     "http://cervisia.kde.org");

    about.addAuthor(ki18n("Bernd Gehrmann"), ki18n("Original author and former "
                    "maintainer"), "*****@*****.**");
    about.addAuthor(ki18n("Christian Loose"), ki18n("Maintainer"),
                    "*****@*****.**");
    about.addAuthor(ki18n("Andr\303\251 W\303\266bbeking"), ki18n("Developer"),
                    "*****@*****.**");
    about.addAuthor(ki18n("Carlos Woelz"), ki18n("Documentation"),
                    "*****@*****.**");

    about.addCredit(ki18n("Richard Moore"), ki18n("Conversion to KPart"),
                    "*****@*****.**");
    about.addCredit(ki18n("Laurent Montel"), ki18n("Conversion to D-Bus"),
                    "*****@*****.**");

    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("+[directory]", ki18n("The sandbox to be loaded"));
    options.add("resolve <file>", ki18n("Show resolve dialog for the given file"));
    options.add("log <file>", ki18n("Show log dialog for the given file"));
    options.add("annotate <file>", ki18n("Show annotation dialog for the given file"));
    KCmdLineArgs::addCmdLineOptions(options);

    KApplication app;

    QString resolvefile = KCmdLineArgs::parsedArgs()->getOption("resolve");
    if (!resolvefile.isEmpty())
        return ShowResolveDialog(resolvefile);

    // is command line option 'show log dialog' specified?
    QString logFile = KCmdLineArgs::parsedArgs()->getOption("log");
    if( !logFile.isEmpty() )
        return ShowLogDialog(logFile);

    // is command line option 'show annotation dialog' specified?
    QString annotateFile = KCmdLineArgs::parsedArgs()->getOption("annotate");
    if( !annotateFile.isEmpty() )
        return ShowAnnotateDialog(annotateFile);

    if ( app.isSessionRestored() ) {
        RESTORE(CervisiaShell);
    } else {
        CervisiaShell* shell = new CervisiaShell();

        const KCmdLineArgs* args = KCmdLineArgs::parsedArgs();
        if( args->count() )
        {
            KUrl directory = args->url(0);
            shell->openURL(directory);
        }
        else
            shell->openURL();

        shell->setWindowIcon(qApp->windowIcon());
        shell->show();
    }

    int res = app.exec();
    cleanupTempFiles();
    return res;
}
Exemplo n.º 2
0
extern "C" Q_DECL_EXPORT int kdemain(int argc, char **argv)
{
    KLocalizedString::setApplicationDomain("cervisia");

    QApplication app(argc, argv);

    KAboutData about("cervisia", i18n("Cervisia"), CERVISIA_VERSION,
                     i18n("A CVS frontend"), KAboutLicense::GPL,
                     i18n("Copyright (c) 1999-2002 Bernd Gehrmann\n"
                          "Copyright (c) 2002-2008 the Cervisia authors"), QString(),
                     QLatin1String("http://cervisia.kde.org"));

    about.addAuthor(i18n("Bernd Gehrmann"), i18n("Original author and former "
                    "maintainer"), "*****@*****.**");
    about.addAuthor(i18n("Christian Loose"), i18n("Maintainer"),
                    "*****@*****.**");
    about.addAuthor(i18n("Andr\303\251 W\303\266bbeking"), i18n("Developer"),
                    "*****@*****.**");
    about.addAuthor(i18n("Carlos Woelz"), i18n("Documentation"),
                    "*****@*****.**");

    about.addCredit(i18n("Richard Moore"), i18n("Conversion to KPart"),
                    "*****@*****.**");
    about.addCredit(i18n("Laurent Montel"), i18n("Conversion to D-Bus"),
                    "*****@*****.**");
    about.addCredit(i18n("Martin Koller"), i18n("Port to KDE Frameworks 5"),
                    "*****@*****.**");

    KAboutData::setApplicationData(about);

    QCommandLineParser parser;
    about.setupCommandLine(&parser);

    parser.addPositionalArgument(QLatin1String("directory"), i18n("The sandbox to be loaded"), QLatin1String("[directory]"));
    parser.addOption(QCommandLineOption(QLatin1String("resolve"), i18n("Show resolve dialog for the given file."), QLatin1String("file")));
    parser.addOption(QCommandLineOption(QLatin1String("log"), i18n("Show log dialog for the given file."), QLatin1String("file")));
    parser.addOption(QCommandLineOption(QLatin1String("annotate"), i18n("Show annotation dialog for the given file."), QLatin1String("file")));
    parser.addVersionOption();
    parser.addHelpOption();

    parser.process(app);
    about.processCommandLine(&parser);

    QString resolvefile = parser.value(QLatin1String("resolve"));
    if (!resolvefile.isEmpty())
        return ShowResolveDialog(resolvefile);

    // is command line option 'show log dialog' specified?
    QString logFile = parser.value(QLatin1String("log"));
    if( !logFile.isEmpty() )
        return ShowLogDialog(logFile);

    // is command line option 'show annotation dialog' specified?
    QString annotateFile = parser.value(QLatin1String("annotate"));
    if( !annotateFile.isEmpty() )
        return ShowAnnotateDialog(annotateFile);

    if ( app.isSessionRestored() ) {
        RESTORE(CervisiaShell);
    } else {
        CervisiaShell* shell = new CervisiaShell();

        if( parser.positionalArguments().count() )
        {
            QDir dir(parser.positionalArguments()[0]);
            QUrl directory = QUrl::fromLocalFile(dir.absolutePath());
            shell->openURL(directory);
        }
        else
            shell->openURL();

        shell->setWindowIcon(qApp->windowIcon());
        shell->show();
    }

    int res = app.exec();
    cleanupTempFiles();
    return res;
}