Skip to content

Commit

Permalink
Add contextmenu to copy key:value in Dev Tools Panel
Browse files Browse the repository at this point in the history
In the Debugging/Development Tools panel, in the Network Logger tab
you see a lot of Request information: Header information,
Query string parts etc etc presented as key:value pairs in the Treeview.

Sometimes (mostly the value) strings can be pretty long.
This adds a context menu (right click on the node) to copy the
key: value as a string to the clipboard.
  • Loading branch information
rduivenvoorde authored and nyalldawson committed Sep 17, 2021
1 parent c70e346 commit 73489ab
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/app/devtools/networklogger/qgsnetworkloggernode.cpp
Expand Up @@ -165,6 +165,21 @@ QVariant QgsNetworkLoggerValueNode::data( int role ) const
return QVariant();
}

QList<QAction *> QgsNetworkLoggerValueNode::actions( QObject *parent )
{
QList< QAction * > res;

QAction *copyAction = new QAction( QObject::tr( "Copy key: value" ), parent );
QObject::connect( copyAction, &QAction::triggered, copyAction, [ = ]
{
QApplication::clipboard()->setText( QStringLiteral( "%1: %2" ).arg( mKey, mValue ) );
} );

res << copyAction;

return res;
}

//
// QgsNetworkLoggerGroup
//
Expand Down
1 change: 1 addition & 0 deletions src/app/devtools/networklogger/qgsnetworkloggernode.h
Expand Up @@ -170,6 +170,7 @@ class QgsNetworkLoggerValueNode : public QgsNetworkLoggerNode

QVariant data( int role = Qt::DisplayRole ) const override final;
int childCount() const override final { return 0; }
QList< QAction * > actions( QObject *parent ) override final;

private:

Expand Down

0 comments on commit 73489ab

Please sign in to comment.