2013-09-09 08:59:03 +00:00
|
|
|
/* 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;
|
2013-09-22 15:30:25 +00:00
|
|
|
bool no_filenames = true;
|
2013-09-09 08:59:03 +00:00
|
|
|
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;
|
|
|
|
}
|
2013-09-22 15:30:25 +00:00
|
|
|
if (imported) {
|
2013-09-09 08:59:03 +00:00
|
|
|
importedFiles.push_back( QString(a) );
|
2013-09-22 15:30:25 +00:00
|
|
|
} else {
|
|
|
|
no_filenames = false;
|
2013-09-09 08:59:03 +00:00
|
|
|
files.push_back( QString(a) );
|
2013-09-22 15:30:25 +00:00
|
|
|
}
|
2013-09-09 08:59:03 +00:00
|
|
|
}
|
|
|
|
if (no_filenames) {
|
|
|
|
files.push_back( QString(prefs.default_filename) );
|
|
|
|
}
|
2013-09-09 09:20:10 +00:00
|
|
|
|
2013-09-09 08:59:03 +00:00
|
|
|
parse_xml_exit();
|
|
|
|
subsurface_command_line_exit(&argc, &argv);
|
|
|
|
mainWindow()->loadFiles(files);
|
|
|
|
mainWindow()->importFiles(importedFiles);
|
|
|
|
run_ui();
|
|
|
|
exit_ui();
|
|
|
|
return 0;
|
|
|
|
}
|