Debian Codegraph @

cmd/gvedit/main.cpp

raw
1 /**
2 * @file
3 * @brief gvedit - simple graph editor and viewer
4 */
5
6 /*************************************************************************
7 * Copyright (c) 2011 AT&T Intellectual Property
8 * All rights reserved. This program and the accompanying materials
9 * are made available under the terms of the Eclipse Public License v1.0
10 * which accompanies this distribution, and is available at
11 * https://www.eclipse.org/legal/epl-v10.html
12 *
13 * Contributors: Details at https://graphviz.org
14 *************************************************************************/
15
16 #include "config.h"
17
18 #ifdef _WIN32
19 #include "windows.h"
20 #endif
21 #include "mainwindow.h"
22 #include <QApplication>
23 #include <QCommandLineParser>
24 #include <QFile>
25 #include <common/globals.h>
26 #include <gvc/gvc.h>
27 #include <stdio.h>
28 #include <util/exit.h>
29
30 QTextStream errout(stderr, QIODevice::WriteOnly);
31
32 int main(int argc, char *argv[]) {
33 Q_INIT_RESOURCE(mdi);
34
35 QStringList files;
36 {
37 // Scoped QCoreApplication for when X11 DISPLAY is not available
38 QCoreApplication app(argc, argv);
39
40 QCommandLineParser parser;
41 parser.setApplicationDescription(
42 QStringLiteral("gvedit - simple graph editor and viewer"));
43 parser.addPositionalArgument(
44 QStringLiteral("files"),
45 QCoreApplication::translate("main", "files to open."),
46 QStringLiteral("[files...]"));
47
48 const QCommandLineOption helpOption(
49 {
50 QStringLiteral("?"),
51 QStringLiteral("h"),
52 QStringLiteral("help"),
53 },
54 QCoreApplication::translate("main",
55 "Displays help on commandline options."));
56 parser.addOption(helpOption);
57
58 const QCommandLineOption scaleInputBy72Option(
59 {
60 QStringLiteral("s"),
61 QStringLiteral("scale-input-by-72"),
62 },
63 QCoreApplication::translate("main", "Scale input by 72"));
64 parser.addOption(scaleInputBy72Option);
65
66 const QCommandLineOption verboseOption(
67 {
68 QStringLiteral("v"),
69 QStringLiteral("verbose"),
70 },
71 QCoreApplication::translate("main", "Verbose mode"));
72 parser.addOption(verboseOption);
73
74 if (!parser.parse(app.arguments())) {
75 parser.showHelp(1);
76 }
77
78 if (parser.isSet(helpOption)) {
79 parser.showHelp(0);
80 }
81
82 if (parser.isSet(scaleInputBy72Option)) {
83 PSinputscale = POINTS_PER_INCH;
84 }
85
86 if (parser.isSet(verboseOption)) {
87 Verbose = 1;
88 }
89
90 files = parser.positionalArguments();
91 }
92
93 QApplication app(argc, argv);
94
95 CMainWindow mainWin(files);
96 mainWin.show();
97 const int ret = app.exec();
98 graphviz_exit(ret);
99 }
100
101 /**
102 * @dir .
103 * @brief simple graph editor and viewer
104 */