This repository has been archived by the owner on Aug 25, 2020. It is now read-only.
/
main.cpp
89 lines (72 loc) · 1.93 KB
/
main.cpp
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#include <QLocale>
#include <locale>
#ifdef QT_VERSION_5
#include <QtGui/QGuiApplication>
#else
#include <QtGui/QApplication>
#endif
#include "simulationcraftqt.hpp"
#ifndef SIMC_NO_AUTOUPDATE
#include "sc_autoupdate.h"
#endif /* SIMC_NO_AUTOUPDATE */
int main( int argc, char *argv[] )
{
QLocale::setDefault( QLocale( "C" ) );
std::locale::global( std::locale( "C" ) );
setlocale( LC_ALL, "C" );
thread_t::init();
QApplication a( argc, argv );
#ifndef SIMC_NO_AUTOUPDATE
AutoUpdater* updater = 0;
#ifdef Q_WS_MAC
CocoaInitializer cocoaInitializer;
updater = new SparkleAutoUpdater( "http://simc.rungie.com/simcqt/update.xml" );
#endif
if ( updater )
{
updater->checkForUpdates();
}
#endif /* SIMC_NO_AUTOUPDATE */
#ifdef Q_WS_MAC
QDir::home().mkpath( "Library/Application Support/simcqt" );
QDir::setCurrent( QDir::home().absoluteFilePath( "Library/Application Support/simcqt" ) );
#endif
// Setup search paths for resources
{
QString appDirPath = a.applicationDirPath();
QDir::addSearchPath( "icon", ":/icons/" );
QDir::addSearchPath( "icon", QString( "%1/../Resources/" ).arg( appDirPath ) );
QDir::addSearchPath( "icon", QString( "%1/qt/icons/" ).arg( appDirPath ) );
QDir::addSearchPath( "icon", "./qt/icons/" );
}
SimulationCraftWindow w;
if ( w.historyWidth != 0 &&
w.historyHeight != 0 )
{
w.resize( w.historyWidth, w.historyHeight );
}
if ( w.historyMaximized )
{
w.showMaximized();
}
else
{
w.showNormal();
}
w.setWindowTitle( "SimulationCraft " + QString( SC_MAJOR_VERSION ) + "-" + QString( SC_MINOR_VERSION ) );
w.cmdLine->setFocus();
if ( argc > 1 )
{
for ( int i=1; i < argc; i++ )
{
QFile file( argv[ i ] );
if ( file.open( QIODevice::ReadOnly ) )
{
w.simulateText->appendPlainText( file.readAll() );
file.close();
}
}
w.mainTab->setCurrentIndex( TAB_SIMULATE );
}
return a.exec();
}