Example #1
0
int read_doumlrc()
{
    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings");
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    int id = settings.value("Main/id", -1).toInt();
    set_manual_dir(settings.value("Main/manual", "").toString());
    set_navigator_path(settings.value("Main/navigator", "").toString());
    set_editor(settings.value("Main/editor", "").toString());
    set_template_project(settings.value("Main/template", "").toString());
    set_lang(settings.value("Main/lang").toString());
    QString s = settings.value("Main/encoding", "UTF-8").toString();
    set_codec(s);
    QTextCodec::setCodecForTr(QTextCodec::codecForName(s));
    QTextCodec::setCodecForLocale(QTextCodec::codecForName(s));
    int l, t, r, b;
    l = settings.value("Desktop/left", -1).toInt();
    r = settings.value("Desktop/right", -1).toInt();
    t = settings.value("Desktop/top", -1).toInt();
    b = settings.value("Desktop/bottom", -1).toInt();
    if(l != -1 && r != -1 && t != -1 && b != -1)
    {
      UmlDesktop::set_limits(l, t, r, b);
    }
    else
    {
      UmlDesktop::set_limits(0, 0, 0, 0);
    }

    if (id == -1) {
        QMessageBox::critical(0, "Douml", TR("Own identifier missing or invalid"));
        EnvDialog::edit(FALSE, TRUE);
        return read_doumlrc();
    }

    return id;
}
Example #2
0
int main(int argc, char ** argv)
{

    ExitOnError = FALSE;

    QApplication a(argc, argv);

    QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8"));

//#ifdef DEBUG
    QsLogging::Logger & logger = QsLogging::Logger::instance();
    logger.setLoggingLevel(QsLogging::TraceLevel);
    QDir dir;
    dir.setPath(qApp->applicationDirPath());
    dir.remove(QString("douml") + QString(".log"));
    const QString sLogPath(QDir(qApp->applicationDirPath()).filePath(QString("douml") + QString(".log")));
    QsLogging::DestinationPtr fileDestination(QsLogging::DestinationFactory::MakeFileDestination(sLogPath));
    QsLogging::DestinationPtr debugDestination(QsLogging::DestinationFactory::MakeDebugOutputDestination());
    logger.addDestination(debugDestination.get());
    logger.addDestination(fileDestination.get());
    QLOG_INFO() << "Starting the log";
//#endif


    An<EdgeMenuFactory> factory;
    factory->AddFactory(TypeIdentifier<ClassDialog>::id(), CreateClassDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<ClassDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<OperationDialog>::id(), CreateClassDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<OperationDialog>::id(), ConnectToClassDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<ArtifactDialog>::id(), CreateLimitedDialogMenu);
    factory->AddConnectionFunctor(TypeIdentifier<ArtifactDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialog>);
    factory->AddFactory(TypeIdentifier<ConstructorInitializerDialog>::id(), CreateLimitedDialogMenu);
    factory->AddConnectionFunctorQt4(TypeIdentifier<ConstructorInitializerDialog>::id(), ConnectToLimitedDialog<EdgeMenuDialogQt4>);


    UmlDesktop::init();
    QSettings settings("settings.ini", QSettings::IniFormat);
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    bool overridePresent = QFileInfo("override_transition.txt").exists();
    if(settings.value("Main/compatibility_save") .toInt() == 1 && !overridePresent)
    {
    QMessageBox::warning(0, QObject::tr("Warning"),
                         QObject::tr("Douml is working in transitional mode.\n All UI improvements are yours to use,  "
                                     "but saving is done in the format of Bouml 4.22 "
                                     "which loses all new c++11 and hierarchy specifiers\n\n"
                                     "To suppress this warning place empty file override_transition.txt into the application folder\n"
                                     "To disable the mode - change compatibility_save parameter to 0 in settings.ini\n"));
    }

    // note : bool conv_env = !QDir::home().exists(".doumlrc") doesn't work
    // if the path contains non latin1 characters, for instance cyrillic !
    QString s = QDir::home().absFilePath(".doumlrc");
    FILE * fp = fopen((const char *) s, "r");
    bool conv_env = (fp == 0);


    if (conv_env)
        EnvDialog::edit(TRUE);
    else
        fclose(fp);

    read_doumlrc();	// for virtual desktop
    init_pixmaps();
    init_font();
    Shortcut::init(conv_env);

    bool exec = FALSE;
    bool no_gui = FALSE;

    if (argc > 3) {
        if (!strcmp(argv[2], "-execnogui"))
            exec = no_gui = TRUE;
        else
            exec = !strcmp(argv[2], "-exec");
    }

    UmlWindow * uw = new UmlWindow(exec);

    if (no_gui)
        UmlDesktop::set_nogui();
    else
    {
        uw->showMaximized();
    }

    if (argc > 1) {
        try {
            if ((argc == 3) &&
                !strcmp(argv[2], "-root") &&
                (msg_critical(TR("DO NOT CONFIRM"),
                              TR("Root mode protection\n\n"
                                 "This mode allows me to develop BOUML\n\n"
                                 "do NOT confirm to avoid a disaster !!!\n\n"
                                 "confirm ?"),
                              QMessageBox::Yes, QMessageBox::No)
                 == QMessageBox::Yes)) {
                set_user_id(0);
                set_editor(getenv("BOUML_EDITOR")); // no environment file
                argc = 1;
            }

            uw->load_it(argv[1]);
        }
        catch (...) {
            // cannot read a file
            return -1;

        }
    }

    QObject::connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));

    try {
        if (argc > 2) {
            if (exec) {
                bool with_exit = FALSE;

                if (!strcmp(argv[argc - 1], "-exit")) {
                    with_exit = TRUE;
                    argc -= 1;
                }

                WrapperStr cmd = argv[3];
                WrapperStr space = " ";
                int index;

                for (index = 4; index != argc; index += 1)
                    cmd += space + WrapperStr(argv[index]);

                ToolCom::run((const char *) cmd, BrowserView::get_project(), with_exit);
            }
            else
                msg_warning(TR("Error"), TR("Bouml was called with wrong parameters, ignore them"));
        }


        ExitOnError = TRUE;
        a.exec();
    }
    catch (...) {
        ;
    }


    return exit_value();
}