Skip to content

Commit e7c692b

Browse files
committed
Implement toolbar with copy all button for emv-viewer
This is for when the user wishes to copy all decoded items, including trailing invalid data or padding, to the clipboard. The edit-copy icon is not available in Windows and MacOS and therefore the action will only display the "Copy All" text on those platforms.
1 parent 63e98ee commit e7c692b

File tree

3 files changed

+73
-26
lines changed

3 files changed

+73
-26
lines changed

viewer/emv-viewer-mainwindow.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,12 @@ void EmvViewerMainWindow::on_treeView_itemCopyClicked(QTreeWidgetItem* item)
301301
QApplication::clipboard()->setText(str);
302302
}
303303

304+
void EmvViewerMainWindow::on_actionCopyAll_triggered()
305+
{
306+
QString str = treeView->toClipboardText(QStringLiteral(" "), 0);
307+
QApplication::clipboard()->setText(str);
308+
}
309+
304310
void EmvViewerMainWindow::on_descriptionText_linkActivated(const QString& link)
305311
{
306312
// Open link using external application

viewer/emv-viewer-mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ private slots: // connect-by-name helper functions
6060
void on_decodeObjectsCheckBox_stateChanged(int state);
6161
void on_treeView_itemPressed(QTreeWidgetItem* item, int column);
6262
void on_treeView_itemCopyClicked(QTreeWidgetItem* item);
63+
void on_actionCopyAll_triggered();
6364
void on_descriptionText_linkActivated(const QString& link);
6465

6566
protected:

viewer/emv-viewer-mainwindow.ui

Lines changed: 66 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
<property name="childrenCollapsible">
2424
<bool>false</bool>
2525
</property>
26-
<widget class="QWidget" name="layoutWidget">
26+
<widget class="QWidget" name="horizontalLayoutTopContainer">
2727
<layout class="QHBoxLayout" name="horizontalLayoutTop">
2828
<item>
2929
<widget class="QPlainTextEdit" name="dataEdit">
@@ -124,32 +124,61 @@
124124
<property name="childrenCollapsible">
125125
<bool>false</bool>
126126
</property>
127-
<widget class="EmvTreeView" name="treeView">
128-
<property name="minimumSize">
129-
<size>
130-
<width>300</width>
131-
<height>0</height>
132-
</size>
133-
</property>
134-
<property name="verticalScrollMode">
135-
<enum>QAbstractItemView::ScrollPerPixel</enum>
136-
</property>
137-
<property name="headerHidden">
138-
<bool>true</bool>
139-
</property>
140-
<property name="columnCount">
141-
<number>2</number>
142-
</property>
143-
<column>
144-
<property name="text">
145-
<string notr="true">Field</string>
146-
</property>
147-
</column>
148-
<column>
149-
<property name="text">
150-
<string notr="true">Buttons</string>
127+
<widget class="QWidget" name="treeViewContainer">
128+
<layout class="QVBoxLayout" name="treeViewLayout">
129+
<property name="spacing">
130+
<number>0</number>
151131
</property>
152-
</column>
132+
<item>
133+
<widget class="QToolBar" name="treeViewToolBar">
134+
<property name="maximumSize">
135+
<size>
136+
<width>16777215</width>
137+
<height>32</height>
138+
</size>
139+
</property>
140+
<property name="movable">
141+
<bool>false</bool>
142+
</property>
143+
<property name="toolButtonStyle">
144+
<enum>Qt::ToolButtonTextBesideIcon</enum>
145+
</property>
146+
<property name="floatable">
147+
<bool>false</bool>
148+
</property>
149+
<addaction name="actionCopyAll"/>
150+
</widget>
151+
</item>
152+
<item>
153+
<widget class="EmvTreeView" name="treeView">
154+
<property name="minimumSize">
155+
<size>
156+
<width>300</width>
157+
<height>0</height>
158+
</size>
159+
</property>
160+
<property name="verticalScrollMode">
161+
<enum>QAbstractItemView::ScrollPerPixel</enum>
162+
</property>
163+
<property name="headerHidden">
164+
<bool>true</bool>
165+
</property>
166+
<property name="columnCount">
167+
<number>2</number>
168+
</property>
169+
<column>
170+
<property name="text">
171+
<string notr="true">Field</string>
172+
</property>
173+
</column>
174+
<column>
175+
<property name="text">
176+
<string notr="true">Buttons</string>
177+
</property>
178+
</column>
179+
</widget>
180+
</item>
181+
</layout>
153182
</widget>
154183
<widget class="BetterPlainTextEdit" name="descriptionText">
155184
<property name="minimumSize">
@@ -167,6 +196,17 @@
167196
</item>
168197
</layout>
169198
</widget>
199+
<action name="actionCopyAll">
200+
<property name="icon">
201+
<iconset theme="edit-copy"/>
202+
</property>
203+
<property name="text">
204+
<string>Copy All</string>
205+
</property>
206+
<property name="toolTip">
207+
<string>Copy all fields to clipboard</string>
208+
</property>
209+
</action>
170210
</widget>
171211
<customwidgets>
172212
<customwidget>

0 commit comments

Comments
 (0)