示例#1
0
文件: main.cpp 项目: MikeBrinson/qucs
int main(int argc, char *argv[])
{
  // apply default settings
  QucsSettings.x = 60;
  QucsSettings.y = 30;
  QucsSettings.dx = 640;
  QucsSettings.dy = 400;
  QucsSettings.font = QFont("Helvetica", 12);

  // is application relocated?
  char * var = getenv ("QUCSDIR");
  if (var != NULL) {
    QDir QucsDir = QDir (var);
    QString QucsDirStr = QucsDir.canonicalPath ();
    QucsSettings.DocDir =
      QDir::convertSeparators (QucsDirStr + "/share/qucs/docs/");
    QucsSettings.BitmapDir =
      QDir::convertSeparators (QucsDirStr + "/share/qucs/bitmaps/");
    QucsSettings.LangDir =
      QDir::convertSeparators (QucsDirStr + "/share/qucs/lang/");
  } else {
    QucsSettings.DocDir = DOCDIR;
    QucsSettings.BitmapDir = BITMAPDIR;
    QucsSettings.LangDir = LANGUAGEDIR;
  }

  loadSettings();

  QApplication a(argc, argv);
  a.setFont(QucsSettings.font);

  QTranslator tor( 0 );
  QString locale = QucsSettings.Language;
  if(locale.isEmpty())
    locale = QTextCodec::locale();
  tor.load( QString("qucs_") + locale, QucsSettings.LangDir);
  a.installTranslator( &tor );

  QucsHelpDir = QucsSettings.DocDir + locale;
  if (!QucsHelpDir.exists () || !QucsHelpDir.isReadable ()) {
    int p = locale.find ('_');
    if (p != -1) {
       QucsHelpDir = QucsSettings.DocDir + locale.left (p);
      if (!QucsHelpDir.exists () || !QucsHelpDir.isReadable ()) {
         QucsHelpDir = QucsSettings.DocDir + "en";
      }
    }
    else QucsHelpDir = QucsSettings.DocDir + "en";
  }

  QString Page;
  if(argc > 1) Page = argv[1];

  QucsHelp *qucs = new QucsHelp(Page);
  a.setMainWidget(qucs);
  qucs->resize(QucsSettings.dx, QucsSettings.dy); // size and position ...
  qucs->move(QucsSettings.x, QucsSettings.y);     // ... before "show" !!!
  qucs->show();
  int result = a.exec();
  saveApplSettings(qucs);
  return result;
}
示例#2
0
文件: main.cpp 项目: andresmmera/qucs
int main(int argc, char *argv[])
{

  QApplication a(argc, argv);

  // apply default settings
  QucsSettings.x = 60;
  QucsSettings.y = 30;
  QucsSettings.dx = 640;
  QucsSettings.dy = 400;
  QucsSettings.font = QFont("Helvetica", 12);

  // is application relocated?
  char * var = getenv ("QUCSDIR");
  QDir QucsDir;
  if (var != NULL) {
    QucsDir = QDir (QString(var));
    QString QucsDirStr = QucsDir.canonicalPath ();
    QucsSettings.DocDir =
      QDir::convertSeparators (QucsDirStr + "/share/qucs/docs/");
    QucsSettings.LangDir =
      QDir::convertSeparators (QucsDirStr + "/share/qucs/lang/");
  } else {
    QString QucsApplicationPath = QCoreApplication::applicationDirPath();
    #ifdef __APPLE__
    QucsDir = QDir(QucsApplicationPath.section("/bin",0,0));
    #else
    QucsDir = QDir(QucsApplicationPath);
    QucsDir.cdUp();
     #endif
    QucsSettings.DocDir  = QucsDir.canonicalPath() + "/share/qucs/docs/";
    QucsSettings.LangDir = QucsDir.canonicalPath() + "/share/qucs/lang/";
  }

  loadSettings();

  a.setFont(QucsSettings.font);

  QTranslator tor( 0 );
  QString locale = QucsSettings.Language;
  if(locale.isEmpty())
      locale = QString(QLocale::system().name());

  tor.load( QString("qucs_") + locale, QucsSettings.LangDir);
  a.installTranslator( &tor );

  QucsHelpDir = QucsSettings.DocDir + locale;
  if (!QucsHelpDir.exists () || !QucsHelpDir.isReadable ()) {
    int p = locale.indexOf ('_');
    if (p != -1) {
       QucsHelpDir = QucsSettings.DocDir + locale.left (p);
      if (!QucsHelpDir.exists () || !QucsHelpDir.isReadable ()) {
         QucsHelpDir = QucsSettings.DocDir + "en";
      }
    }
    else QucsHelpDir = QucsSettings.DocDir + "en";
  }

  QString Page;
  if(argc > 1) Page = argv[1];

  qInstallMsgHandler(qucsMessageOutput);

  QucsHelp *qucs = new QucsHelp(Page);
  //a.setMainWidget(qucs);
  qucs->resize(QucsSettings.dx, QucsSettings.dy); // size and position ...
  qucs->move(QucsSettings.x, QucsSettings.y);     // ... before "show" !!!
  qucs->show();
  int result = a.exec();
  saveApplSettings(qucs);
  return result;
}