File indexing completed on 2024-05-19 16:49:47

0001 // SPDX-FileCopyrightText: 2020 Simon Persson <simon.persson@mykolab.com>
0002 //
0003 // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0004 
0005 #include "filedigger.h"
0006 #include "mergedvfs.h"
0007 
0008 #include <git2/global.h>
0009 
0010 #include <KAboutData>
0011 #include <KLocalizedString>
0012 
0013 #include <QApplication>
0014 #include <QCommandLineOption>
0015 #include <QCommandLineParser>
0016 #include <QDir>
0017 #include <QFile>
0018 #include <QTextStream>
0019 
0020 int main(int pArgCount, char **pArgArray) {
0021     QApplication lApp(pArgCount, pArgArray);
0022     QApplication::setAttribute(Qt::AA_UseHighDpiPixmaps, true);
0023 
0024     KLocalizedString::setApplicationDomain("kup");
0025 
0026     KAboutData lAbout(QStringLiteral("kupfiledigger"), xi18nc("@title", "File Digger"), QStringLiteral("0.9.1"),
0027                       i18n("Browser for bup archives."),
0028                       KAboutLicense::GPL, i18n("Copyright (C) 2013-2020 Simon Persson"));
0029     lAbout.addAuthor(i18n("Simon Persson"), i18n("Maintainer"), "simon.persson@mykolab.com");
0030     lAbout.setTranslator(xi18nc("NAME OF TRANSLATORS", "Your names"), xi18nc("EMAIL OF TRANSLATORS", "Your emails"));
0031     KAboutData::setApplicationData(lAbout); //this calls qApp.setApplicationName, setVersion, etc.
0032 
0033     QCommandLineParser lParser;
0034     lParser.addOption(QCommandLineOption(QStringList() << QStringLiteral("b") << QStringLiteral("branch"),
0035                                          i18n("Name of the branch to be opened."),
0036                                          QStringLiteral("branch name"), QStringLiteral("kup")));
0037     lParser.addPositionalArgument(QStringLiteral("<repository path>"), i18n("Path to the bup repository to be opened."));
0038 
0039     lAbout.setupCommandLine(&lParser);
0040     lParser.process(lApp);
0041     lAbout.processCommandLine(&lParser);
0042 
0043     QString lRepoPath;
0044     QStringList lPosArgs = lParser.positionalArguments();
0045     if(!lPosArgs.isEmpty()) {
0046         auto lDir = QDir(lPosArgs.takeFirst());
0047         lRepoPath = lDir.absolutePath();
0048     }
0049 
0050     // This needs to be called first thing, before any other calls to libgit2.
0051     git_libgit2_init();
0052 
0053     auto lFileDigger = new FileDigger(lRepoPath, lParser.value(QStringLiteral("branch")));
0054     lFileDigger->show();
0055     int lRetVal = QApplication::exec();
0056     git_libgit2_shutdown();
0057     return lRetVal;
0058 }