| 1 | #include "livecodeeditor.h" |
| 2 | #include "ui_livecodeeditor.h" |
| 3 | |
| 4 | #include "documentview.h" |
| 5 | |
| 6 | LiveCodeEditor::LiveCodeEditor(QWidget *parent, OpEntryParser *m_opcodeTree) : |
| 7 | QWidget(parent), |
| 8 | ui(new Ui::LiveCodeEditor) |
| 9 | { |
| 10 | ui->setupUi(this); |
| 11 | m_docView = new DocumentView(this, m_opcodeTree); |
| 12 | m_docView->showLineArea(true); |
| 13 | m_docView->setFullText(""); |
| 14 | |
| 15 | ui->verticalLayout->addWidget(m_docView); |
| 16 | |
| 17 | connect(ui->modeComboBox, SIGNAL(currentIndexChanged(int)), |
| 18 | this, SLOT(modeChanged(int))); |
| 19 | connect(m_docView, SIGNAL(evaluate(QString)), this, SLOT(evaluateSlot(QString))); |
| 20 | } |
| 21 | |
| 22 | LiveCodeEditor::~LiveCodeEditor() |
| 23 | { |
| 24 | delete ui; |
| 25 | } |
| 26 | |
| 27 | DocumentView *LiveCodeEditor::getDocumentView() |
| 28 | { |
| 29 | return m_docView; |
| 30 | } |
| 31 | |
| 32 | void LiveCodeEditor::setCsdMode(bool csdMode) |
| 33 | { |
| 34 | if (csdMode) { |
| 35 | ui->modeComboBox->setCurrentIndex(0); |
| 36 | } else { |
| 37 | ui->modeComboBox->setCurrentIndex(1); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void LiveCodeEditor::modeChanged(int index) |
| 42 | { |
| 43 | if (index == 0) { |
| 44 | m_docView->setFileType(EDIT_CSOUND_MODE); |
| 45 | // m_docView->setBackgroundColor(QColor(240, 230, 230)); |
| 46 | emit enableCsdMode(true); |
| 47 | } else { |
| 48 | m_docView->setFileType(EDIT_PYTHON_MODE); |
| 49 | // m_docView->setBackgroundColor(QColor(230, 240, 230)); |
| 50 | emit enableCsdMode(false); |
| 51 | } |
| 52 | } |
| 53 | |
| 54 | void LiveCodeEditor::evaluateSlot(QString code) |
| 55 | { |
| 56 | emit evaluate(code); |
| 57 | } |