Update authors list:
[kdenetwork.git] / kget / main.cpp
blob15e82d743a20b15a21ff02203810a887a96541d1
1 /* This file is part of the KDE project
3 Copyright (C) 2002 by Patrick Charbonnier <pch@freeshell.org>
4 Based On Caitoo v.0.7.3 (c) 1998 - 2000, Matej Koss
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
12 #include <QtDBus>
14 #include <kwindowsystem.h>
15 #include <klocale.h>
16 #include <kaboutdata.h>
17 #include <kcmdlineargs.h>
18 #include <kuniqueapplication.h>
19 #include <kstandarddirs.h>
21 #include "core/kget.h"
22 #include "kgetadaptor.h"
23 #include "settings.h"
24 #include "ui/splash.h"
25 #include "mainwindow.h"
27 class KGetApp : public KUniqueApplication
29 public:
30 KGetApp()
31 : KUniqueApplication(), kget( 0 ), splash( 0 )
33 showSplash();
36 ~KGetApp()
38 delete splash;
39 delete kget;
42 void showSplash()
44 //determine whether splash-screen is enabled in kgetrc
45 if ( !Settings::showSplashscreen() )
46 return;
48 // getting splash-screen path
49 QString path = KStandardDirs::locate( "data", "kget/pics/kget_splash.png" );
51 if ( !path.isEmpty() )
52 splash = new Splash( path );
55 int newInstance()
57 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
59 if (!kget)
61 kget = new MainWindow(!args->isSet("showDropTarget"), args->isSet("startWithoutAnimation"));
62 new KgetAdaptor(kget);
63 QDBusConnection::sessionBus().registerObject("/KGet", kget);
65 KWindowSystem::activateWindow(kget->winId());
67 if (args->isSet("showDropTarget"))
68 Settings::setShowDropTarget( true );
70 KUrl::List l;
71 for (int i = 0; i < args->count(); i++)
73 QString txt(args->arg(i));
74 if ( txt.endsWith( ".kgt", Qt::CaseInsensitive ) )
75 KGet::load( txt );
76 else
77 l.push_back(KUrl(args->arg(i)));
79 // all the args read from command line are downloads
80 if (l.count() >= 1)
81 KGet::addTransfer(l, QString(), QString(), true);
83 // the last arg read (when we have more than 1 arg) is considered
84 // as destination dir for the previous downloads
85 if (l.count() == 1)
86 kget->addTransfersEx( l, KUrl());
87 else if (l.count() > 1)
89 KUrl last = l.last();
90 l.pop_back();
91 kget->addTransfersEx(l, last);
94 args->clear();
95 if ( splash )
96 splash->removeSplash();
97 return 0;
100 private:
101 MainWindow * kget;
102 Splash * splash;
106 int main(int argc, char *argv[])
108 KAboutData aboutData("kget", 0, ki18n("KGet"), "2.0 Beta1",
109 ki18n("An advanced download manager for KDE"),
110 KAboutData::License_GPL,
111 ki18n("(C) 2005 - 2007, The KGet developers\n"
112 "(C) 2001 - 2002, Patrick Charbonnier\n"
113 "(C) 2002, Carsten Pfeiffer\n"
114 "(C) 1998 - 2000, Matej Koss"),
115 ki18n("<a href=\"mailto:kget@kde.org\">kget@kde.org</a>"));
117 aboutData.addAuthor(ki18n("Dario Massarin"), ki18n("Maintainer, Core Developer"), "nekkar@libero.it");
118 aboutData.addAuthor(ki18n("Urs Wolfer"), ki18n("Core Developer"), "uwolfer@kde.org");
119 aboutData.addAuthor(ki18n("Manolo Valdes"), ki18n("Core Developer, Multithreaded Plugin Author"), "nolis71cu@gmail.com");
120 aboutData.addAuthor(ki18n("Javier Goday"), ki18n("Developer"), "jgoday@gmail.com");
121 aboutData.addAuthor(ki18n("Patrick Charbonnier"), ki18n("Former Developer"), "pch@freeshell.org");
122 aboutData.addAuthor(ki18n("Carsten Pfeiffer"), ki18n("Former Developer"), "pfeiffer@kde.org");
123 aboutData.addAuthor(ki18n("Matej Koss"), ki18n("Former Developer"));
125 KCmdLineArgs::init(argc, argv, &aboutData);
127 KCmdLineOptions option;
128 option.add("showDropTarget", ki18n("Start KGet with drop target"));
129 option.add("hideMainWindow", ki18n("Start KGet with hidden main window"));
130 option.add("startWithoutAnimation", ki18n("Start KGet without drop target animation"));
131 option.add("+[URL(s)]", ki18n("URL(s) to download"));
132 KCmdLineArgs::addCmdLineOptions(option);
134 KGetApp::addCmdLineOptions();
136 if (!KGetApp::start())
138 fprintf(stderr, "kget is already running!\n");
139 exit(0);
142 KGetApp kApp;
144 return kApp.exec();