comparison src/main.cpp @ 370:b9c153e00e84

Move source files to src/
author Chris Cannam
date Thu, 24 Mar 2011 10:27:51 +0000
parents main.cpp@f649f6066e4d
children 110d1fefa073
comparison
equal deleted inserted replaced
369:19cce6d2c470 370:b9c153e00e84
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 EasyMercurial
5
6 Based on HgExplorer by Jari Korhonen
7 Copyright (c) 2010 Jari Korhonen
8 Copyright (c) 2011 Chris Cannam
9 Copyright (c) 2011 Queen Mary, University of London
10
11 This program is free software; you can redistribute it and/or
12 modify it under the terms of the GNU General Public License as
13 published by the Free Software Foundation; either version 2 of the
14 License, or (at your option) any later version. See the file
15 COPYING included with this distribution for more information.
16 */
17
18 #include "mainwindow.h"
19 #include "common.h"
20 #include "debug.h"
21
22 #include <QApplication>
23 #include <QTranslator>
24 #include <QDir>
25
26 int main(int argc, char *argv[])
27 {
28 QApplication app(argc, argv);
29
30 QApplication::setOrganizationName("easymercurial");
31 QApplication::setOrganizationDomain("easymercurial.org");
32 QApplication::setApplicationName(QApplication::tr("EasyMercurial"));
33
34 // Lose our controlling terminal (so we can provide a new pty to
35 // capture password requests)
36 loseControllingTerminal();
37
38 installSignalHandlers();
39
40 QTranslator translator;
41 QString language = QLocale::system().name();
42 QString trname = QString("easyhg_%1").arg(language);
43 translator.load(trname, ":");
44 app.installTranslator(&translator);
45
46 QStringList args = app.arguments();
47
48 QString myDirPath = QFileInfo(QDir::current().absoluteFilePath(args[0]))
49 .canonicalPath();
50
51 MainWindow mainWin(myDirPath);
52 mainWin.show();
53
54 if (args.size() == 2) {
55 QString path = args[1];
56 DEBUG << "Opening " << args[1] << endl;
57 if (QDir(path).exists()) {
58 path = QDir(path).canonicalPath();
59 mainWin.open(path);
60 }
61 }
62
63 return app.exec();
64 }