]> git.sesse.net Git - kdenlive/blob - src/main.cpp
Add command line option ( --mlt-path ) to give location of the MLT install
[kdenlive] / src / main.cpp
1 /***************************************************************************
2  *   Copyright (C) 2007 by Marco Gittler (g.marco@freenet.de)              *
3  *   Copyright (C) 2008 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
4  *                                                                         *
5  *   This program is free software; you can redistribute it and/or modify  *
6  *   it under the terms of the GNU General Public License as published by  *
7  *   the Free Software Foundation; either version 2 of the License, or     *
8  *   (at your option) any later version.                                   *
9  *                                                                         *
10  *   This program is distributed in the hope that it will be useful,       *
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
13  *   GNU General Public License for more details.                          *
14  *                                                                         *
15  *   You should have received a copy of the GNU General Public License     *
16  *   along with this program; if not, write to the                         *
17  *   Free Software Foundation, Inc.,                                       *
18  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
19  ***************************************************************************/
20
21 #include <KApplication>
22 #include <KAboutData>
23 #include <KDebug>
24 #include <KCmdLineArgs>
25 #include <KUrl> //new
26
27 #include "mainwindow.h"
28
29 int main(int argc, char *argv[]) {
30     KAboutData aboutData(QByteArray("kdenlive"), QByteArray("kdenlive"),
31                          ki18n("Kdenlive"), QByteArray("0.7"),
32                          ki18n("An open source video editor."),
33                          KAboutData::License_GPL,
34                          ki18n("Copyright (c) 2008 Development team"));
35     aboutData.addAuthor(ki18n("Jean-Baptiste Mardelle"), ki18n("Mlt porting, KDE4 porting, Main developer"), "jb@kdenlive.org");
36     aboutData.addAuthor(ki18n("Marco Gittler"), ki18n("MltConnection, Transition, Effect, Timeline Developer"), "g.marco@freenet.de");
37     aboutData.setHomepage("http://kdenlive.org");
38     //aboutData.setBugAddress("http://kdenlive.org/mantis");
39     KCmdLineArgs::init(argc, argv, &aboutData);
40
41     KCmdLineOptions options;
42     options.add("mlt-path <path>", ki18n("Set the path for MLT environnement"));
43     options.add("+[file]", ki18n("Document to open")); //new
44     KCmdLineArgs::addCmdLineOptions(options); //new
45
46     KApplication app;
47
48     // see if we are starting with session management
49     if (app.isSessionRestored()) {
50         int n = 1;
51         while (KMainWindow::canBeRestored(n)) {
52             const QString className = KXmlGuiWindow::classNameOfToplevel(n);
53             if (className == QLatin1String("MainWindow")) {
54                 MainWindow* win = new MainWindow();
55                 win->restore(n);
56             } else {
57                 kWarning() << "Unknown class " << className << " in session saved data!";
58             }
59             ++n;
60         }
61     } else {
62         KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); //new
63
64         QString mltPath = args->getOption("mlt-path");
65         MainWindow* window = new MainWindow(mltPath);
66         window->show();
67         if (args->count()) { //new
68             window->openFile(args->url(0)); //new
69         }
70
71         args->clear();
72     }
73
74     return app.exec();
75 }