/* * MathPlanner 3.1 - Mathematical design tool. * Copyright(C) 2002 Jarmo Nikkanen * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation. * * You should have received a copy of the GNU General Public License with this program. * */ #include #include #include #include #include #include #include #include #include #include #include "Math.h" #include "Error.h" #include "Extern.h" #ifndef _INSTALL_DIR #define _INSTALL_DIR "/usr/local/share/MathPlanner" #endif #ifndef _DOC_DIR #define _DOC_DIR "" #endif QString image_path; QString home_path; QString install_dir; QString config_path; QString webbrowser; QString doc_dir; QString kde_dir; int bug_report; int main( int argc, char *argv[] ) { // CHECK THAT THERE IS A DISPLAY AVAILABLE if (getenv("DISPLAY")==NULL) { printf("Graphical display is required"); exit(-1); } // SETUP KDEDIR char *web=getenv("KDEDIR"); if (web) kde_dir=QString(web); else kde_dir=QString("/usr"); QApplication app(argc,argv); QFileInfo info(argv[0]); if (QString(argv[1]).contains("--debug")) bug_report=1; else bug_report=0; NBugReset(); // SETUP INSTALL DIRECTORIES doc_dir=QString(_DOC_DIR); install_dir=QString( _INSTALL_DIR ); home_path=QDir::home().path(); image_path=install_dir+QString("/pixmaps"); config_path=home_path+QString("/.MathPlanner"); // IF DOCDIR IS NOT DEFINED USE INSTALL DIRECTORY if (doc_dir.isEmpty()) doc_dir=install_dir; QTranslator translator( NULL ); translator.load(QString("mpl_")+QTextCodec::locale(), install_dir+"/ts"); app.installTranslator( &translator ); QDir dir(install_dir); if (dir.exists()==false) { QMessageBox::critical( 0, "MathPlanner", QObject::tr("Data directory not found:\n")+install_dir); exit(-1); } QDir cfg(config_path); if (cfg.exists()==false) { cfg.mkdir(config_path); // WE HAVE NEW USER } MathWindow *mathwindow=new MathWindow(QString(argv[1])); app.setMainWidget(mathwindow); mathwindow->showMaximized(); switch (mathwindow->Style()) { case 1: QLibrary resolve(QWindowsStyle); break; case 2: QLibrary resolve(QPlatinumStyle); break; case 3: QLibrary resolve(QMotifStyle); break; } // SETUP WEB BROWSER web=getenv("BROWSER"); if (web) webbrowser=QString(web); else webbrowser=mathwindow->Browser(); app.connect(&app,SIGNAL(aboutToQuit()),mathwindow,SLOT(Rescue())); return app.exec(); }