File indexing completed on 2024-12-22 04:17:24
0001 /*************************************************************************** 0002 * * 0003 * copyright : (C) 2007 The University of Toronto * 0004 * netterfield@astro.utoronto.ca * 0005 * * 0006 * This program is free software; you can redistribute it and/or modify * 0007 * it under the terms of the GNU General Public License as published by * 0008 * the Free Software Foundation; either version 2 of the License, or * 0009 * (at your option) any later version. * 0010 * * 0011 ***************************************************************************/ 0012 0013 #include "application.h" 0014 0015 #include "builtinprimitives.h" 0016 #include "builtindatasources.h" 0017 #include "builtinobjects.h" 0018 #include "builtingraphics.h" 0019 #include "builtinrelations.h" 0020 0021 #include "datagui.h" 0022 #include "datacollection.h" 0023 #include "dialoglaunchergui.h" 0024 #include "datasource.h" 0025 #include "dialogdefaults.h" 0026 #include "datasourcepluginmanager.h" 0027 //#include "dialogscriptinterface.h" 0028 #include "settings.h" 0029 #include "geticon.h" 0030 0031 0032 #include <QIcon> 0033 0034 0035 namespace Kst { 0036 0037 Application::Application(int &argc, char **argv) 0038 : QApplication(argc, argv) { 0039 0040 QCoreApplication::setApplicationName("Kst"); 0041 setWindowIcon(KstGetIcon("kst")); 0042 0043 0044 // get the Username from the OS. On windows this is USERNAME and on linux, USER. 0045 #ifdef Q_OS_WIN 0046 _userName = qgetenv("USERNAME"); 0047 if (_userName.isEmpty()) {// hmmm... something odd. 0048 _userName = qgetenv("USER"); 0049 } 0050 #else 0051 _userName = qgetenv("USER"); 0052 if (_userName.isEmpty()) { // hmmm... something odd. 0053 _userName = qgetenv("USERNAME"); 0054 } 0055 #endif 0056 if (_userName.isEmpty()) { 0057 _userName = "kst"; 0058 } 0059 0060 0061 Builtins::initPrimitives(); //libkst 0062 Builtins::initDataSources(); //libkstapp 0063 Builtins::initObjects(); //libkstmath 0064 Builtins::initRelations(); //libkstmath 0065 Builtins::initGraphics(); //libkstapp 0066 0067 //Replace the data singleton with one that actually works 0068 Data::replaceSelf(new DataGui); 0069 0070 //Replace the dialoglauncher singleton with one that actually works 0071 DialogLauncher::replaceSelf(new DialogLauncherGui); 0072 0073 //Also give us dialog-script scripting functionality 0074 //DialogLauncherSI::self = new DialogLauncherSI; 0075 0076 //_mainWindow->show(); 0077 //_mainWindow->hide(); 0078 } 0079 0080 void Application::initMainWindow() { 0081 _mainWindow = new MainWindow; 0082 connect(this, SIGNAL(aboutToQuit()), _mainWindow, SLOT(aboutToQuit())); 0083 } 0084 0085 Application::~Application() { 0086 // lets not clean up before we leave.... 0087 // if we do, we'll end up crashing on exit 0088 // unless we fix some stuff related to destruction 0089 delete _mainWindow; 0090 deleteAllSettings(); 0091 } 0092 0093 0094 MainWindow *Application::mainWindow() const { 0095 return _mainWindow; 0096 } 0097 0098 } 0099 0100 // vim: ts=2 sw=2 et