Exemplo n.º 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;
}
Exemplo n.º 2
0
int read_boumlrc()
{
  // note : QFile fp(QDir::home().absFilePath(".boumlrc")) doesn't work
  // if the path contains non latin1 characters, for instance cyrillic !
  QString s = QDir::home().absFilePath(".boumlrc");
  FILE * fp = fopen((const char *) s, "r");

















  
  if (fp == 0) {
    QMessageBox::critical(0, "Bouml", TR("cannot read '%1'", s));
    exit(-1);
  }

  set_manual_dir("");
  set_navigator_path("");
  set_template_project("");
  set_editor("");
  set_codec("");
  UmlDesktop::set_limits(0, 0, 0, 0);
        
  int id = -1;
  char line[512];
  bool lang_set = FALSE;
  bool nolang = FALSE;
      
  while (fgets(line, sizeof(line) - 1, fp) != 0) {
    remove_crlf(line);

    if (!strncmp(line, "ID ", 3))
      sscanf(line+3, "%d", &id);
    else if (!strncmp(line, "MANUAL ", 7))
      set_manual_dir(line+7);
    else if (!strncmp(line, "NAVIGATOR ", 10))
      set_navigator_path(line+10);
    else if (!strncmp(line, "TEMPLATE ",9 ))
      set_template_project(line+9);
    else if (!strncmp(line, "EDITOR ", 7))
      set_editor(line+7);
    else if (!strncmp(line, "CHARSET ", 8))
      set_codec(line+8);
    else if (!strncmp(line, "DESKTOP ", 8)) {
      int l, t, r, b;
      
      if (sscanf(line+8, "%d %d %d %d", &l, &t, &r, &b) == 4)
	UmlDesktop::set_limits(l, t, r, b);
    }
    else if (!strncmp(line, "LANG ", 5)) {
      set_lang(line+5);
      lang_set = TRUE;
    }
    else if (!strncmp(line, "NOLANG", 6)) {
      nolang = TRUE;
    }
  }
    
  fclose(fp);
  
  if (! lang_set) {
    set_lang("");
    
    if (! nolang)
      propose_lang();
  }
  
  if (id == -1) {
    QMessageBox::critical(0, "Bouml", TR("Own identifier missing or invalid"));
    EnvDialog::edit(FALSE, TRUE);
    return read_boumlrc();
  }
    
  return id;
}