forked from qt-creator/qt-creator
QmlDesigner: Update paste action on clipboard changes
Fixes: QDS-10999 Change-Id: I03e477be64036ffbd3baf2c2286406f3ef2ae2b7 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -877,6 +877,7 @@ public:
|
|||||||
void updateRedoAction();
|
void updateRedoAction();
|
||||||
void updateUndoAction();
|
void updateUndoAction();
|
||||||
void updateCopyAction(bool on);
|
void updateCopyAction(bool on);
|
||||||
|
void updatePasteAction();
|
||||||
|
|
||||||
public:
|
public:
|
||||||
TextEditorWidget *q;
|
TextEditorWidget *q;
|
||||||
@@ -1074,6 +1075,7 @@ public:
|
|||||||
QAction *m_copyAction = nullptr;
|
QAction *m_copyAction = nullptr;
|
||||||
QAction *m_copyHtmlAction = nullptr;
|
QAction *m_copyHtmlAction = nullptr;
|
||||||
QAction *m_cutAction = nullptr;
|
QAction *m_cutAction = nullptr;
|
||||||
|
QAction *m_pasteAction = nullptr;
|
||||||
QAction *m_autoIndentAction = nullptr;
|
QAction *m_autoIndentAction = nullptr;
|
||||||
QAction *m_autoFormatAction = nullptr;
|
QAction *m_autoFormatAction = nullptr;
|
||||||
QAction *m_visualizeWhitespaceAction = nullptr;
|
QAction *m_visualizeWhitespaceAction = nullptr;
|
||||||
@@ -1272,6 +1274,8 @@ TextEditorWidgetPrivate::TextEditorWidgetPrivate(TextEditorWidget *parent)
|
|||||||
connect(q, &QPlainTextEdit::copyAvailable,
|
connect(q, &QPlainTextEdit::copyAvailable,
|
||||||
this, &TextEditorWidgetPrivate::updateCopyAction);
|
this, &TextEditorWidgetPrivate::updateCopyAction);
|
||||||
|
|
||||||
|
connect(qApp->clipboard(), &QClipboard::changed, this, &TextEditorWidgetPrivate::updatePasteAction);
|
||||||
|
|
||||||
m_parenthesesMatchingTimer.setSingleShot(true);
|
m_parenthesesMatchingTimer.setSingleShot(true);
|
||||||
m_parenthesesMatchingTimer.setInterval(50);
|
m_parenthesesMatchingTimer.setInterval(50);
|
||||||
connect(&m_parenthesesMatchingTimer, &QTimer::timeout,
|
connect(&m_parenthesesMatchingTimer, &QTimer::timeout,
|
||||||
@@ -4257,11 +4261,13 @@ void TextEditorWidgetPrivate::registerActions()
|
|||||||
.addOnTriggered([this] { q->cut(); })
|
.addOnTriggered([this] { q->cut(); })
|
||||||
.setScriptable(true)
|
.setScriptable(true)
|
||||||
.contextAction();
|
.contextAction();
|
||||||
m_modifyingActions << ActionBuilder(this, PASTE)
|
m_pasteAction = ActionBuilder(this, PASTE)
|
||||||
.setContext(m_editorContext)
|
.setContext(m_editorContext)
|
||||||
.addOnTriggered([this] { q->paste(); })
|
.addOnTriggered([this] { q->paste(); })
|
||||||
.setScriptable(true)
|
.setScriptable(true)
|
||||||
.contextAction();
|
.contextAction();
|
||||||
|
m_modifyingActions << m_pasteAction;
|
||||||
|
|
||||||
ActionBuilder(this, SELECTALL)
|
ActionBuilder(this, SELECTALL)
|
||||||
.setContext(m_editorContext)
|
.setContext(m_editorContext)
|
||||||
.setScriptable(true)
|
.setScriptable(true)
|
||||||
@@ -4710,7 +4716,7 @@ void TextEditorWidgetPrivate::updateActions()
|
|||||||
updateRedoAction();
|
updateRedoAction();
|
||||||
updateUndoAction();
|
updateUndoAction();
|
||||||
updateCopyAction(q->textCursor().hasSelection());
|
updateCopyAction(q->textCursor().hasSelection());
|
||||||
|
updatePasteAction();
|
||||||
updateOptionalActions();
|
updateOptionalActions();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4755,6 +4761,12 @@ void TextEditorWidgetPrivate::updateCopyAction(bool hasCopyableText)
|
|||||||
m_copyHtmlAction->setEnabled(hasCopyableText);
|
m_copyHtmlAction->setEnabled(hasCopyableText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TextEditorWidgetPrivate::updatePasteAction()
|
||||||
|
{
|
||||||
|
if (m_pasteAction)
|
||||||
|
m_pasteAction->setEnabled(!q->isReadOnly() && !qApp->clipboard()->text(QClipboard::Mode::Clipboard).isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
bool TextEditorWidget::codeFoldingVisible() const
|
bool TextEditorWidget::codeFoldingVisible() const
|
||||||
{
|
{
|
||||||
return d->m_codeFoldingVisible;
|
return d->m_codeFoldingVisible;
|
||||||
|
Reference in New Issue
Block a user