forked from qt-creator/qt-creator
Debugger: Add action to copy watch value to clipboard.
This commit is contained in:
@@ -459,6 +459,15 @@ static inline QString removeWatchActionText(QString exp)
|
|||||||
return WatchWindow::tr("Remove Watch Expression \"%1\"").arg(exp);
|
return WatchWindow::tr("Remove Watch Expression \"%1\"").arg(exp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void copyToClipboard(const QString &clipboardText)
|
||||||
|
{
|
||||||
|
QClipboard *clipboard = QApplication::clipboard();
|
||||||
|
#ifdef Q_WS_X11
|
||||||
|
clipboard->setText(clipboardText, QClipboard::Selection);
|
||||||
|
#endif
|
||||||
|
clipboard->setText(clipboardText, QClipboard::Clipboard);
|
||||||
|
}
|
||||||
|
|
||||||
void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
||||||
{
|
{
|
||||||
DebuggerEngine *engine = currentEngine();
|
DebuggerEngine *engine = currentEngine();
|
||||||
@@ -659,6 +668,9 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QAction *actCopy = new QAction(tr("Copy Contents to Clipboard"), &menu);
|
QAction *actCopy = new QAction(tr("Copy Contents to Clipboard"), &menu);
|
||||||
|
QAction *actCopyValue = new QAction(tr("Copy Value to Clipboard"), &menu);
|
||||||
|
actCopyValue->setEnabled(idx.isValid());
|
||||||
|
|
||||||
|
|
||||||
menu.addAction(actInsertNewWatchItem);
|
menu.addAction(actInsertNewWatchItem);
|
||||||
menu.addAction(actSelectWidgetToWatch);
|
menu.addAction(actSelectWidgetToWatch);
|
||||||
@@ -667,7 +679,8 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
menu.addAction(actSetWatchpointAtVariableAddress);
|
menu.addAction(actSetWatchpointAtVariableAddress);
|
||||||
if (actSetWatchpointAtPointerValue)
|
if (actSetWatchpointAtPointerValue)
|
||||||
menu.addAction(actSetWatchpointAtPointerValue);
|
menu.addAction(actSetWatchpointAtPointerValue);
|
||||||
menu.addAction(actCopy );
|
menu.addAction(actCopy);
|
||||||
|
menu.addAction(actCopyValue);
|
||||||
menu.addSeparator();
|
menu.addSeparator();
|
||||||
|
|
||||||
menu.addAction(debuggerCore()->action(UseDebuggingHelpers));
|
menu.addAction(debuggerCore()->action(UseDebuggingHelpers));
|
||||||
@@ -734,13 +747,10 @@ void WatchWindow::contextMenuEvent(QContextMenuEvent *ev)
|
|||||||
watchExpression(exp);
|
watchExpression(exp);
|
||||||
} else if (act == actRemoveWatchExpression) {
|
} else if (act == actRemoveWatchExpression) {
|
||||||
removeWatchExpression(exp);
|
removeWatchExpression(exp);
|
||||||
} else if (act == actCopy ) {
|
} else if (act == actCopy) {
|
||||||
const QString clipboardText = DebuggerTreeViewToolTipWidget::treeModelClipboardContents(model());
|
copyToClipboard(DebuggerTreeViewToolTipWidget::treeModelClipboardContents(model()));
|
||||||
QClipboard *clipboard = QApplication::clipboard();
|
} else if (act == actCopyValue) {
|
||||||
#ifdef Q_WS_X11
|
copyToClipboard(mi1.data().toString());
|
||||||
clipboard->setText(clipboardText, QClipboard::Selection);
|
|
||||||
#endif
|
|
||||||
clipboard->setText(clipboardText, QClipboard::Clipboard);
|
|
||||||
} else if (act == actRemoveWatches) {
|
} else if (act == actRemoveWatches) {
|
||||||
currentEngine()->watchHandler()->clearWatches();
|
currentEngine()->watchHandler()->clearWatches();
|
||||||
} else if (act == actClearCodeModelSnapshot) {
|
} else if (act == actClearCodeModelSnapshot) {
|
||||||
|
Reference in New Issue
Block a user