Пример #1
0
void CodeEditor::contextMenuEvent(QContextMenuEvent* event)
{
    QMenu menu(this);

    QAction* act = menu.addAction(tr("&Undo"), this, SLOT(undo()));       //, QKeySequence::Undo);
    act->setEnabled(document()->isUndoAvailable());
    act = menu.addAction(tr("&Redo"), this, SLOT(redo()));                //, QKeySequence::Redo);
    act->setEnabled(document()->isRedoAvailable());
    menu.addSeparator();
    act = menu.addAction(tr("Cu&t"),       this, SLOT(cut()));            //, QKeySequence::Cut);
    act->setEnabled(textCursor().hasSelection());
    act = menu.addAction(tr("&Copy"),      this, SLOT(copy()));           //, QKeySequence::Copy);
    act->setEnabled(textCursor().hasSelection());
    act = menu.addAction(tr("&Paste"),     this, SLOT(paste()));          //, QKeySequence::Paste);
    act->setEnabled(canPaste());
    act = menu.addAction(tr("Delete"),     this, SLOT(deleteSelected())); //, QKeySequence::Delete);
    act->setEnabled(textCursor().hasSelection());
    act = menu.addAction(tr("Select All"), this, SLOT(selectAll()));      //, QKeySequence::SelectAll);
    act->setEnabled(!document()->isEmpty());
    menu.addSeparator();
    menu.addAction(tr("Fold All"),   this, SLOT(foldAll()));
    menu.addAction(tr("Unfold All"), this, SLOT(unfoldAll()));
    menu.addSeparator();
    menu.addAction(tr("Toggle comment"), this, SLOT(toggleComment()));
    menu.addSeparator();
    menu.addAction(tr("UPPERCASE"), this, SLOT(toUpperCase()));
    menu.addAction(tr("lowercase"), this, SLOT(toLowerCase()));

    menu.exec(event->globalPos());
}
Пример #2
0
void MainWindow::initMenuEdit() {
	//connect menu "Edit" Action
	connect(actionCut, SIGNAL(triggered()), _documentManager, SLOT(cut()));
	connect(actionCopy, SIGNAL(triggered()), _documentManager, SLOT(copy()));
	connect(actionPaste, SIGNAL(triggered()), _documentManager, SLOT(paste()));
	connect(actionUndo, SIGNAL(triggered()), _documentManager, SLOT(undo()));
	connect(actionRedo, SIGNAL(triggered()), _documentManager, SLOT(redo()));
	connect(actionSelectAll, SIGNAL(triggered()), _documentManager, SLOT(selectAll()));

	connect(actionIndent, SIGNAL(triggered()), this, SLOT(increaseIndentation()));
	connect(actionUnindent, SIGNAL(triggered()), this, SLOT(decreaseIndentation()));
	connect(actionAutoIndentation, SIGNAL(toggled(bool)), _documentManager, SLOT(setAutoIndentation(bool)));
	connect(actionIndentationGuides, SIGNAL(toggled(bool)), _documentManager, SLOT(showIndentationGuides(bool)));

	connect(actionTabsToSpaces, SIGNAL(triggered()), _documentManager, SLOT(tabsToSpaces()));
	connect(actionSpacesToTabs, SIGNAL(triggered()), _documentManager, SLOT(spacesToTabs()));
	connect(actionTrimTrailingSpaces, SIGNAL(triggered()), _documentManager, SLOT(trimTrailingSpaces()));
	connect(actionCompressSpaces, SIGNAL(triggered()), _documentManager, SLOT(compressSpaces()));

	connect(actionUpperCase, SIGNAL(triggered()), _documentManager, SLOT(convertSelectedTextToUpperCase()));
	connect(actionLowerCase, SIGNAL(triggered()), _documentManager, SLOT(convertSelectedTextToLowerCase()));
	connect(actionDuplicateLine, SIGNAL(triggered()), _documentManager, SLOT(duplicateCurrentLine()));
	connect(actionCopyLine, SIGNAL(triggered()), _documentManager, SLOT(copyCurrentLine()));
	connect(actionCutLine, SIGNAL(triggered()), _documentManager, SLOT(cutCurrentLine()));
	connect(actionDeleteLine, SIGNAL(triggered()), _documentManager, SLOT(deleteCurrentLine()));
	connect(actionMoveLineUp, SIGNAL(triggered()), _documentManager, SLOT(moveCurrentLineUp()));
	connect(actionMoveLineDown, SIGNAL(triggered()), _documentManager, SLOT(moveCurrentLineDown()));
	connect(actionDeleteWord, SIGNAL(triggered()), _documentManager, SLOT(deleteCurrentWord()));

	connect(actionGotoLine, SIGNAL(triggered()), this, SLOT(gotoLine()));

	connect(actionReadOnly, SIGNAL(triggered(bool)), _documentManager, SLOT(setReadOnly(bool)));
	connect(actionReindentFile, SIGNAL(triggered()), _documentManager, SLOT(reindentDocument()));
	connect(actionReindentOpenFiles, SIGNAL(triggered()), _documentManager, SLOT(reindentOpenDocuments()));

	connect(actionToggleComment, SIGNAL(triggered()), _documentManager, SLOT(toggleComment()));
	connect(actionToggleBlockComment, SIGNAL(triggered()), _documentManager, SLOT(toggleBlockComment()));

	connect(actionSwitchSrc, SIGNAL(triggered()), _documentManager, SLOT(switchDocumentSrc()));
	connect(actionSwitchFile, SIGNAL(triggered()), _documentManager, SLOT(switchFile()));
	connect(actionSwitchSymbol, SIGNAL(triggered()), this, SLOT(switchSymbol()));

	connect(menuEdit, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditMenu()));
	connect(menuIndentation, SIGNAL(aboutToShow()), this, SLOT(aboutToShowEditIndentationMenu()));
}
Пример #3
0
/// Uncomment a block of code
void ScriptFileInterpreter::uncomment() { toggleComment(false); }
Пример #4
0
/// Comment a block of code
void ScriptFileInterpreter::comment() { toggleComment(true); }