Use correct namespace for focus policies.
[basket4.git] / src / main.cpp
blob5b3164a53873e360b979996455200b3343eef125
1 /***************************************************************************
2 * Copyright (C) 2003 by Sébastien Laoût *
3 * slaout@linux62.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 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19 ***************************************************************************/
21 #include <stdlib.h>
23 #include <kcmdlineargs.h>
24 #include <kaboutdata.h>
25 #include <kiconloader.h>
26 #include <qpixmap.h>
27 #include <klocale.h>
28 #include <kglobalaccel.h>
29 #include <kmessagebox.h>
30 #include <kstandarddirs.h>
31 #include <kdebug.h>
32 #include <qfile.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"
40 #include "settings.h"
41 #include "global.h"
42 #include "debugwindow.h"
43 #include "notedrag.h"
44 #include "basket.h"
45 #include "aboutdata.h"
46 #include "basket_options.h"
47 #include "backup.h"
49 #include <config.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
54 #else
55 class Application : public KUniqueApplication
57 public:
58 Application() : KUniqueApplication(true, true, false) {}
59 virtual ~Application() {}
60 virtual int newInstance() {
61 if (win)
62 win->setActive(true);
63 return KUniqueApplication::newInstance();
66 #endif
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;
79 Application app;
81 Backup::figureOutBinaryPath(argv0, app);
83 /* Main Window */
84 MainWindow* win = new MainWindow();
85 Global::bnpView->handleCommandLine();
86 app.setMainWidget(win);
87 // if (!(Settings::useSystray() && KCmdLineArgs::parsedArgs() && KCmdLineArgs::parsedArgs()->isSet("start-hidden")))
88 // win->show();
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:
98 else
99 win->show();
100 } else
101 // No system tray icon: always show:
102 win->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()
107 return 1;
109 /* Go */
110 int result = app.exec();
111 //return result;
112 exit(result); // Do not clean up memory to not crash while deleting the KApplication, or do not hang up on KDE exit