Disable clipboardsharing in view only mode.
[kdenetwork.git] / kget / main.cpp
blob60808fc16c4d17554f34459007e4c32098aaaadc
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 <kwindowsystem.h>
13 #include <klocale.h>
14 #include <kaboutdata.h>
15 #include <kcmdlineargs.h>
16 #include <kuniqueapplication.h>
17 #include <kstandarddirs.h>
19 #include "core/kget.h"
20 #include "kgetadaptor.h"
21 #include "settings.h"
22 #include "ui/splash.h"
23 #include "mainwindow.h"
24 #include "ui/newtransferdialog.h"
26 class KGetApp : public KUniqueApplication
28 public:
29 KGetApp()
30 : KUniqueApplication(), kget( 0 ), splash( 0 )
32 showSplash();
35 ~KGetApp()
37 delete splash;
38 delete kget;
41 void showSplash()
43 //determine whether splash-screen is enabled in kgetrc
44 if ( !Settings::showSplashscreen() )
45 return;
47 // getting splash-screen path
48 QString path = KStandardDirs::locate( "data", "kget/pics/kget_splash.png" );
50 if ( !path.isEmpty() )
51 splash = new Splash( path );
54 int newInstance()
56 KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
58 if (!kget)
60 kget = new MainWindow(!args->isSet("showDropTarget"), args->isSet("startWithoutAnimation"));
61 new KgetAdaptor(kget);
62 QDBusConnection::sessionBus().registerObject("/KGet", kget);
64 KWindowSystem::activateWindow(kget->winId());
66 if (args->isSet("showDropTarget"))
67 Settings::setShowDropTarget( true );
69 KUrl::List l;
70 for (int i = 0; i < args->count(); i++)
72 QString txt(args->arg(i));
73 if ( txt.endsWith( ".kgt", Qt::CaseInsensitive ) )
74 KGet::load( txt );
75 else
76 l.push_back(KUrl(args->arg(i)));
79 args->clear();
80 if (splash)
81 splash->removeSplash();
83 // the last arg read (when we have more than 1 arg) is considered
84 // as destination dir for the previous downloads
85 // if there is a valid local file
86 QString destUrl;
87 if (l.count() >= 2 && l.last().isLocalFile()) {
88 if (!QFileInfo(l.last().path()).isDir())
89 destUrl = l.last().directory(KUrl::AppendTrailingSlash);
90 else
91 destUrl = l.last().path(KUrl::AddTrailingSlash);
93 l.removeLast();
94 KGet::addTransfer(l, destUrl, QString(), true);
95 return 0;
97 // all the args read from command line are downloads
98 if (l.count() == 1)
99 NewTransferDialog::instance(kget)->showDialog(l.takeFirst().url());
100 if (l.count() > 1 && !l.last().isLocalFile())
101 NewTransferDialog::instance(kget)->showDialog(l);
102 return 0;
105 private:
106 MainWindow * kget;
107 Splash * splash;
111 int main(int argc, char *argv[])
113 KAboutData aboutData("kget", 0, ki18n("KGet"),
114 QByteArray("2." + QByteArray::number(KDE_VERSION_MINOR) + '.' + QByteArray::number(KDE_VERSION_RELEASE)),
115 ki18n("An advanced download manager for KDE"),
116 KAboutData::License_GPL,
117 ki18n("(C) 2005 - 2008, The KGet developers\n"
118 "(C) 2001 - 2002, Patrick Charbonnier\n"
119 "(C) 2002, Carsten Pfeiffer\n"
120 "(C) 1998 - 2000, Matej Koss"),
121 ki18n("<a href=\"mailto:kget@kde.org\">kget@kde.org</a>"));
123 aboutData.addAuthor(ki18n("Dario Massarin"), ki18n("Maintainer, Core Developer"), "nekkar@libero.it");
124 aboutData.addAuthor(ki18n("Urs Wolfer"), ki18n("Core Developer"), "uwolfer@kde.org");
125 aboutData.addAuthor(ki18n("Manolo Valdes"), ki18n("Core Developer, Multithreaded Plugin Author"), "nolis71cu@gmail.com");
126 aboutData.addAuthor(ki18n("Javier Goday"), ki18n("Developer"), "jgoday@gmail.com");
127 aboutData.addAuthor(ki18n("Lukas Appelhans"), ki18n("Developer, Torrent Plugin Author"), "l.appelhans@gmx.de");
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"));
131 aboutData.addCredit(ki18n("Joris Guisson"), ki18n("BTCore (KTorrent) Developer"), "joris.guisson@gmail.com");
132 aboutData.addCredit(ki18n("Mensur Zahirovic (Nookie)"), ki18n("Design of Webinterface"), "linuxsajten@gmail.com");
134 KCmdLineArgs::init(argc, argv, &aboutData);
136 KCmdLineOptions option;
137 option.add("showDropTarget", ki18n("Start KGet with drop target"));
138 option.add("hideMainWindow", ki18n("Start KGet with hidden main window"));
139 option.add("startWithoutAnimation", ki18n("Start KGet without drop target animation"));
140 option.add("+[URL(s)]", ki18n("URL(s) to download"));
141 KCmdLineArgs::addCmdLineOptions(option);
143 KGetApp::addCmdLineOptions();
145 if (!KGetApp::start())
147 fprintf(stderr, "kget is already running!\n");
148 exit(0);
151 KGetApp kApp;
153 return kApp.exec();