X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=gui%2Fmain.cpp;h=121e323a3344f4dae5a8d827afad3d7977888d16;hb=7257dfcc57b3a1af576a8a2ca69992ae8d77dea4;hp=bee35d370ce89fcb28bca3cb2be34ebab59f4227;hpb=f6667d1331849a8534ead1c653ab4a1aeaeddcc8;p=apitrace diff --git a/gui/main.cpp b/gui/main.cpp index bee35d3..121e323 100644 --- a/gui/main.cpp +++ b/gui/main.cpp @@ -1,24 +1,99 @@ #include "mainwindow.h" +#include "apitrace.h" #include "apitracecall.h" +#include "os_string.hpp" +#include "os_process.hpp" + #include #include #include +#include + +#include Q_DECLARE_METATYPE(QList); +Q_DECLARE_METATYPE(QVector); +Q_DECLARE_METATYPE(Qt::CaseSensitivity); +Q_DECLARE_METATYPE(ApiTrace::SearchResult); +Q_DECLARE_METATYPE(ApiTrace::SearchRequest); +Q_DECLARE_METATYPE(QList); + +static void usage(void) +{ + qWarning("usage: qapitrace [options] [TRACE] [CALLNO]\n" + "Valid options include:\n" + " -h, --help Print this help message\n" + " --remote-target HOST Replay trace on remote target HOST\n"); +} int main(int argc, char **argv) { + QApplication::setGraphicsSystem("raster"); QApplication app(argc, argv); qRegisterMetaType >(); - MainWindow window; + qRegisterMetaType >(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType(); + qRegisterMetaType >(); +#ifndef Q_OS_WIN + os::String currentProcess = os::getProcessName(); + currentProcess.trimFilename(); + QString path = qgetenv("PATH"); + path = QLatin1String(currentProcess.str()) + QLatin1String(":") + path; + qputenv("PATH", path.toLatin1()); +#endif + + QStringList args = app.arguments(); + QString remoteTarget; + + int i = 1; + while (i < args.count()) { + QString arg = args[i]; + if (arg[0] != QLatin1Char('-')) { + break; + } + ++i; + if (arg == QLatin1String("--")) { + break; + } else if (arg == QLatin1String("--remote-target")) { + if (i == args.count()) { + qWarning("Option --remote-target requires an argument.\n"); + exit(1); + } + remoteTarget = args[i]; + ++i; + } else if (arg == QLatin1String("-h") || + arg == QLatin1String("--help")) { + usage(); + exit(0); + } else { + usage(); + exit(1); + } + } + + MainWindow window; window.show(); - if (app.arguments().count() == 2) - window.loadTrace(app.arguments()[1]); + if (i < args.count()) { + QString fileName = args[i++]; + + int callNum = -1; + if (i < args.count()) { + callNum = args[i++].toInt(); + } + window.loadTrace(fileName, callNum); + } + + if (remoteTarget.length()) { + window.setRemoteTarget(remoteTarget); + } app.exec(); }