forked from qt-creator/qt-creator
ClangTools: Add copy to clipboard action to diagnostic mark
Fixes: QTCREATORBUG-25110 Change-Id: Ie20e85fc6690dd23f8cb1e28f9e2a593c8e0479e Reviewed-by: André Hartmann <aha_1980@gmx.de> Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -30,6 +30,10 @@
|
||||
|
||||
#include <utils/utilsicons.h>
|
||||
|
||||
#include <QAction>
|
||||
#include <QApplication>
|
||||
#include <QClipboard>
|
||||
|
||||
namespace ClangTools {
|
||||
namespace Internal {
|
||||
|
||||
@@ -48,6 +52,20 @@ DiagnosticMark::DiagnosticMark(const Diagnostic &diagnostic)
|
||||
setIcon(markIcon.isNull() ? Utils::Icons::CODEMODEL_WARNING.icon() : markIcon);
|
||||
setToolTip(createDiagnosticToolTipString(diagnostic, Utils::nullopt, true));
|
||||
setLineAnnotation(diagnostic.description);
|
||||
|
||||
// Copy to clipboard action
|
||||
QVector<QAction *> actions;
|
||||
QAction *action = new QAction();
|
||||
action->setIcon(QIcon::fromTheme("edit-copy", Utils::Icons::COPY.icon()));
|
||||
QObject::connect(action, &QAction::triggered, [diagnostic]() {
|
||||
const QString text = createFullLocationString(diagnostic.location)
|
||||
+ ": "
|
||||
+ diagnostic.description;
|
||||
QApplication::clipboard()->setText(text);
|
||||
});
|
||||
actions << action;
|
||||
|
||||
setActions(actions);
|
||||
}
|
||||
|
||||
void DiagnosticMark::disable()
|
||||
|
||||
Reference in New Issue
Block a user