/***************************************************************************
 *   Copyright (C) 2008 by Andreas Silberstorff   *
 *   ml@andreas-silberstorff.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.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
 ***************************************************************************/


#include "kalva2.h"
#include <KUniqueApplication>
#include <KAboutData>
#include <KCmdLineArgs>
#include <KDE/KLocale>

static const char description[] =
    I18N_NOOP("Kalva is a lightweight video application");

static const char version[] = "1.91";

/**
 * Kalva is a lightweight video application.
 * Kalva uses a plugin system to provide different perspectives.
 */
int main(int argc, char **argv)
{
    KAboutData about("kalva2", 0, ki18n("Kalva2"), version, ki18n(description),
                     KAboutData::License_GPL, ki18n("(C) 2008 Andreas Silberstorff"), KLocalizedString(), 0, "ml@andreas-silberstorff.de");
    about.addAuthor( ki18n("Andreas Silberstorff"), KLocalizedString(), "ml@andreas-silberstorff.de" );
    KCmdLineArgs::init(argc, argv, &about);

    KCmdLineOptions options;
    options.add("+[URL]", ki18n( "Document to open" ));
    KCmdLineArgs::addCmdLineOptions(options);
    KUniqueApplication app;

    kalva2 *widget = new kalva2;

    // see if we are starting with session management
    if (app.isSessionRestored())
    {
        RESTORE(kalva2);
    }
    else
    {
        // no session.. just start up normally
        KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
        if (args->count() == 0)
        {
            //te *widget = new te;
            widget->show();
        }
        else
        {
            int i = 0;
            for (; i < args->count(); i++)
            {
                //te *widget = new te;
                widget->show();
            }
        }
        args->clear();
    }

    return app.exec();
}
