From 1da76b3706a6c9bd41bf8f219d7c97de5e1e5c7f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 26 Apr 2024 19:44:18 +0200 Subject: Merging upstream version 4.2.4. Signed-off-by: Daniel Baumann --- ui/qt/utils/data_printer.cpp | 13 +++++++++++++ ui/qt/utils/data_printer.h | 1 + 2 files changed, 14 insertions(+) (limited to 'ui/qt/utils') diff --git a/ui/qt/utils/data_printer.cpp b/ui/qt/utils/data_printer.cpp index 36f1abd7..a96e1ed4 100644 --- a/ui/qt/utils/data_printer.cpp +++ b/ui/qt/utils/data_printer.cpp @@ -54,6 +54,14 @@ void DataPrinter::toClipboard(DataPrinter::DumpType type, IDataPrintable * print for (int i = 0; i < printData.length(); i++) clipboard_text += QString("%1").arg((uint8_t) printData[i], 2, 16, QChar('0')); break; + case DP_PrintableText: + for (int i = 0; i < printData.length(); i++) { + QChar ch(printData[i]); + if (ch.isSpace() || ch.isPrint()) { + clipboard_text += ch; + } + } + break; case DP_Base64: #if WS_IS_AT_LEAST_GNUC_VERSION(12,1) DIAG_OFF(stringop-overread) @@ -219,6 +227,11 @@ QActionGroup * DataPrinter::copyActions(QObject * copyClass, QObject * data) action->setProperty("printertype", DataPrinter::DP_HexOnly); connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); + action = new QAction(tr("…as Printable Text"), actions); + action->setToolTip(tr("Copy only the printable text in the packet.")); + action->setProperty("printertype", DataPrinter::DP_PrintableText); + connect(action, &QAction::triggered, dpi, &DataPrinter::copyIDataBytes); + action = new QAction(tr("…as a Hex Stream"), actions); action->setToolTip(tr("Copy packet bytes as a stream of hex.")); action->setProperty("printertype", DataPrinter::DP_HexStream); diff --git a/ui/qt/utils/data_printer.h b/ui/qt/utils/data_printer.h index 85f11c36..882b5752 100644 --- a/ui/qt/utils/data_printer.h +++ b/ui/qt/utils/data_printer.h @@ -30,6 +30,7 @@ public: DP_HexDump, DP_HexOnly, DP_HexStream, + DP_PrintableText, DP_CString, DP_MimeData, DP_Base64 -- cgit v1.2.3