コード例 #1
0
ファイル: qucs_actions.cpp プロジェクト: Qucs/qucs
// ------------------------------------------------------------------------
///
/// \brief QucsApp::editFile
/// \param File is the filename, or empty for a new file
///
/// Called by :
/// - slotTextNew()
/// - slotShowLastMsg()
/// - slotShowLastNetlist()
/// - edit properties of components (such as spice, verilog)
///
void QucsApp::editFile(const QString& File)
{
    if ((QucsSettings.Editor.toLower() == "qucs") | QucsSettings.Editor.isEmpty())
    {
        // The Editor is 'qucs' or empty, open a net document tab
        if (File.isEmpty()) {
            TextDoc *d = new TextDoc(this, "");
            int i = DocumentTab->addTab(d, QPixmap(":/bitmaps/empty.xpm"), QObject::tr("untitled"));
            DocumentTab->setCurrentIndex(i);
        }
        else
        {
            slotHideEdit(); // disable text edit of component property

            statusBar()->showMessage(tr("Opening file..."));

            QFileInfo finfo(File);

            if(!finfo.exists())
                statusBar()->showMessage(tr("Opening aborted, file not found."), 2000);
            else {
                gotoPage(File);
                lastDirOpenSave = File;   // remember last directory and file
                statusBar()->showMessage(tr("Ready."));
            }
        }
    }
    else
    {
      // use an external editor
      QString prog;
      QStringList args;

      QString editorPath = QucsSettings.Editor;
      QFileInfo editor(editorPath);
      prog = QDir::toNativeSeparators(editor.canonicalFilePath());

      if (!File.isEmpty()) {
          args << File;
      }

      QProcess *externalEditor = new QProcess();
      qDebug() << "Command: " << editorPath << args.join(" ");
      externalEditor->start(prog, args);

      if( !externalEditor->waitForStarted(1000) ) {
        QMessageBox::critical(this, tr("Error"), tr("Cannot start text editor: \n\n%1").arg(editorPath));
        delete externalEditor;
        return;
      }
      qDebug() << externalEditor->readAllStandardError();

      // to kill it before qucs ends
      connect(this, SIGNAL(signalKillEmAll()), externalEditor, SLOT(kill()));
    }
}
コード例 #2
0
ファイル: qucs_actions.cpp プロジェクト: MikeBrinson/qucs
// ------------------------------------------------------------------------
// Is called to start the attenuator calculation program.
void QucsApp::slotCallAtt()
{
  QProcess *QucsAtt =
    new QProcess(QString(QucsSettings.BinDir + "qucsattenuator"));
  if(!QucsAtt->start()) {
    QMessageBox::critical(this, tr("Error"),
                          tr("Cannot start attenuator calculation program!"));
    delete QucsAtt;
    return;
  }

  // to kill it before qucs ends
  connect(this, SIGNAL(signalKillEmAll()), QucsAtt, SLOT(kill()));
}
コード例 #3
0
ファイル: qucs_actions.cpp プロジェクト: MikeBrinson/qucs
// ------------------------------------------------------------------------
// Is called to start the component library program.
void QucsApp::slotCallLibrary()
{
  QProcess *QucsLibrary =
    new QProcess(QString(QucsSettings.BinDir + "qucslib"));
  if(!QucsLibrary->start()) {
    QMessageBox::critical(this, tr("Error"),
                          tr("Cannot start library program!"));
    delete QucsLibrary;
    return;
  }

  // to kill it before qucs ends
  connect(this, SIGNAL(signalKillEmAll()), QucsLibrary, SLOT(kill()));
}
コード例 #4
0
ファイル: qucs_actions.cpp プロジェクト: MikeBrinson/qucs
// ------------------------------------------------------------------------
// Is called to start the filter synthesis program.
void QucsApp::slotCallFilter()
{
  QProcess *QucsFilter =
    new QProcess(QString(QucsSettings.BinDir + "qucsfilter"));
  if(!QucsFilter->start()) {
    QMessageBox::critical(this, tr("Error"),
                          tr("Cannot start filter synthesis program!"));
    delete QucsFilter;
    return;
  }

  // to kill it before qucs ends
  connect(this, SIGNAL(signalKillEmAll()), QucsFilter, SLOT(kill()));
}
コード例 #5
0
ファイル: qucs_actions.cpp プロジェクト: ClemensFMN/qucs
// ------------------------------------------------------------------------
// Is called to start the transmission line calculation program.
void QucsApp::slotCallLine()
{
  Q3Process *QucsLine =
    new Q3Process(QString(QucsSettings.BinDir + "qucstrans"));
  if(!QucsLine->start()) {
    QMessageBox::critical(this, tr("Error"),
                          tr("Cannot start line calculation program!"));
    delete QucsLine;
    return;
  }

  // to kill it before qucs ends
  connect(this, SIGNAL(signalKillEmAll()), QucsLine, SLOT(kill()));
}
コード例 #6
0
ファイル: qucs_actions.cpp プロジェクト: MikeBrinson/qucs
// --------------------------------------------------------------
void QucsApp::showHTML(const QString& Page)
{
  QStringList com;
  com << QucsSettings.BinDir + "qucshelp" << Page;
  QProcess *QucsHelp = new QProcess(com);
  QucsHelp->setCommunication(0);
  if(!QucsHelp->start()) {
    QMessageBox::critical(this, tr("Error"), tr("Cannot start qucshelp!"));
    delete QucsHelp;
    return;
  }

  // to kill it before qucs ends
  connect(this, SIGNAL(signalKillEmAll()), QucsHelp, SLOT(kill()));
}
コード例 #7
0
ファイル: qucs_actions.cpp プロジェクト: MikeBrinson/qucs
// ------------------------------------------------------------------------
// Is called by slotShowLastMsg(), by slotShowLastNetlist() and from the
// component edit dialog.
void QucsApp::editFile(const QString& File)
{
  QStringList com;
  com << QucsSettings.Editor;
  if (!File.isEmpty()) com << File;
  QProcess *QucsEditor = new QProcess(com);
  QucsEditor->setCommunication(0);
  if(!QucsEditor->start()) {
    QMessageBox::critical(this, tr("Error"), tr("Cannot start text editor!"));
    delete QucsEditor;
    return;
  }

  // to kill it before qucs ends
  connect(this, SIGNAL(signalKillEmAll()), QucsEditor, SLOT(kill()));
}
コード例 #8
0
ファイル: qucs_actions.cpp プロジェクト: ClemensFMN/qucs
// ------------------------------------------------------------------------
// Is called by slotShowLastMsg(), by slotShowLastNetlist() and from the
// component edit dialog.
void QucsApp::editFile(const QString& File)
{

    if (QucsSettings.Editor.toLower() == "qucs" | QucsSettings.Editor.isEmpty())
    {
        // The Editor is 'qucs' or empty, open it in an editor tab
        editText->setHidden(true); // disable text edit of component property

        statusBar()->message(tr("Opening file..."));

        QFileInfo finfo(File);

        if(!finfo.exists())
          statusBar()->message(tr("Opening aborted, file not found."), 2000);
        else {
          gotoPage(File);
          lastDirOpenSave = File;   // remember last directory and file
          statusBar()->message(tr("Ready."));
        }
    }
    else
    {
      // use an external editor
      QStringList com;

      com << QucsSettings.Editor;

      if (!File.isEmpty())
      {
          com << File;
      }

      Q3Process *QucsEditor = new Q3Process(com);
      QucsEditor->setCommunication(0);
      if(!QucsEditor->start()) {
        QMessageBox::critical(this, tr("Error"), tr("Cannot start text editor!"));
        delete QucsEditor;
        return;
      }

      // to kill it before qucs ends
      connect(this, SIGNAL(signalKillEmAll()), QucsEditor, SLOT(kill()));
    }
}
コード例 #9
0
ファイル: qucs_actions.cpp プロジェクト: Qucs/qucs
/*!
 * \brief launch an external application passing arguments
 *
 * \param prog  executable program name (will be transformed depending on OS)
 * \param progDesc  program description string (used for error messages)
 * \param args  arguments to pass to the executable
 */
void QucsApp::launchTool(const QString& prog, const QString& progDesc, const QString& args) {
  QProcess *tool = new QProcess();

#ifdef __MINGW32__
  QString cmd = QDir::toNativeSeparators("\""+QucsSettings.BinDir + prog + ".exe\"");
#elif __APPLE__
  QString cmd = QDir::toNativeSeparators(QucsSettings.BinDir + prog + ".app/Contents/MacOS/" + prog);
#else
  QString cmd = QDir::toNativeSeparators(QucsSettings.BinDir + prog);
#endif

  char const* var = getenv("QUCS_USE_PATH");
  if(var != NULL) {
    // just use PATH. this is currently bound to a contition, to maintain
    // backwards compatibility with QUCSDIR
    qDebug() << "QUCS_USE_PATH";
    cmd = prog;
  }else{
    // don't know what this is about. doesn't make sense in the case above.
    // (and in all other cases i can think of)
    tool->setWorkingDirectory(QucsSettings.BinDir);
  }

  qDebug() << "Command :" << cmd + " " + args;

  // FIXME: use start(const QString& program, const QStringList& arguments);
  tool->start(cmd + " " + args);
  
  // BUG: use signals. see QUCSATOR invocation
  if(!tool->waitForStarted(1000) ) {
    QMessageBox::critical(this, tr("Error"),
	tr("Cannot start %1 program! \n\n(%2)").arg(progDesc, cmd + " " + args));
    delete tool;
    return;
  }

  // to kill the application first before qucs finishes exiting
  connect(this, SIGNAL(signalKillEmAll()), tool, SLOT(kill()));
}