1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
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. *
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. *
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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
23 #include <kcmdlineargs.h>
24 #include <kaboutdata.h>
25 #include <kiconloader.h>
28 #include <kglobalaccel.h>
29 #include <kmessagebox.h>
30 #include <kstandarddirs.h>
33 #include <qfileinfo.h>
35 #include <kconfig.h> // TMP IN ALPHA 1
37 #include "application.h"
38 #include "backgroundmanager.h"
39 #include "mainwindow.h"
42 #include "debugwindow.h"
45 #include "aboutdata.h"
46 #include "basket_options.h"
51 /* Thanks to JuK for this Application class */
52 /*#if KDE_IS_VERSION( 3, 1, 90 )
53 typedef KUniqueApplication Application; // KDE 3.2 and later already re-show the main window
55 class Application : public KUniqueApplication
58 Application() : KUniqueApplication(true, true, false) {}
59 virtual ~Application() {}
60 virtual int newInstance() {
63 return KUniqueApplication::newInstance();
69 int main(int argc
, char *argv
[])
71 // KCmdLineArgs::init will modify argv[0] so we remember it:
72 const char *argv0
= (argc
>= 1 ? argv
[0] : "");
74 KCmdLineArgs::init(argc
, argv
, Global::about());
75 KCmdLineArgs::addCmdLineOptions(basket_options
);
77 KUniqueApplication::addCmdLineOptions();
78 //KUniqueApplication app;
81 Backup::figureOutBinaryPath(argv0
, app
);
84 MainWindow
* win
= new MainWindow();
85 Global::bnpView
->handleCommandLine();
86 app
.setMainWidget(win
);
87 // if (!(Settings::useSystray() && KCmdLineArgs::parsedArgs() && KCmdLineArgs::parsedArgs()->isSet("start-hidden")))
90 if (Settings::useSystray()) {
91 // The user wanted to not show the window (but it is already hidden by default, so we do nothing):
92 if (KCmdLineArgs::parsedArgs() && KCmdLineArgs::parsedArgs()->isSet("start-hidden"))
94 // When the application is restored by KDE session, restore its state:
95 else if (app
.isSessionRestored())
96 win
->setShown(!Settings::startDocked());
97 // Else, the application has been launched explicitely by the user (KMenu, keyboard shortcut...), so he need it, we show it:
101 // No system tray icon: always show:
104 // Self-test of the presence of basketui.rc (the only requiered file after basket executable)
105 if (Global::bnpView
->popupMenu("basket") == 0L)
106 // An error message will be show by BNPView::popupMenu()
110 int result
= app
.exec();
112 exit(result
); // Do not clean up memory to not crash while deleting the KApplication, or do not hang up on KDE exit