mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-25 15:35:23 +00:00
Fix script editor undo/redo context menu actions
This commit is contained in:
parent
6063d8e31b
commit
e685de0f84
@ -306,10 +306,14 @@ void CSVWorld::ScriptEdit::commentSelection()
|
||||
end.setPosition(end.selectionEnd());
|
||||
end.movePosition(QTextCursor::EndOfLine);
|
||||
|
||||
begin.beginEditBlock();
|
||||
|
||||
for (; begin < end; begin.movePosition(QTextCursor::EndOfLine), begin.movePosition(QTextCursor::Right))
|
||||
{
|
||||
begin.insertText(";");
|
||||
}
|
||||
|
||||
begin.endEditBlock();
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::uncommentSelection()
|
||||
@ -322,6 +326,8 @@ void CSVWorld::ScriptEdit::uncommentSelection()
|
||||
end.setPosition(end.selectionEnd());
|
||||
end.movePosition(QTextCursor::EndOfLine);
|
||||
|
||||
begin.beginEditBlock();
|
||||
|
||||
for (; begin < end; begin.movePosition(QTextCursor::EndOfLine), begin.movePosition(QTextCursor::Right)) {
|
||||
begin.select(QTextCursor::LineUnderCursor);
|
||||
QString line = begin.selectedText();
|
||||
@ -345,6 +351,8 @@ void CSVWorld::ScriptEdit::uncommentSelection()
|
||||
begin.insertText(line);
|
||||
}
|
||||
}
|
||||
|
||||
begin.endEditBlock();
|
||||
}
|
||||
|
||||
void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
|
||||
@ -358,6 +366,16 @@ void CSVWorld::ScriptEdit::resizeEvent(QResizeEvent *e)
|
||||
void CSVWorld::ScriptEdit::contextMenuEvent(QContextMenuEvent *event)
|
||||
{
|
||||
QMenu *menu = createStandardContextMenu();
|
||||
|
||||
// remove redo/undo since they are disabled
|
||||
QList<QAction*> menuActions = menu->actions();
|
||||
for (QList<QAction*>::iterator i = menuActions.begin(); i < menuActions.end(); ++i)
|
||||
{
|
||||
if ((*i)->text().contains("Undo") || (*i)->text().contains("Redo"))
|
||||
{
|
||||
(*i)->setVisible(false);
|
||||
}
|
||||
}
|
||||
menu->addAction(mCommentAction);
|
||||
menu->addAction(mUncommentAction);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user