]> Shamusworld >> Repos - architektonas/blobdiff - src/mainapp/main.cpp
In the middle of chasing down MDI not activating bug, renaming of Graphic to
[architektonas] / src / mainapp / main.cpp
index 3c0a154addb8199b70feae5b6beafe8c445d8580..5d5776981c33fd0e19b1764e5ca582d0994c970c 100644 (file)
@@ -3,7 +3,9 @@
 // Part of the Architektonas Project
 // Originally part of QCad Community Edition by Andrew Mustun
 // Extensively rewritten and refactored by James L. Hammons
-// (C) 2010 Underground Software
+// Portions copyright (C) 2001-2003 RibbonSoft
+// Copyright (C) 2010 Underground Software
+// See the README and GPLv2 files for licensing and warranty information
 //
 // JLH = James L. Hammons <jlhamm@acm.org>
 //
 
 QSplashScreen * splash = 0;
 
-#ifdef RS_SCRIPTING
+#ifdef SCRIPTING
 #include <qsproject.h>
 #endif
 
-#include "rs_fontlist.h"
-#include "rs_patternlist.h"
-#include "rs_scriptlist.h"
+#include "fontlist.h"
+#include "patternlist.h"
+#include "scriptlist.h"
 #include "settings.h"
-#include "rs_system.h"
-#include "rs_fileio.h"
-#include "rs_filtercxf.h"
-#include "rs_filterdxf.h"
-#include "rs_filterdxf1.h"
+#include "system.h"
+#include "fileio.h"
+#include "filtercxf.h"
+#include "filterdxf.h"
+#include "filterdxf1.h"
 
 #include "dlginitial.h"
 
-#include "qc_applicationwindow.h"
+#include "applicationwindow.h"
 
 #ifdef RS_CAM
-# include "rs_filtercam.h"
-# include "rs_camdialog.h"
+# include "filtercam.h"
+# include "camdialog.h"
 #endif
 
-//#ifdef RS_CAM
-//# include "xpm/intro_camexpert.xpm"
-//# include "xpm/splash_camexpert.xpm"
-//#else
-//# include "xpm/intro_qcad.xpm"
-//# ifndef QC_CUSTOM_SPLASH
-//#  include "xpm/splash_qcad.xpm"
-//# endif
-//#endif
-
 #ifndef QC_SPLASH_TXTCOL
 # define QC_SPLASH_TXTCOL Qt::black
 #endif
@@ -74,8 +66,8 @@ int main(int argc, char * argv[])
        // Init compiled-in resources
        Q_INIT_RESOURCE(architektonas);
 
-       RS_DEBUG->setLevel(RS_Debug::D_WARNING);
-       RS_DEBUG->print("param 0: %s", argv[0]);
+       DEBUG->setLevel(Debug::D_WARNING);
+       DEBUG->print("param 0: %s", argv[0]);
 
        // avoid . / , confusion on German environments
        setlocale(LC_ALL, "C");
@@ -84,19 +76,19 @@ int main(int argc, char * argv[])
 
        for(int i=0; i<app.argc(); i++)
                if (QString("--debug") == app.argv()[i])
-                       RS_DEBUG->setLevel(RS_Debug::D_DEBUGGING);
+                       DEBUG->setLevel(Debug::D_DEBUGGING);
 
        QFileInfo prgInfo(QFile::decodeName(argv[0]));
        QString prgDir(prgInfo.absolutePath());
-//fail RS_SYSTEM->init(QC_APPNAME, QC_VERSION, QC_APPDIR, prgDir);
-//     RS_SYSTEM->init("Architektonas", QC_VERSION, "qcad", prgDir);
-       RS_SYSTEM->init("Architektonas", QC_VERSION, "architektonas", prgDir);
+//fail SYSTEM->init(QC_APPNAME, QC_VERSION, QC_APPDIR, prgDir);
+//     SYSTEM->init("Architektonas", QC_VERSION, "qcad", prgDir);
+       SYSTEM->init("Architektonas", QC_VERSION, "architektonas", prgDir);
 
-       RS_FILEIO->registerFilter(new RS_FilterCXF());
-       RS_FILEIO->registerFilter(new RS_FilterDXF());
-       RS_FILEIO->registerFilter(new RS_FilterDXF1());
+       FILEIO->registerFilter(new FilterCXF());
+       FILEIO->registerFilter(new FilterDXF());
+       FILEIO->registerFilter(new FilterDXF1());
 #ifdef RS_OPT_CAM
-       RS_FILEIO->registerFilter(new RS_FilterCAM());
+       FILEIO->registerFilter(new FilterCAM());
 #endif
 
        // parse command line arguments that might not need a launched program:
@@ -114,18 +106,16 @@ int main(int argc, char * argv[])
 #endif
     settings.endGroup();
 
-       // show initial config dialog:
+       // Show initial config dialog if necessary:
        if (unit == "Invalid")
        {
-               RS_DEBUG->print("main: show initial config dialog..");
+               DEBUG->print("main: show initial config dialog..");
                DlgInitial di(NULL);
                di.setText("<font size=\"+1\"><b>Welcome to Architektonas</b></font>"
                "<br>"
                "Please choose the unit you want to use for new drawings and your "
                "preferred language.<br>"
                "You can changes these settings later in the Options Dialog of Architektonas.");
-//             QPixmap pxm(":/res/intro.xpm");
-//             di.setPixmap(pxm);
                di.setPixmap(QPixmap(":/res/intro.xpm"));
 
                if (di.exec())
@@ -135,41 +125,28 @@ int main(int argc, char * argv[])
                settings.endGroup();
                }
 
-               RS_DEBUG->print("main: show initial config dialog: OK");
+               DEBUG->print("main: show initial config dialog: OK");
        }
 
 #ifdef QSPLASHSCREEN_H
-       RS_DEBUG->print("main: splashscreen..");
-
-//# ifdef QC_CUSTOM_SPLASH
-//     QPixmap * pixmap = new QPixmap(qPixmapFromMimeSource(QC_CUSTOM_SPLASH));
-//# else
-////   QPixmap * pixmap = new QPixmap(":/res/splash.xpm");
-       QPixmap * pixmap = new QPixmap(":/res/splash_qcad.xpm");
-//# endif
+       DEBUG->print("main: splashscreen..");
 
-/*
-       splash = new QSplashScreen(*pixmap);
-       splash->show();
-       splash->message(app.tr("Loading.."),
-               Qt::AlignRight|Qt::AlignBottom, QC_SPLASH_TXTCOL);
-       RS_DEBUG->print("main: splashscreen: OK");
-*/
+       QPixmap * pixmap = new QPixmap(":/res/splash.png");
 #endif
 
-       RS_DEBUG->print("main: init fontlist..");
-    RS_FONTLIST->init();
-       RS_DEBUG->print("main: init fontlist: OK");
+       DEBUG->print("main: init fontlist..");
+    FONTLIST->init();
+       DEBUG->print("main: init fontlist: OK");
 
-       RS_DEBUG->print("main: init patternlist..");
-    RS_PATTERNLIST->init();
-       RS_DEBUG->print("main: init patternlist: OK");
+       DEBUG->print("main: init patternlist..");
+    PATTERNLIST->init();
+       DEBUG->print("main: init patternlist: OK");
 
-       RS_DEBUG->print("main: init scriptlist..");
-    RS_SCRIPTLIST->init();
-       RS_DEBUG->print("main: init scriptlist: OK");
+       DEBUG->print("main: init scriptlist..");
+    SCRIPTLIST->init();
+       DEBUG->print("main: init scriptlist: OK");
 
-       RS_DEBUG->print("main: loading translation..");
+       DEBUG->print("main: loading translation..");
        settings.beginGroup("Appearance");
 #ifdef QC_PREDEFINED_LOCALE
        lang = settings.value("Language", "").toString();
@@ -193,15 +170,15 @@ int main(int argc, char * argv[])
 #endif
        settings.endGroup();
 
-       RS_SYSTEM->loadTranslation(lang, langCmd);
-       RS_DEBUG->print("main: loading translation: OK");
+       SYSTEM->loadTranslation(lang, langCmd);
+       DEBUG->print("main: loading translation: OK");
 
 #ifdef QSPLASHSCREEN_H
        splash = new QSplashScreen(*pixmap);
        splash->show();
 //     splash->message(QObject::tr("Loading.."), Qt::AlignRight | Qt::AlignBottom, QC_SPLASH_TXTCOL);
        splash->showMessage(QObject::tr("Loading..."), Qt::AlignRight | Qt::AlignBottom, QC_SPLASH_TXTCOL);
-       RS_DEBUG->print("main: splashscreen: OK");
+       DEBUG->print("main: splashscreen: OK");
 #endif
 
        //QApplication::setStyle(new QWindowsStyle());
@@ -211,36 +188,36 @@ int main(int argc, char * argv[])
 #endif
 
 #ifdef QC_BUILTIN_STYLE //js:
-       RS_DEBUG->print("main: applying built in style..");
+       DEBUG->print("main: applying built in style..");
        applyBuiltinStyle();
 #endif
 
-       RS_DEBUG->print("main: creating main window..");
-    QC_ApplicationWindow * appWin = new QC_ApplicationWindow();
-       RS_DEBUG->print("main: setting caption");
+       DEBUG->print("main: creating main window..");
+    ApplicationWindow * appWin = new ApplicationWindow();
+       DEBUG->print("main: setting caption");
     appWin->setWindowTitle("Architektonas");
-       RS_DEBUG->print("main: show main window");
+       DEBUG->print("main: show main window");
     appWin->show();
-       RS_DEBUG->print("main: set focus");
+       DEBUG->print("main: set focus");
        appWin->setFocus();
-       RS_DEBUG->print("main: creating main window: OK");
+       DEBUG->print("main: creating main window: OK");
 
 #ifdef QSPLASHSCREEN_H
        if (splash)
        {
-               RS_DEBUG->print("main: updating splash..");
+               DEBUG->print("main: updating splash..");
 //             splash->message(QObject::tr("Loading Library Paths.."),
                splash->showMessage(QObject::tr("Loading Library Paths.."),
                        Qt::AlignRight | Qt::AlignBottom, QC_SPLASH_TXTCOL);
-               RS_DEBUG->print("main: processing events");
+               DEBUG->print("main: processing events");
                qApp->processEvents();
-               RS_DEBUG->print("main: updating splash: OK");
+               DEBUG->print("main: updating splash: OK");
        }
 #endif
 
        // loading files:
-       RS_DEBUG->print("main: loading files..");
-       bool files_loaded = false;
+       DEBUG->print("main: loading files..");
+       bool filesLoaded = false;
 
        for(QStringList::Iterator it=fileList.begin(); it!=fileList.end(); ++it)
        {
@@ -254,15 +231,10 @@ int main(int argc, char * argv[])
                }
 #endif
                        appWin->slotFileOpen(*it, RS2::FormatUnknown);
-                       files_loaded = true;
+                       filesLoaded = true;
        }
 
-       RS_DEBUG->print("main: loading files: OK");
-
-//none of this demo shit
-//#ifdef RS_DEMO
-//     QTimer::singleShot(10 * 60 * 1000, appWin, SLOT(slotFileDemoQuit()));
-//#endif
+       DEBUG->print("main: loading files: OK");
 
 #ifdef QSPLASHSCREEN_H
 # ifndef QC_DELAYED_SPLASH_SCREEN
@@ -276,15 +248,13 @@ int main(int argc, char * argv[])
        delete pixmap;
 #endif
 
-    //app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit()));
-
        // renew: avoid . / , confusion on German environments
        //setlocale(LC_NUMERIC, "C");
        setlocale(LC_ALL, "C");
 
-       RS_DEBUG->print("main: app.exec()");
+       DEBUG->print("main: app.exec()");
 
-       if (!files_loaded)
+       if (!filesLoaded)
                appWin->slotFileNew();
 
        appWin->slotRunStartScript();
@@ -293,7 +263,7 @@ int main(int argc, char * argv[])
 
        delete appWin;
 
-       RS_DEBUG->print("main: finished");
+       DEBUG->print("main: finished");
 
        return r;
 }
@@ -305,7 +275,7 @@ int main(int argc, char * argv[])
  */
 QStringList handleArgs(int argc, char * argv[])
 {
-       RS_DEBUG->print("main: handling args..");
+       DEBUG->print("main: handling args..");
        QStringList ret;
 
        bool doexit = false;
@@ -334,7 +304,7 @@ QStringList handleArgs(int argc, char * argv[])
                                machine = QString(argv[i]);
                        else
                        {
-                               RS_DEBUG->print(RS_Debug::D_WARNING, "No machine configuration given after --convert. Aborting..");
+                               DEBUG->print(Debug::D_WARNING, "No machine configuration given after --convert. Aborting..");
                                exit(1);
                        }
 
@@ -344,7 +314,7 @@ QStringList handleArgs(int argc, char * argv[])
                                input = QString(argv[i]);
                        else
                        {
-                               RS_DEBUG->print(RS_Debug::D_WARNING, "No input given after --convert. Aborting..");
+                               DEBUG->print(Debug::D_WARNING, "No input given after --convert. Aborting..");
                                exit(1);
                        }
 
@@ -354,7 +324,7 @@ QStringList handleArgs(int argc, char * argv[])
                                output = QString(argv[i]);
                        else
                        {
-                               RS_DEBUG->print(RS_Debug::D_WARNING, "No output given after --convert. Aborting..");
+                               DEBUG->print(Debug::D_WARNING, "No output given after --convert. Aborting..");
                                exit(1);
                        }
                }
@@ -365,9 +335,9 @@ QStringList handleArgs(int argc, char * argv[])
        // auto cam convert
        if (machine.isEmpty() == false && input.isEmpty() == false && output.isEmpty() == false)
        {
-               RS_FilterCAM fc;
-               RS_Graphic gr;
-               RS_FILEIO->fileImport(gr, input, RS2::FormatUnknown);
+               FilterCAM fc;
+               Drawing gr;
+               FILEIO->fileImport(gr, input, RS2::FormatUnknown);
                RS_CamDialog dlg(gr, NULL);
                dlg.activateMachineGenerator(machine);
                dlg.externalOK();
@@ -379,6 +349,6 @@ QStringList handleArgs(int argc, char * argv[])
        if (doexit)
                exit(0);
 
-       RS_DEBUG->print("main: handling args: OK");
+       DEBUG->print("main: handling args: OK");
        return ret;
 }