00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00049
00050
00051
00052
00053 #include <cstdlib>
00054 #include <ctime>
00055
00056
00057 #include <qapplication.h>
00058 #include <qfont.h>
00059 #include <qbitmap.h>
00060 #include <qimage.h>
00061 #include <qstring.h>
00062 #include <qtextcodec.h>
00063 #include <qgl.h>
00064
00065
00066 #include "iconsets.h"
00067 #include "xbrabo.h"
00068
00070 static void debugHandler(QtMsgType type, const char* message)
00074 {
00075 switch (type)
00076 {
00077 #ifndef QT_NO_DEBUG // only print out debug and warning messages in debug builds
00078 case QtDebugMsg: fprintf(stdout, "%s\n", message);
00079 break;
00080 case QtWarningMsg: fprintf(stderr, "Warning: %s\n", message);
00081 break;
00082 #endif
00083 case QtFatalMsg: fprintf(stderr, "FATAL: %s\n", message);
00084 fprintf(stderr, "Please note the exact message when reporting this.\n");
00085 fprintf(stderr, "The application will now shut down.\n");
00086 abort();
00087 default:
00088 break;
00089 }
00090 }
00091
00093 int main(int argc, char *argv[])
00095 {
00096 qInstallMsgHandler(debugHandler);
00097 QApplication app(argc, argv);
00098
00099 if (!QGLFormat::hasOpenGL())
00100 qFatal("This system has no working OpenGL support. Exiting...");
00101
00103 bool showSplash = true;
00104 for(int i = 1; i < argc; i++)
00105 {
00106 if(QString(argv[i]).contains("-nosplash"))
00107 {
00108 showSplash = false;
00109 break;
00110 }
00111 }
00113 QWidget* splash = NULL;
00114 if(showSplash)
00115 {
00116
00117
00118 splash = new QWidget(0, 0, Qt::WStyle_Customize | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop | Qt::WX11BypassWM);
00119 QPixmap pm(IconSets::getSplash());
00120 splash->resize(pm.size());
00121 splash->setBackgroundPixmap(pm);
00122 if(pm.mask())
00123 splash->setMask(*pm.mask());
00124 QRect screenRect = app.desktop()->availableGeometry(app.desktop()->primaryScreen());
00125 splash->move(screenRect.width()/2 - 309, screenRect.height()/2 - 193);
00126 splash->show();
00127 }
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138 srand(time(NULL));
00139
00140 Xbrabo* xbrabo = new Xbrabo();
00141 app.setMainWidget(xbrabo);
00142 if(showSplash)
00143 {
00144 xbrabo->show();
00145 app.processEvents();
00146 }
00147 xbrabo->init();
00148 if(showSplash)
00149 app.processEvents();
00151 for(int i = 1; i < argc; i++)
00152 {
00153 if(QString(argv[i]).right(4) == ".cml")
00154 {
00155 xbrabo->fileOpen(QString(argv[i]));
00156 if(showSplash)
00157 app.processEvents();
00158 }
00159 }
00160 if(showSplash)
00161 splash->deleteLater();
00162
00163 return app.exec();
00164 }
00165