Debian Codegraph @

src/main.cpp

raw symbols SCIP
1 /***************************************************************************
2 * Copyright (C) 2009 by The qGo Project *
3 * *
4 * This file is part of qGo. *
5 * *
6 * qGo is free software: you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, see <http://www.gnu.org/licenses/> *
18 * or write to the Free Software Foundation, Inc., *
19 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
20 ***************************************************************************/
21
22
23 #include <QApplication>
24
25 #include "mainwindow.h"
26 #include "defines.h"
27
28
29 struct _preferences preferences;
30 MainWindow * mainwindow = 0;
31 ConnectionWidget * connectionWidget = 0;
32
33 void startqGo(void)
34 {
35 QSettings settings;
36 bool restarting = false;
37
38 if(mainwindow)
39 {
40 restarting = true;
41 mainwindow->deleteLater();
42 }
43 mainwindow = new MainWindow(0,0);
44 if(restarting)
45 mainwindow->show();
46
47 QVariant main_window_size_x = settings.value("MAIN_WINDOW_SIZE_X");
48 if(main_window_size_x != QVariant())
49 {
50 mainwindow->resize(main_window_size_x.toInt(), settings.value("MAIN_WINDOW_SIZE_Y").toInt());
51 mainwindow->move(settings.value("MAIN_WINDOW_POS_X").toInt(), settings.value("MAIN_WINDOW_POS_Y").toInt());
52 }
53 }
54
55 int main(int argc, char *argv[])
56 {
57 Q_INIT_RESOURCE(application);
58 QApplication * app = new QApplication(argc, argv);
59
60 QTranslator qtTranslator;
61 if (qtTranslator.load(QLocale(), "qt", "_",
62 QLibraryInfo::location(QLibraryInfo::TranslationsPath)))
63 app->installTranslator(&qtTranslator);
64 else
65 qDebug() << "qgo translation file for locale " << QLocale() << " not found in " << QLibraryInfo::location(QLibraryInfo::TranslationsPath)+"/translations";
66
67 QTranslator qgoTranslator;
68 if (qgoTranslator.load(QLocale(), "qgo", "_",
69 QCoreApplication::applicationDirPath()+"/translations"))
70 app->installTranslator(&qgoTranslator);
71 else
72 qDebug() << "qgo translation file for locale " << QLocale() << " not found in " << QCoreApplication::applicationDirPath()+"/translations";
73
74 app->setOrganizationName("qGo");
75 app->setApplicationName("qGo");
76
77 QCommandLineParser parser;
78 parser.process(*app);
79 const QStringList args = parser.positionalArguments();
80
81 startqGo();
82 mainwindow->show();
83
84 QStringList::const_iterator filename;
85 for ( filename = args.begin(); filename != args.end(); ++filename )
86 {
87 mainwindow->openSGF(*filename);
88 }
89
90 srand(time(NULL));
91
92 return app->exec();
93 }