void IQmolApplication::initOpenBabel() { QDir dir(QApplication::applicationDirPath()); dir.cdUp(); QString path(dir.absolutePath()); #ifdef Q_WS_MAC // Assumed directory structure: IQmol.app/Contents/MacOS/IQmol QApplication::addLibraryPath(path + "/Frameworks"); QApplication::addLibraryPath(path + "/PlugIns"); #else // Assumed directory structure: IQmol-xx/bin/IQmol QApplication::addLibraryPath(path + "/lib"); QApplication::addLibraryPath(path + "/lib/plugins"); #endif #ifdef Q_OS_LINUX return; #endif QString env(qgetenv("BABEL_LIBDIR")); if (env.isEmpty()) { env = path + "/lib/openbabel"; qputenv("BABEL_LIBDIR", env.toAscii()); QLOG_INFO() << "Setting BABEL_LIBDIR = " << env; }else { QLOG_INFO() << "BABEL_LIBDIR already set: " << env; } env = qgetenv("BABEL_DATADIR"); if (env.isEmpty()) { env = path + "/share/openbabel"; qputenv("BABEL_DATADIR", env.toAscii()); QLOG_INFO() << "Setting BABEL_DATADIR = " << env; }else { QLOG_INFO() << "BABEL_DATADIR already set: " << env; } #ifdef Q_WS_WIN QLibrary openBabel("libopenbabel.dll"); #else QLibrary openBabel("openbabel"); #endif if (!openBabel.load()) { QString msg("Could not load library "); msg += openBabel.fileName(); QLOG_ERROR() << msg << " " << openBabel.errorString(); QLOG_ERROR() << "Library Paths:"; QLOG_ERROR() << libraryPaths(); msg += "\n\nPlease ensure the OpenBabel libraries have been installed correctly"; QMsgBox::critical(0, "IQmol", msg); QApplication::quit(); return; } }
XCA_application::XCA_application(int &argc, char *argv[]) :QApplication(argc, argv) { qtTr = NULL; xcaTr = NULL; mainw = NULL; QFile file(getUserSettingsDir() + QDir::separator() + "defaultlang"); if (file.open(QIODevice::ReadOnly)) { lang = QLocale(QString(file.read(128))); } langAvail << QLocale::system(); langAvail << QString("en"); QDirIterator qmIt(getPrefix(), QStringList() << "*.qm", QDir::Files); while (qmIt.hasNext()) { XcaTranslator t; qmIt.next(); QString language = qmIt.fileInfo().baseName().mid(4, -1); if (t.load(language, "xca", getPrefix())) langAvail << QLocale(language); } setupLanguage(lang); #ifdef Q_OS_MAC QStringList libp = libraryPaths(); libp.prepend(applicationDirPath() + "/../Plugins"); setLibraryPaths(libp); #endif tableFont = QFont("Courier", QApplication::font().pointSize() #if defined (Q_OS_WIN32) +1 #else +2 #endif ); installEventFilter(this); }