File indexing completed on 2024-05-12 05:25:36
0001 /* 0002 SPDX-FileCopyrightText: 2015-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 #include "pimdatacommandlineoption.h" 0007 #include "pimdataexporter-version.h" 0008 #include "pimdataexporterwindow.h" 0009 #include "pimdataexportgui_debug.h" 0010 #include <KAboutData> 0011 #include <KLocalizedString> 0012 #include <QApplication> 0013 #include <QCommandLineOption> 0014 0015 PimDataCommandLineOption::PimDataCommandLineOption(QObject *parent) 0016 : QObject(parent) 0017 { 0018 } 0019 0020 PimDataCommandLineOption::~PimDataCommandLineOption() = default; 0021 0022 void PimDataCommandLineOption::slotActivateRequested(const QStringList &arguments, const QString &workingDirectory) 0023 { 0024 Q_UNUSED(workingDirectory) 0025 if (!arguments.isEmpty()) { 0026 if (mParser.parse(arguments)) { 0027 handleCommandLine(); 0028 } else { 0029 qCDebug(PIMDATAEXPORTERGUI_LOG) << " Impossible to parse argument "; 0030 } 0031 } 0032 } 0033 0034 void PimDataCommandLineOption::createParser(const QApplication &app) 0035 { 0036 KAboutData aboutData(QStringLiteral("pimdataexporter"), 0037 i18n("PIM Data Exporter"), 0038 QStringLiteral(PIMDATAEXPORTER_VERSION), 0039 i18n("PIM Data Exporter"), 0040 KAboutLicense::GPL_V2, 0041 i18n("Copyright © 2012-%1 pimdataexporter authors", QStringLiteral("2024"))); 0042 aboutData.addAuthor(i18n("Laurent Montel"), i18n("Maintainer"), QStringLiteral("montel@kde.org")); 0043 KAboutData::setApplicationData(aboutData); 0044 aboutData.setupCommandLine(&mParser); 0045 mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("template"), 0046 i18n("Template file uses to define what data, settings to import or export"), 0047 QStringLiteral("file"))); 0048 mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("import"), i18n("Import the given file"))); 0049 mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("export"), i18n("Export the given file"))); 0050 mParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("+[url]"), i18n("File or url. The user will be asked whether to import or export."))); 0051 #ifdef WITH_KUSERFEEDBACK 0052 mParser.addOption(QCommandLineOption(QStringLiteral("feedback"), i18n("Lists the available options for user feedback"))); 0053 #endif 0054 mParser.process(app); 0055 aboutData.processCommandLine(&mParser); 0056 } 0057 0058 void PimDataCommandLineOption::setExportWindow(PimDataExporterWindow *exporterWindow) 0059 { 0060 mExporterWindow = exporterWindow; 0061 } 0062 0063 void PimDataCommandLineOption::handleCommandLine() 0064 { 0065 if (mExporterWindow) { 0066 mExporterWindow->handleCommandLine(mParser); 0067 } 0068 } 0069 0070 bool PimDataCommandLineOption::parseUserFeedback() const 0071 { 0072 return mParser.isSet(QStringLiteral("feedback")); 0073 } 0074 0075 #include "moc_pimdatacommandlineoption.cpp"