| 1 | /* |
| 2 | * Copyright (C) 2015, Mike Walters <[email protected]> |
| 3 | * |
| 4 | * This file is part of inspectrum. |
| 5 | * |
| 6 | * This program is free software: you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation, either version 3 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #include <QApplication> |
| 21 | #include <QCommandLineParser> |
| 22 | |
| 23 | #include "mainwindow.h"cxx . . $ `<file>/src/mainwindow.h`/ |
| 24 | |
| 25 | int maincxx . . $ main(afcd3168fc1188a4).(int argc, char *argv[]) |
| 26 | { |
| 27 | QApplicationcxx . . $ QApplication# acxx . . $ QApplication#QApplication(6e9b1c7df49e191d).(argc, argv); |
| 28 | a.setApplicationNamecxx . . $ QCoreApplication#setApplicationName(3520e46b33348bf6).("inspectrum"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 29 | a.setOrganizationNamecxx . . $ QCoreApplication#setOrganizationName(3520e46b33348bf6).("inspectrum"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 30 | |
| 31 | MainWindowcxx . . $ MainWindow# mainWincxx . . $ MainWindow#MainWindow(49f6e7a06ebc5aa8).; |
| 32 | |
| 33 | QCommandLineParsercxx . . $ QCommandLineParser# parsercxx . . $ QCommandLineParser#QCommandLineParser(49f6e7a06ebc5aa8).; |
| 34 | parser.setApplicationDescriptioncxx . . $ QCommandLineParser#setApplicationDescription(3520e46b33348bf6).("spectrum viewer"cxx . . $ QString#QString(85c52e162fed56f9).); |
| 35 | parser.addHelpOptioncxx . . $ QCommandLineParser#addHelpOption(cd8590dcf46f7865).(); |
| 36 | parser.addPositionalArgumentcxx . . $ QCommandLineParser#addPositionalArgument(9f9ceb6f9de3a67b).("file"cxx . . $ QString#QString(85c52e162fed56f9)., QCoreApplicationcxx . . $ QCoreApplication#::translatecxx . . $ QCoreApplication#translate(699330408c757f1b).("main", "File to view.")); |
| 37 | |
| 38 | // Add options |
| 39 | QCommandLineOptioncxx . . $ QCommandLineOption# rateOptioncxx . . $ QCommandLineOption#QCommandLineOption(b412db680b93e64c).(QStringListcxx . . $ QStringList#QStringList(49f6e7a06ebc5aa8).() <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "r"cxx . . $ QString#QString(85c52e162fed56f9). <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "rate"cxx . . $ QString#QString(85c52e162fed56f9)., |
| 40 | QCoreApplicationcxx . . $ QCoreApplication#::translatecxx . . $ QCoreApplication#translate(699330408c757f1b).("main", "Set sample rate."), |
| 41 | QCoreApplicationcxx . . $ QCoreApplication#::translatecxx . . $ QCoreApplication#translate(699330408c757f1b).("main", "Hz")); |
| 42 | parser.addOptioncxx . . $ QCommandLineParser#addOption(785b7e1f8b52cda9).(rateOption); |
| 43 | QCommandLineOptioncxx . . $ QCommandLineOption# formatOptioncxx . . $ QCommandLineOption#QCommandLineOption(b412db680b93e64c).(QStringListcxx . . $ QStringList#QStringList(49f6e7a06ebc5aa8).() <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "f"cxx . . $ QString#QString(85c52e162fed56f9). <<cxx . . $ QStringList#`operator<<`(85116071a693d053). "format"cxx . . $ QString#QString(85c52e162fed56f9)., |
| 44 | QCoreApplicationcxx . . $ QCoreApplication#::translatecxx . . $ QCoreApplication#translate(699330408c757f1b).("main", "Set file format, options: cfile/cf32/fc32, cf64/fc64, cs32/sc32/c32, cs16/sc16/c16, cs8/sc8/c8, cu8/uc8, f32, f64, s16, s8, u8, sigmf-meta/sigmf-data."), |
| 45 | QCoreApplicationcxx . . $ QCoreApplication#::translatecxx . . $ QCoreApplication#translate(699330408c757f1b).("main", "fmt")); |
| 46 | parser.addOptioncxx . . $ QCommandLineParser#addOption(785b7e1f8b52cda9).(formatOption); |
| 47 | |
| 48 | // Process the actual command line |
| 49 | parser.processcxx . . $ QCommandLineParser#process(b8a59b8a0e185f8a).(a); |
| 50 | |
| 51 | // Check for file format override |
| 52 | if(parser.isSetcxx . . $ QCommandLineParser#isSet(77a06b70c81738c8).(formatOption)){ |
| 53 | mainWin.setFormatcxx . . $ MainWindow#setFormat(7df51288a9ebd664).(parsercxx . . $ QString#QString(e1217c004a86c950)..valuecxx . . $ QCommandLineParser#value(aa213ac3e429ad86).(formatOption)); |
| 54 | } |
| 55 | |
| 56 | const QStringListcxx . . $ QStringList# args = parser.positionalArgumentscxx . . $ QCommandLineParser#positionalArguments(e1dbd5c4feadc8f5).(); |
| 57 | if (args.sizecxx . . $ QList#size(455f465bc33b4cdf).()>=1) |
| 58 | mainWin.openFilecxx . . $ MainWindow#openFile(7df51288a9ebd664).(argscxx . . $ QString#QString(3520e46b33348bf6)..atcxx . . $ QList#at(e2681f9bb6b2f357).(0)); |
| 59 | |
| 60 | if (parser.isSetcxx . . $ QCommandLineParser#isSet(77a06b70c81738c8).(rateOption)) { |
| 61 | bool ok; |
| 62 | auto rate = parser.valuecxx . . $ QCommandLineParser#value(aa213ac3e429ad86).(rateOption).toDoublecxx . . $ QString#toDouble(1bd8e57dd4a29c14).(&ok); |
| 63 | if(!ok) { |
| 64 | fputs("ERROR: could not parse rate\n", stderrcxx . . $ `<external>/232824719582829767/stdio.h:159:9`!); |
| 65 | return 1; |
| 66 | } |
| 67 | mainWin.setSampleRatecxx . . $ MainWindow#setSampleRate(ba8836b59fb42830).(rate); |
| 68 | } |
| 69 | |
| 70 | mainWin.showcxx . . $ QWidget#show(49f6e7a06ebc5aa8).(); |
| 71 | return a.execcxx . . $ QApplication#exec(b126dc7c1de90089).(); |
| 72 | } |