Test: Add copy button (#25979)
* added a copy button which copies all the errors and traceback to clipboard * removed unused variable * removed space at end of Copy string * copied text notification in status bar * removed unwanted header * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Test: Address review comments --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
This commit is contained in:
@@ -122,6 +122,19 @@
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="copyButton">
|
||||
<property name="text">
|
||||
<string>&Copy</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Ctrl+C</string>
|
||||
</property>
|
||||
<property name="autoDefault">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="helpButton">
|
||||
<property name="text">
|
||||
@@ -151,7 +164,7 @@
|
||||
<item>
|
||||
<widget class="QPushButton" name="closeButton">
|
||||
<property name="text">
|
||||
<string>&Close</string>
|
||||
<string>Close</string>
|
||||
</property>
|
||||
<property name="shortcut">
|
||||
<string>Alt+C</string>
|
||||
@@ -300,6 +313,7 @@
|
||||
<tabstop>comboTests</tabstop>
|
||||
<tabstop>startButton</tabstop>
|
||||
<tabstop>treeViewFailure</tabstop>
|
||||
<tabstop>copyButton</tabstop>
|
||||
<tabstop>helpButton</tabstop>
|
||||
<tabstop>aboutButton</tabstop>
|
||||
<tabstop>closeButton</tabstop>
|
||||
|
||||
@@ -20,8 +20,12 @@
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "FCGlobal.h"
|
||||
|
||||
#include <QFontMetrics>
|
||||
#include <QMessageBox>
|
||||
#include <QClipboard>
|
||||
#include <QApplication>
|
||||
|
||||
|
||||
#include <Base/Interpreter.h>
|
||||
@@ -107,6 +111,7 @@ void UnitTestDialog::setupConnections()
|
||||
);
|
||||
connect(ui->helpButton, &QPushButton::clicked, this, &UnitTestDialog::onHelpButtonClicked);
|
||||
connect(ui->aboutButton, &QPushButton::clicked, this, &UnitTestDialog::onAboutButtonClicked);
|
||||
connect(ui->copyButton, &QPushButton::clicked, this, &UnitTestDialog::onCopyButtonClicked);
|
||||
connect(ui->startButton, &QPushButton::clicked, this, &UnitTestDialog::onStartButtonClicked);
|
||||
}
|
||||
|
||||
@@ -186,6 +191,21 @@ void UnitTestDialog::onAboutButtonClicked()
|
||||
);
|
||||
}
|
||||
|
||||
void UnitTestDialog::onCopyButtonClicked()
|
||||
{
|
||||
QString text;
|
||||
QTreeWidgetItemIterator it(ui->treeViewFailure);
|
||||
while (*it) {
|
||||
text += (*it)->data(0, Qt::UserRole).toString() + QStringLiteral("\n\n");
|
||||
++it;
|
||||
}
|
||||
if (text.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
QApplication::clipboard()->setText(text);
|
||||
setStatusText(tr("Errors copied to clipboard"));
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the unit tests.
|
||||
*/
|
||||
|
||||
@@ -70,6 +70,7 @@ private:
|
||||
void onTreeViewFailureItemDoubleClicked(QTreeWidgetItem* item, int column);
|
||||
void onHelpButtonClicked();
|
||||
void onAboutButtonClicked();
|
||||
void onCopyButtonClicked();
|
||||
void onStartButtonClicked();
|
||||
void setupConnections();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user