Debian Codegraph @

src/main.cpp

raw symbols SCIP
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"
24
25 int main(int argc, char *argv[])
26 {
27 QApplication a(argc, argv);
28 a.setApplicationName("inspectrum");
29 a.setOrganizationName("inspectrum");
30
31 MainWindow mainWin;
32
33 QCommandLineParser parser;
34 parser.setApplicationDescription("spectrum viewer");
35 parser.addHelpOption();
36 parser.addPositionalArgument("file", QCoreApplication::translate("main", "File to view."));
37
38 // Add options
39 QCommandLineOption rateOption(QStringList() << "r" << "rate",
40 QCoreApplication::translate("main", "Set sample rate."),
41 QCoreApplication::translate("main", "Hz"));
42 parser.addOption(rateOption);
43 QCommandLineOption formatOption(QStringList() << "f" << "format",
44 QCoreApplication::translate("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 QCoreApplication::translate("main", "fmt"));
46 parser.addOption(formatOption);
47
48 // Process the actual command line
49 parser.process(a);
50
51 // Check for file format override
52 if(parser.isSet(formatOption)){
53 mainWin.setFormat(parser.value(formatOption));
54 }
55
56 const QStringList args = parser.positionalArguments();
57 if (args.size()>=1)
58 mainWin.openFile(args.at(0));
59
60 if (parser.isSet(rateOption)) {
61 bool ok;
62 auto rate = parser.value(rateOption).toDouble(&ok);
63 if(!ok) {
64 fputs("ERROR: could not parse rate\n", stderr);
65 return 1;
66 }
67 mainWin.setSampleRate(rate);
68 }
69
70 mainWin.show();
71 return a.exec();
72 }