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.
14 #include <kwindowsystem.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"
24 #include "ui/splash.h"
25 #include "mainwindow.h"
26 #include "ui/newtransferdialog.h"
28 class KGetApp
: public KUniqueApplication
32 : KUniqueApplication(), kget( 0 ), splash( 0 )
45 //determine whether splash-screen is enabled in kgetrc
46 if ( !Settings::showSplashscreen() )
49 // getting splash-screen path
50 QString path
= KStandardDirs::locate( "data", "kget/pics/kget_splash.png" );
52 if ( !path
.isEmpty() )
53 splash
= new Splash( path
);
58 KCmdLineArgs
*args
= KCmdLineArgs::parsedArgs();
62 kget
= new MainWindow(!args
->isSet("showDropTarget"), args
->isSet("startWithoutAnimation"));
63 new KgetAdaptor(kget
);
64 QDBusConnection::sessionBus().registerObject("/KGet", kget
);
66 KWindowSystem::activateWindow(kget
->winId());
68 if (args
->isSet("showDropTarget"))
69 Settings::setShowDropTarget( true );
72 for (int i
= 0; i
< args
->count(); i
++)
74 QString
txt(args
->arg(i
));
75 if ( txt
.endsWith( ".kgt", Qt::CaseInsensitive
) )
78 l
.push_back(KUrl(args
->arg(i
)));
83 splash
->removeSplash();
85 // the last arg read (when we have more than 1 arg) is considered
86 // as destination dir for the previous downloads
87 // if there is a valid local file
89 if (l
.count() >= 2 && l
.last().isLocalFile()) {
90 if (!QFileInfo(l
.last().path()).isDir())
91 destUrl
= l
.last().directory();
93 destUrl
= l
.last().path();
96 KGet::addTransfer(l
, destUrl
, QString(), true);
99 // all the args read from command line are downloads
101 NewTransferDialog::showNewTransferDialog(l
.takeFirst().url());
102 if (l
.count() > 1 && !l
.last().isLocalFile())
103 NewTransferDialog::showNewTransferDialog(l
);
113 int main(int argc
, char *argv
[])
115 KAboutData
aboutData("kget", 0, ki18n("KGet"), "2.0 Beta1",
116 ki18n("An advanced download manager for KDE"),
117 KAboutData::License_GPL
,
118 ki18n("(C) 2005 - 2007, The KGet developers\n"
119 "(C) 2001 - 2002, Patrick Charbonnier\n"
120 "(C) 2002, Carsten Pfeiffer\n"
121 "(C) 1998 - 2000, Matej Koss"),
122 ki18n("<a href=\"mailto:kget@kde.org\">kget@kde.org</a>"));
124 aboutData
.addAuthor(ki18n("Dario Massarin"), ki18n("Maintainer, Core Developer"), "nekkar@libero.it");
125 aboutData
.addAuthor(ki18n("Urs Wolfer"), ki18n("Core Developer"), "uwolfer@kde.org");
126 aboutData
.addAuthor(ki18n("Manolo Valdes"), ki18n("Core Developer, Multithreaded Plugin Author"), "nolis71cu@gmail.com");
127 aboutData
.addAuthor(ki18n("Javier Goday"), ki18n("Developer"), "jgoday@gmail.com");
128 aboutData
.addAuthor(ki18n("Patrick Charbonnier"), ki18n("Former Developer"), "pch@freeshell.org");
129 aboutData
.addAuthor(ki18n("Carsten Pfeiffer"), ki18n("Former Developer"), "pfeiffer@kde.org");
130 aboutData
.addAuthor(ki18n("Matej Koss"), ki18n("Former Developer"));
132 KCmdLineArgs::init(argc
, argv
, &aboutData
);
134 KCmdLineOptions option
;
135 option
.add("showDropTarget", ki18n("Start KGet with drop target"));
136 option
.add("hideMainWindow", ki18n("Start KGet with hidden main window"));
137 option
.add("startWithoutAnimation", ki18n("Start KGet without drop target animation"));
138 option
.add("+[URL(s)]", ki18n("URL(s) to download"));
139 KCmdLineArgs::addCmdLineOptions(option
);
141 KGetApp::addCmdLineOptions();
143 if (!KGetApp::start())
145 fprintf(stderr
, "kget is already running!\n");