main.cpp 3.33 KB
Newer Older
1
/***********************************************************************
2
3
* SPDX-FileCopyrightText: 2003-2004 Max Howell <max.howell@methylblue.com>
* SPDX-FileCopyrightText: 2008-2014 Martin Sandsmark <martin.sandsmark@kde.org>
4
*
5
* SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
6
***********************************************************************/
7
8

#include "define.h"
9
10
#include "mainWindow.h"

11
12
13
#include <QApplication>
#include <QCommandLineParser>
#include <QUrl>
14
#include <QDir>
15

16
17
18
#include <KAboutData>
#include <KLocalizedString>
#include <Kdelibs4ConfigMigrator>
19
20
#include <KSharedConfig>
#include <KConfigGroup>
21

22
int main(int argc, char *argv[])
23
{
Christoph Cullmann's avatar
Christoph Cullmann committed
24
25
26
27
28
29
    /**
     * enable high dpi support
     */
    QCoreApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
    QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling, true);

Laurent Montel's avatar
Laurent Montel committed
30
31
    QApplication app(argc, argv);

32
33
    KLocalizedString::setApplicationDomain("filelight");

Laurent Montel's avatar
Laurent Montel committed
34
35
36
    Kdelibs4ConfigMigrator migrate(QStringLiteral("filelight"));
    migrate.setConfigFiles(QStringList() << QStringLiteral("filelightrc"));
    migrate.setUiFiles(QStringList() << QStringLiteral("filelightui.rc"));
37
38
    migrate.migrate();

39
40
41
42
43
44
45
46
    auto config = KSharedConfig::openConfig();
    auto stateConfig = KSharedConfig::openStateConfig();
    if (config->hasGroup("general")) {
        auto grp = stateConfig->group("general");
        config->group("general").copyTo(&grp);
        config->deleteGroup("general");
    }

47
48
    using Filelight::MainWindow;

Burkhard Lück's avatar
Burkhard Lück committed
49
50
51
52
53
54
55
56
57
    KAboutData about(
        QStringLiteral(APP_NAME),
        i18n(APP_PRETTYNAME),
        QStringLiteral(APP_VERSION),
        i18n("Graphical disk-usage information"),
        KAboutLicense::GPL,
        i18n("(C) 2006 Max Howell\n"
             "(C) 2008-2014 Martin Sandsmark"),
        QString(),
58
        QStringLiteral("https://utils.kde.org/projects/filelight")
Burkhard Lück's avatar
Burkhard Lück committed
59
    );
60
61
    about.addAuthor(i18n("Martin Sandsmark"), i18n("Maintainer"), QStringLiteral("martin.sandsmark@kde.org"), QStringLiteral("https://iskrembilen.com/"));
    about.addAuthor(i18n("Max Howell"),       i18n("Original author"), QStringLiteral("max.howell@methylblue.com"), QStringLiteral("https://www.methylblue.com/"));
62
63
64
65
66
    about.addCredit(i18n("Lukas Appelhans"),  i18n("Help and support"));
    about.addCredit(i18n("Steffen Gerlach"),  i18n("Inspiration"), QString(), QStringLiteral("http://www.steffengerlach.de/"));
    about.addCredit(i18n("Mike Diehl"),       i18n("Original documentation"));
    about.addCredit(i18n("Sune Vuorela"),     i18n("Icon"));
    about.addCredit(i18n("Nuno Pinheiro"),    i18n("Icon"));
67

68
    KAboutData::setApplicationData(about);
69
    app.setOrganizationName(QStringLiteral("KDE"));
Laurent Montel's avatar
Laurent Montel committed
70
    app.setWindowIcon(QIcon::fromTheme(QStringLiteral(APP_NAME)));
71

72
    QCommandLineParser options;
73
    options.addPositionalArgument(QStringLiteral("url"), i18n("Path or URL to scan"), i18n("[url]"));
74
    about.setupCommandLine(&options);
75
    options.process(app);
76
    about.processCommandLine(&options);
77

78
    if (!app.isSessionRestored()) {
79
80
        MainWindow *mw = new MainWindow();

81
        QStringList args = options.positionalArguments();
82
        if (args.count() > 0) {
83
            mw->scan(QUrl::fromUserInput(args.at(0), QDir::currentPath(), QUrl::AssumeLocalFile));
84
        }
85
86
87

        mw->show();
    }
88
    else kRestoreMainWindows<MainWindow>();
89
90
91

    return app.exec();
}