File indexing completed on 2025-01-05 04:22:26
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: GPL-2.0-or-later 0005 */ 0006 0007 #include "voskdownloadlanguagejob.h" 0008 #include <QApplication> 0009 #include <QCommandLineParser> 0010 #include <QDebug> 0011 #include <QFileInfo> 0012 #include <QStandardPaths> 0013 0014 int main(int argc, char **argv) 0015 { 0016 QApplication app(argc, argv); 0017 QStandardPaths::setTestModeEnabled(true); 0018 QCommandLineParser parser; 0019 parser.addVersionOption(); 0020 parser.addHelpOption(); 0021 parser.addOption(QCommandLineOption(QStringList() << QStringLiteral("+[file]"), QStringLiteral("Add specific archive file name"))); 0022 0023 parser.process(app); 0024 if (!parser.positionalArguments().isEmpty()) { 0025 const QString fileName = parser.positionalArguments().at(0); 0026 auto download = new VoskDownloadLanguageJob(); 0027 VoskDownloadLanguageJob::DownloadLanguageInfo info; 0028 info.url = QUrl(fileName); 0029 const QFileInfo f(fileName); 0030 const QString baseName = f.baseName(); 0031 0032 info.name = info.url.path() + QLatin1Char('/') + baseName; 0033 0034 download->setInfo(std::move(info)); 0035 QObject::connect(download, &VoskDownloadLanguageJob::extractDone, &app, []() { 0036 qDebug() << "Extraction Done"; 0037 }); 0038 QObject::connect(download, &VoskDownloadLanguageJob::errorText, &app, [](const QString &str) { 0039 qDebug() << "Extraction error: " << str; 0040 }); 0041 download->start(); 0042 app.exec(); 0043 } else { 0044 qWarning() << "Missing argument"; 0045 } 0046 return 0; 0047 }