annotate src/main.cpp @ 665:88061103b878

Build fix
author Chris Cannam
date Wed, 23 Mar 2016 14:49:49 +0000
parents ae67ea0af696
children 751b21af6b6f
rev   line source
Chris@57 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@57 2
Chris@57 3 /*
Chris@57 4 EasyMercurial
Chris@57 5
Chris@57 6 Based on HgExplorer by Jari Korhonen
Chris@57 7 Copyright (c) 2010 Jari Korhonen
Chris@644 8 Copyright (c) 2013 Chris Cannam
Chris@644 9 Copyright (c) 2013 Queen Mary, University of London
Chris@57 10
Chris@57 11 This program is free software; you can redistribute it and/or
Chris@57 12 modify it under the terms of the GNU General Public License as
Chris@57 13 published by the Free Software Foundation; either version 2 of the
Chris@57 14 License, or (at your option) any later version. See the file
Chris@57 15 COPYING included with this distribution for more information.
Chris@57 16 */
jtkorhonen@0 17
jtkorhonen@0 18 #include "mainwindow.h"
Chris@78 19 #include "common.h"
Chris@78 20 #include "debug.h"
Chris@643 21 #include "version.h"
jtkorhonen@0 22
Chris@145 23 #include <QApplication>
Chris@155 24 #include <QTranslator>
Chris@145 25 #include <QDir>
Chris@145 26
Chris@643 27 using std::cout;
Chris@643 28 using std::endl;
Chris@643 29
jtkorhonen@0 30 int main(int argc, char *argv[])
jtkorhonen@0 31 {
Chris@643 32 if (argc == 2 &&
Chris@643 33 (!strcmp(argv[1], "-v") ||
Chris@643 34 !strcmp(argv[1], "--version"))) {
Chris@643 35 cout << "EasyMercurial v" << EASYHG_VERSION << "\n"
Chris@643 36 << "Copyright (c) 2010 Jari Korhonen\n"
Chris@644 37 << "Copyright (c) 2013 Chris Cannam\n"
Chris@644 38 << "Copyright (c) 2013 Queen Mary, University of London\n"
Chris@643 39 << "This program is free software; you can redistribute it and/or\n"
Chris@643 40 << "modify it under the terms of the GNU General Public License as\n"
Chris@643 41 << "published by the Free Software Foundation; either version 2 of the\n"
Chris@643 42 << "License, or (at your option) any later version. See the file\n"
Chris@643 43 << "COPYING included with this distribution for more information."
Chris@643 44 << endl;
Chris@643 45 return 0;
Chris@643 46 }
Chris@643 47
Chris@256 48 QApplication app(argc, argv);
Chris@256 49
Chris@61 50 QApplication::setOrganizationName("easymercurial");
Chris@61 51 QApplication::setOrganizationDomain("easymercurial.org");
Chris@61 52 QApplication::setApplicationName(QApplication::tr("EasyMercurial"));
jtkorhonen@0 53
Chris@462 54 #ifdef Q_OS_MAC
Chris@462 55 // Mac doesn't align menu labels when icons are shown: result is messy
Chris@462 56 app.setAttribute(Qt::AA_DontShowIconsInMenus);
Chris@462 57 #endif
Chris@462 58
Chris@78 59 // Lose our controlling terminal (so we can provide a new pty to
Chris@78 60 // capture password requests)
Chris@78 61 loseControllingTerminal();
Chris@78 62
Chris@105 63 installSignalHandlers();
Chris@105 64
Chris@155 65 QTranslator translator;
Chris@155 66 QString language = QLocale::system().name();
Chris@493 67 if (language == "C") language = "en";
Chris@155 68 QString trname = QString("easyhg_%1").arg(language);
Chris@155 69 translator.load(trname, ":");
Chris@155 70 app.installTranslator(&translator);
Chris@155 71
Chris@145 72 QStringList args = app.arguments();
Chris@172 73
Chris@172 74 QString myDirPath = QFileInfo(QDir::current().absoluteFilePath(args[0]))
Chris@172 75 .canonicalPath();
Chris@172 76
Chris@172 77 MainWindow mainWin(myDirPath);
jtkorhonen@0 78 mainWin.show();
Chris@145 79
Chris@145 80 if (args.size() == 2) {
Chris@145 81 QString path = args[1];
Chris@145 82 DEBUG << "Opening " << args[1] << endl;
Chris@145 83 if (QDir(path).exists()) {
Chris@145 84 path = QDir(path).canonicalPath();
Chris@145 85 mainWin.open(path);
Chris@145 86 }
Chris@145 87 }
Chris@145 88
jtkorhonen@0 89 return app.exec();
jtkorhonen@0 90 }