| 625 | } |
| 626 | |
| 627 | void MainWindow::tabChange(int tab) { |
| 628 | if (curEditor) { |
| 629 | disconnect(ui->actionCopy, &QAction::triggered, curEditor, &CodeEditor::copy); |
| 630 | disconnect(ui->actionPaste, &QAction::triggered, curEditor, &CodeEditor::paste); |
| 631 | disconnect(ui->actionCut, &QAction::triggered, curEditor, &CodeEditor::cut); |
| 632 | disconnect(ui->actionSelect_All, &QAction::triggered, curEditor, &CodeEditor::selectAll); |
| 633 | disconnect(ui->actionUndo, &QAction::triggered, curEditor, &CodeEditor::undo); |
| 634 | disconnect(ui->actionRedo, &QAction::triggered, curEditor, &CodeEditor::redo); |
| 635 | disconnect(curEditor, &CodeEditor::copyAvailable, ui->actionCopy, &QAction::setEnabled); |
| 636 | disconnect(curEditor, &CodeEditor::copyAvailable, ui->actionCut, &QAction::setEnabled); |
| 637 | disconnect(curEditor->document(), &QTextDocument::modificationChanged, |
| 638 | this, &MainWindow::setWindowModified); |
| 639 | disconnect(curEditor->document(), &QTextDocument::undoAvailable, |
| 640 | ui->actionUndo, &QAction::setEnabled); |
| 641 | disconnect(curEditor->document(), &QTextDocument::redoAvailable, |
| 642 | ui->actionRedo, &QAction::setEnabled); |
| 643 | disconnect(curEditor, &CodeEditor::cursorPositionChanged, this, &MainWindow::editor_cursor_position_changed); |
| 644 | disconnect(code_checker, &CodeChecker::finished, curEditor, &CodeEditor::checkFile); |
| 645 | disconnect(curEditor, &CodeEditor::changedDebounced, this, &MainWindow::check_code); |
| 646 | } |
| 647 | curEditor = tab == -1 ? nullptr : qobject_cast<CodeEditor*>(ui->tabWidget->widget(tab)); |
| 648 | if (!curEditor) { |
| 649 | setEditorMenuItemsEnabled(false); |
| 650 | ui->findFrame->hide(); |
| 651 | } else { |
| 652 | setEditorMenuItemsEnabled(true); |
| 653 | connect(ui->actionCopy, &QAction::triggered, curEditor, &CodeEditor::copy); |
| 654 | connect(ui->actionPaste, &QAction::triggered, curEditor, &CodeEditor::paste); |
| 655 | connect(ui->actionCut, &QAction::triggered, curEditor, &CodeEditor::cut); |
| 656 | connect(ui->actionSelect_All, &QAction::triggered, curEditor, &CodeEditor::selectAll); |
| 657 | connect(ui->actionUndo, &QAction::triggered, curEditor, &CodeEditor::undo); |
| 658 | connect(ui->actionRedo, &QAction::triggered, curEditor, &CodeEditor::redo); |
| 659 | connect(curEditor, &CodeEditor::copyAvailable, ui->actionCopy, &QAction::setEnabled); |
| 660 | connect(curEditor, &CodeEditor::copyAvailable, ui->actionCut, &QAction::setEnabled); |
| 661 | connect(curEditor->document(), &QTextDocument::modificationChanged, |
| 662 | this, &MainWindow::setWindowModified); |
| 663 | connect(curEditor->document(), &QTextDocument::undoAvailable, |
| 664 | ui->actionUndo, &QAction::setEnabled); |
| 665 | connect(curEditor->document(), &QTextDocument::redoAvailable, |
| 666 | ui->actionRedo, &QAction::setEnabled); |
| 667 | connect(curEditor, &CodeEditor::cursorPositionChanged, this, &MainWindow::editor_cursor_position_changed); |
| 668 | connect(code_checker, &CodeChecker::finished, curEditor, &CodeEditor::checkFile); |
| 669 | connect(curEditor, &CodeEditor::changedDebounced, this, &MainWindow::check_code); |
| 670 | setWindowModified(curEditor->document()->isModified()); |
| 671 | QString p; |
| 672 | p += " "; |
| 673 | p += QChar(0x2014); |
| 674 | p += " "; |
| 675 | if (getProject().hasProjectFile()) { |
| 676 | QFileInfo fi(getProject().projectFile()); |
| 677 | p += "Project: " + fi.baseName(); |
| 678 | } else { |
| 679 | p += "Untitled Project"; |
| 680 | } |
| 681 | if (curEditor->filepath.isEmpty()) { |
| 682 | setWindowFilePath(curEditor->filename); |
| 683 | setWindowTitle(curEditor->filename+p+"[*]"); |
| 684 | } else { |
nothing calls this directly
no test coverage detected