File: pimdatacommandlineoption.cpp

package info (click to toggle)
pim-data-exporter 4%3A24.12.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,552 kB
  • sloc: cpp: 13,291; xml: 182; makefile: 6; sh: 3
file content (76 lines) | stat: -rw-r--r-- 3,000 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
   SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org>

   SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "pimdatacommandlineoption.h"
#include "pimdataexporter-version.h"
#include "pimdataexporterwindow.h"
#include "pimdataexportgui_debug.h"
#include <KAboutData>
#include <KLocalizedString>
#include <QApplication>
#include <QCommandLineOption>

PimDataCommandLineOption::PimDataCommandLineOption(QObject *parent)
    : QObject(parent)
{
}

PimDataCommandLineOption::~PimDataCommandLineOption() = default;

void PimDataCommandLineOption::slotActivateRequested(const QStringList &arguments, const QString &workingDirectory)
{
    Q_UNUSED(workingDirectory)
    if (!arguments.isEmpty()) {
        if (mParser.parse(arguments)) {
            handleCommandLine();
        } else {
            qCDebug(PIMDATAEXPORTERGUI_LOG) << " Impossible to parse argument ";
        }
    }
}

void PimDataCommandLineOption::createParser(const QApplication &app)
{
    KAboutData aboutData(QStringLiteral("pimdataexporter"),
                         i18n("PIM Data Exporter"),
                         QStringLiteral(PIMDATAEXPORTER_VERSION),
                         i18n("PIM Data Exporter"),
                         KAboutLicense::GPL_V2,
                         i18n("Copyright © 2012-%1 pimdataexporter authors", QStringLiteral("2024")));
    aboutData.addAuthor(i18nc("@info:credit", "Laurent Montel"), i18n("Maintainer"), QStringLiteral("montel@kde.org"));
    KAboutData::setApplicationData(aboutData);
    aboutData.setupCommandLine(&mParser);
    mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("template"),
                                         i18n("Template file uses to define what data, settings to import or export"),
                                         QStringLiteral("file")));
    mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("import"), i18nc("@info:shell", "Import the given file")));
    mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("export"), i18nc("@info:shell", "Export the given file")));
    mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("+[url]"),
                                         i18nc("@info:shell", "File or url. The user will be asked whether to import or export.")));
#ifdef WITH_KUSERFEEDBACK
    mParser.addOption(QCommandLineOption(QStringLiteral("feedback"), i18nc("@info:shell", "Lists the available options for user feedback")));
#endif
    mParser.process(app);
    aboutData.processCommandLine(&mParser);
}

void PimDataCommandLineOption::setExportWindow(PimDataExporterWindow *exporterWindow)
{
    mExporterWindow = exporterWindow;
}

void PimDataCommandLineOption::handleCommandLine()
{
    if (mExporterWindow) {
        mExporterWindow->handleCommandLine(mParser);
    }
}

bool PimDataCommandLineOption::parseUserFeedback() const
{
    return mParser.isSet(QStringLiteral("feedback"));
}

#include "moc_pimdatacommandlineoption.cpp"