File indexing completed on 2024-04-21 05:48:19

0001 /**
0002  * SPDX-FileCopyrightText: (C) 2003 Sébastien Laoût <slaout@linux62.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-or-later
0005  */
0006 
0007 #include "basket_options.h"
0008 #include <QCommandLineOption>
0009 #include <QCommandLineParser>
0010 #include <config.h>
0011 #include <kconfig.h> // TMP IN ALPHA 1
0012 
0013 #include "application.h"
0014 #include "backup.h"
0015 #include "global.h"
0016 #include "kde4_migration.h"
0017 #include "mainwindow.h"
0018 #include "settings.h"
0019 
0020 int main(int argc, char *argv[])
0021 {
0022     const char *argv0 = (argc >= 1 ? argv[0] : "");
0023 
0024     // enable high dpi support
0025     Application::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0026     Application::setAttribute(Qt::AA_EnableHighDpiScaling, true);
0027 
0028     Global::commandLineOpts = new QCommandLineParser();
0029     Application app(argc, argv);
0030 
0031     QCommandLineParser *opts = Global::commandLineOpts;
0032     KAboutData::applicationData().setupCommandLine(opts); //--author, --license
0033     setupCmdLineOptions(opts);
0034     opts->process(app);
0035     KAboutData::applicationData().processCommandLine(opts); // show author, license information and exit
0036 
0037     {
0038         Kde4Migrator migrator;
0039         if (migrator.migrateKde4Data())
0040             migrator.showPostMigrationDialog();
0041     }
0042 
0043     app.tryLoadFile(opts->positionalArguments(), QDir::currentPath());
0044 
0045     // Initialize the config file
0046     Global::basketConfig = KSharedConfig::openConfig("basketrc");
0047 
0048     Backup::figureOutBinaryPath(argv0, app);
0049 
0050     /* Main Window */
0051     MainWindow *win = new MainWindow();
0052     Global::mainWnd = win;
0053     Global::bnpView->handleCommandLine();
0054     app.setActiveWindow(win);
0055 
0056     win->show();
0057 
0058     // Self-test of the presence of basketui.rc (the only required file after basket executable)
0059     if (Global::bnpView->popupMenu("basket") == nullptr)
0060         // An error message will be show by BNPView::popupMenu()
0061         return 1;
0062 
0063     /* Go */
0064     int result = app.exec();
0065     exit(result); // Do not clean up memory to not crash while deleting the QApplication, or do not hang up on session exit
0066 }