00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifdef HAVE_CONFIG_H
00023 #include <config.h>
00024 #endif
00025
00026 #include "omgmainwindow.h"
00027 #include "omgtermsandconditions.h"
00028 #include "omgui.h"
00029 #include <stdio.h>
00030 #include <stdlib.h>
00031
00032 #include <QApplication>
00033 #include <QBitmap>
00034 #include <QDir>
00035 #include <QPixmap>
00036 #include <QPlastiqueStyle>
00037 #include <QSettings>
00038 #include <QString>
00039 #include <QStyle>
00040 #include <QSettings>
00041 #include <QTextCodec>
00042 #include <QLocale>
00043 #include <QTranslator>
00044 #include <QImageReader>
00045
00046 #include <cpl_conv.h>
00047
00048
00049 #ifdef WITH_QGIS
00050
00051
00052
00053 #include <qgsapplication.h>
00054 #endif
00055
00056 #if STATIC_BUILD
00057 #include <QtCore/QtPlugin>
00058 Q_IMPORT_PLUGIN(qjpeg)
00059 Q_IMPORT_PLUGIN(qsvg)
00060 #endif
00061
00062 #ifdef Q_OS_MACX
00063
00064 #include <ApplicationServices/ApplicationServices.h>
00065 #endif
00066
00067
00068 int main(int argc, char *argv[])
00069 {
00070 #ifdef WITH_QGIS
00071 QgsApplication myApp(argc,argv,true);
00072
00073 #else
00074 QApplication myApp(argc,argv);
00075 #endif
00076
00077
00078 QCoreApplication::setOrganizationName("openModeller");
00079 QCoreApplication::setOrganizationDomain("openmodeller.sf.net");
00080 QCoreApplication::setApplicationName("OpenModellerGui");
00081
00082
00083
00084
00085
00086 #ifdef Q_WS_WIN
00087 QApplication::addLibraryPath( QApplication::applicationDirPath()
00088 + QDir::separator() + "plugins" );
00089 #endif
00090 #ifdef Q_OS_MACX
00091 qDebug("Adding qt image plugins to plugin search path...");
00092 CFURLRef myBundleRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
00093 CFStringRef myMacPath = CFURLCopyFileSystemPath(myBundleRef, kCFURLPOSIXPathStyle);
00094 const char *mypPathPtr = CFStringGetCStringPtr(myMacPath,CFStringGetSystemEncoding());
00095 CFRelease(myBundleRef);
00096 CFRelease(myMacPath);
00097 QString myPath(mypPathPtr);
00098
00099
00100
00101
00102 if (myPath.contains(".app"))
00103 {
00104 QString myPluginPath = myPath + "/Contents/plugins";
00105 QApplication::addLibraryPath( myPluginPath );
00106 qDebug( "Added %s to plugin search path", qPrintable( myPluginPath ) );
00107
00108
00109
00110 QString myGdalDataPath = myPath + "/Contents/MacOS/share";
00111 CPLSetConfigOption("GDAL_DATA", myGdalDataPath.toLocal8Bit());
00112
00113 if( CPLGetConfigOption("GDAL_DATA",NULL) != NULL )
00114 {
00115 myGdalDataPath = QString(CPLGetConfigOption("GDAL_DATA",NULL));
00116 qDebug("GDAL_DATA set to :" + myGdalDataPath.toLocal8Bit());
00117 }
00118 else
00119 {
00120 qDebug("Warning GDAL_DATA is not set and thus projections");
00121 qDebug("may not work properly...");
00122 }
00123 }
00124 #endif
00125
00126
00127
00128
00129
00130
00131 #ifdef Q_WS_WIN
00132 myApp.setPluginPath(myApp.applicationDirPath() + QDir::separator() +
00133 "lib" + QDir::separator() + "qgis");
00134 myApp.setPkgDataPath(myApp.applicationDirPath() + QDir::separator() +
00135 "share" + QDir::separator() + "qgis");
00136
00137 #endif
00138 qDebug("srs path:" + myApp.srsDbFilePath().toLocal8Bit());
00139
00140 QImageReader::supportedImageFormats();
00141 #ifdef Q_WS_WIN
00142
00143 QApplication::setStyle(new QPlastiqueStyle);
00144 #endif
00145
00146
00147 QApplication::addLibraryPath(QApplication::applicationDirPath());
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158 QSettings mySettings;
00159 QString mySystemLocale = QLocale::languageToString(QLocale::system().language());
00160 QString myUserLocale = mySettings.value("locale/userLocale", "").toString();
00161 bool myLocaleOverrideFlag = mySettings.value("locale/overrideFlag",false).toBool();
00162 QString myI18nPath = Omgui::i18nPath();
00163 QString myLocale;
00164 if (!myLocaleOverrideFlag || myUserLocale.isEmpty())
00165 {
00166 myLocale = QTextCodec::locale();
00167 }
00168 else
00169 {
00170 myLocale = myUserLocale;
00171 }
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181 QTranslator myQtTranslator(0);
00182 if (myQtTranslator.load(QString("qt_") + myLocale, myI18nPath))
00183 {
00184 myApp.installTranslator(&myQtTranslator);
00185
00186 }
00187
00188
00189
00190 QTranslator myOmgTranslator(0);
00191 if (myOmgTranslator.load(QString("openModellerDesktop_") + myLocale, myI18nPath))
00192 {
00193 myApp.installTranslator(&myOmgTranslator);
00194
00195 }
00196
00197
00198
00199
00200 OmgMainWindow * mypOmg = new OmgMainWindow();
00201 if (mySettings.value("licensing/termsAgreedFlag",false).toBool()!=true)
00202 {
00203 OmgTermsAndConditions myTerms;
00204 if (myTerms.exec()!=QDialog::Accepted)
00205 {
00206 return false;
00207 }
00208 }
00209 mypOmg->show();
00210
00211
00212
00213 return myApp.exec();
00214
00215 }
00216