aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/texteditor
diff options
context:
space:
mode:
authorMarcus Tillmanns <marcus.tillmanns@qt.io>2024-04-18 08:49:23 +0200
committerMarcus Tillmanns <marcus.tillmanns@qt.io>2024-04-18 09:31:40 +0000
commit9019520d621124fb8e7ab66484166987f4605f02 (patch)
tree190bd702d1133659ac9d1718172f846e6ff36dd6 /src/plugins/texteditor
parentc9299cad64924adf10c923b338dbf8e96452fd69 (diff)
CompilerExplorer: Fix Undo/Redo actions
Change-Id: Ib3f55467764600d0b1e4ef25b53874a4d37a7ba7 Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/texteditor')
-rw-r--r--src/plugins/texteditor/texteditor.cpp32
-rw-r--r--src/plugins/texteditor/texteditor.h5
2 files changed, 29 insertions, 8 deletions
diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp
index 089c483d2e..749e7bf2f7 100644
--- a/src/plugins/texteditor/texteditor.cpp
+++ b/src/plugins/texteditor/texteditor.cpp
@@ -745,8 +745,8 @@ public:
void registerActions();
void updateActions();
void updateOptionalActions();
- void updateRedoAction(bool on);
- void updateUndoAction(bool on);
+ void updateRedoAction();
+ void updateUndoAction();
void updateCopyAction(bool on);
public:
@@ -1936,6 +1936,12 @@ void TextEditorWidget::setVisualIndentOffset(int offset)
d->m_visualIndentOffset = qMax(0, offset);
}
+void TextEditorWidget::updateUndoRedoActions()
+{
+ d->updateUndoAction();
+ d->updateRedoAction();
+}
+
void TextEditorWidgetPrivate::updateCannotDecodeInfo()
{
q->setReadOnly(m_document->hasDecodingError());
@@ -2587,6 +2593,16 @@ void TextEditorWidget::redo()
QPlainTextEdit::redo();
}
+bool TextEditorWidget::isUndoAvailable() const
+{
+ return document()->isUndoAvailable();
+}
+
+bool TextEditorWidget::isRedoAvailable() const
+{
+ return document()->isRedoAvailable();
+}
+
void TextEditorWidget::openLinkUnderCursor()
{
d->openLinkUnderCursor(alwaysOpenLinksInNextSplit());
@@ -4340,8 +4356,8 @@ void TextEditorWidgetPrivate::updateActions()
m_visualizeWhitespaceAction->setChecked(m_displaySettings.m_visualizeWhitespace);
m_textWrappingAction->setChecked(m_displaySettings.m_textWrapping);
- updateRedoAction(q->document()->isRedoAvailable());
- updateUndoAction(q->document()->isUndoAvailable());
+ updateRedoAction();
+ updateUndoAction();
updateCopyAction(q->textCursor().hasSelection());
updateOptionalActions();
@@ -4368,14 +4384,14 @@ void TextEditorWidgetPrivate::updateOptionalActions()
m_autoFormatAction->setEnabled(formatEnabled);
}
-void TextEditorWidgetPrivate::updateRedoAction(bool on)
+void TextEditorWidgetPrivate::updateRedoAction()
{
- m_redoAction->setEnabled(on);
+ m_redoAction->setEnabled(q->isRedoAvailable());
}
-void TextEditorWidgetPrivate::updateUndoAction(bool on)
+void TextEditorWidgetPrivate::updateUndoAction()
{
- m_undoAction->setEnabled(on);
+ m_undoAction->setEnabled(q->isUndoAvailable());
}
void TextEditorWidgetPrivate::updateCopyAction(bool hasCopyableText)
diff --git a/src/plugins/texteditor/texteditor.h b/src/plugins/texteditor/texteditor.h
index 2d54231b1c..78dc0e0b82 100644
--- a/src/plugins/texteditor/texteditor.h
+++ b/src/plugins/texteditor/texteditor.h
@@ -457,6 +457,9 @@ public:
virtual void undo();
virtual void redo();
+ virtual bool isUndoAvailable() const;
+ virtual bool isRedoAvailable() const;
+
void openLinkUnderCursor();
void openLinkUnderCursorInNextSplit();
void openTypeUnderCursor();
@@ -584,6 +587,8 @@ protected:
void setVisualIndentOffset(int offset);
+ void updateUndoRedoActions();
+
public:
QString selectedText() const;