aboutsummaryrefslogtreecommitdiffstats
path: root/main.cpp
blob: 98907ca8d6401d2c17141067eab499a1e03ff3a9 (plain) (blame)
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
/* main.c */
#include <locale.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <libintl.h>

#include "qt-gui.h"
#include "version.h"
#include "subsurfacestartup.h"
#include "qt-ui/mainwindow.h"

#include <QStringList>

int main(int argc, char **argv)
{
	int i;
	bool no_filenames = true;
	const char *path;

	/* set up l18n - the search directory needs to change
	 * so that it uses the correct system directory when
	 * subsurface isn't run from the local directory */
	path = subsurface_gettext_domainpath(argv[0]);
	setlocale(LC_ALL, "");
	bindtextdomain("subsurface", path);
	bind_textdomain_codeset("subsurface", "utf-8");
	textdomain("subsurface");

	setup_system_prefs();
	prefs = default_prefs;

	subsurface_command_line_init(&argc, &argv);
	init_ui(&argc, &argv);
	parse_xml_init();

	QStringList files;
	QStringList importedFiles;
	for (i = 1; i < argc; i++) {
		const char *a = argv[i];
		if (a[0] == '-') {
			parse_argument(a);
			continue;
		}
		if (imported) {
			importedFiles.push_back( QString(a) );
		} else {
			no_filenames = false;
			files.push_back( QString(a) );
		}
	}
	if (no_filenames) {
		files.push_back( QString(prefs.default_filename) );
	}

	parse_xml_exit();
	subsurface_command_line_exit(&argc, &argv);
	mainWindow()->loadFiles(files);
	mainWindow()->importFiles(importedFiles);
	run_ui();
	exit_ui();
	return 0;
}