コード例 #1
0
int PythonEditorsTabWidget::addEditor(const QString &fileName) {
  PythonCodeEditor *codeEditor = new PythonCodeEditor();

  QFileInfo fileInfo(fileName);
  codeEditor->loadCodeFromFile(fileName);
  codeEditor->analyseScriptCode(true);
  codeEditor->setFocus(Qt::ActiveWindowFocusReason);
  codeEditor->installEventFilter(this);
  connect(codeEditor, SIGNAL(textChanged()), this, SLOT(scriptTextChanged()));
  int idx = addTab(codeEditor, fileInfo.fileName());
  setTabToolTip(idx, fileInfo.absoluteFilePath());
  setCurrentIndex(idx);

  if (_fontZoom < 0) {
    for (int i = _fontZoom ; i < 0 ; ++i) {
      codeEditor->zoomOut();
    }
  }

  if (_fontZoom > 0) {
    for (int i = _fontZoom ; i > 0 ; --i) {
      codeEditor->zoomIn();
    }
  }

  return idx;
}
コード例 #2
0
int PythonScriptViewWidget::addPluginEditor(const QString &fileName) {
    PythonCodeEditor *codeEditor = new PythonCodeEditor();
    codeEditor->setGraph(pythonScriptView->getGraph());
    codeEditor->setFileName(fileName);
    codeEditor->installEventFilter(pythonScriptView);
    codeEditor->setFocus(Qt::ActiveWindowFocusReason);
    connect(codeEditor, SIGNAL(textChanged()), this, SLOT(pluginScriptTextChanged()));
    int idx = pluginsTabWidget->addTab(codeEditor, "");
    pluginsTabWidget->setCurrentIndex(idx);
    return idx;
}