forked from anak10thn/ignsdk-qt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
109 lines (102 loc) · 3.44 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <QtGui/QApplication>
#include "ign.h"
#include <QtWebKit/QWebView>
#include <iostream>
#include <getopt.h>
using namespace std;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
ign w;
static int verbose_flag;
char *url = NULL;
char *optional = NULL;
bool dev = false;
bool file = false;
int index;
int c;
bool version = false;
char help[] = "Usage: ignsdk -p [PROJECT DIRECTORY]\n\nGeneral Options :\n--version\toutput version information and exit\n--dev\t\tWeb Inspector Enable\n\nWindow options :\n--transparent\tTransparent Mode\n--noFrame\tFrame Disable\n";
opterr = 0;
static struct option long_options[] =
{
{"verbose", no_argument, &verbose_flag, 1},
{"brief", no_argument, &verbose_flag, 0},
{"dev", no_argument, 0, 'd'},
{"file", required_argument, 0, 'f'},
{"transparent", no_argument, 0, 't'},
{"noFrame", no_argument, 0, 'n'},
{"help", no_argument, 0, 'h'},
{"project", required_argument, 0, 'p'},
{"version", no_argument, 0, 'v'},
{0, 0, 0, 0}
};
int option_index = 0;
while ((c = getopt_long (argc, argv, "vdnhf:tp:",long_options,&option_index)) != -1){
switch (c)
{
case 'p':
url = optarg;
break;
case 'd':
dev = true;
w.setDev(dev);
break;
case 'f':
file = true;
optional = optarg;
break;
case 'n':
w.widgetNoFrame();
break;
case 't':
w.widgetTransparent();
break;
case 'v':
version = true;
break;
case 'h':
printf("%s\n",help);
exit(0);
break;
case '?':
if (optopt == 'c')
fprintf (stderr, "Option -%c requires an argument.\n", optopt);
else if (isprint (optopt))
fprintf (stderr, "Unknown option `-%c'.\n\nUsage: ignsdk -p [PROJECT DIRECTORY]\n\nGeneral Options :\n--version\toutput version information and exit\n--dev\t\tWeb Inspector Enable\n\nWindow options :\n--transparent\tTransparent Mode\n--noFrame\tFrame Disable\n", optopt);
else
fprintf (stderr,
"Unknown option character `\\x%x'.\n",
optopt);
return 1;
default:
abort ();
}
}
for (index = optind; index < argc; index++){
printf ("Non-option argument %s\n", argv[index]);
}
if(version){
qDebug() << "IGNSDK Version : "<< w.sdkVersion();
exit(0);
}
QString opt = url;
if(opt.isEmpty()){
w.render("http://www.igos-nusantara.or.id");
}
else{
w.pathApp = opt;
if(file){
opt += "/";
opt += optional;
}
else {
opt += "/index.html";
}
w.render(opt);
w.config(url);
}
w.show();
return a.exec();
}