Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dschmidt/libcrashreporter-qt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Müller <fmueller@owncloud.com>2021-03-13 01:42:30 +0300
committerFabian Müller <fmueller@owncloud.com>2021-03-13 01:42:30 +0300
commit60f13548198a19e468625768d2b0853f7fac88e3 (patch)
tree2acbcebe24f7cb32c5ce43e9b14b6ba6f23b3f73
parent76611fd501a4cff4f34d75ce10843a26c40deaa9 (diff)
Copy crash ID into clipboard when it's clicked on
-rw-r--r--src/libcrashreporter-gui/CrashReporter.cpp22
-rw-r--r--src/libcrashreporter-gui/CrashReporter.h1
2 files changed, 22 insertions, 1 deletions
diff --git a/src/libcrashreporter-gui/CrashReporter.cpp b/src/libcrashreporter-gui/CrashReporter.cpp
index d11b4ae..9f8891d 100644
--- a/src/libcrashreporter-gui/CrashReporter.cpp
+++ b/src/libcrashreporter-gui/CrashReporter.cpp
@@ -34,6 +34,9 @@
#include <QDir>
#include <QDateTime>
#include <QStandardPaths>
+#include <QClipboard>
+#include <QApplication>
+#include <QLabel>
// #include "utils/TomahawkUtils.h"
@@ -162,6 +165,10 @@ CrashReporter::CrashReporter( const QUrl& url, const QStringList& args )
m_ui->progressBar->setRange( 0, 0 );
}
#endif
+
+ // set up handler for clicked the link in the label that is used to let the user copy the crash ID easily
+ m_ui->progressLabel->setOpenExternalLinks(false);
+ connect(m_ui->progressLabel, &QLabel::linkActivated, this, &CrashReporter::onLinkClicked);
}
@@ -290,7 +297,7 @@ CrashReporter::onDone()
{
QString crashId = response.split("\n").at(0).split("=").at(1);
- m_ui->progressLabel->setText( tr( "Sent! <b>Many thanks</b>. Please refer to crash <b>%1</b> in bug reports." ).arg(crashId) );
+ m_ui->progressLabel->setText( tr( "Sent! <b>Many thanks</b>. Please refer to crash <a href=\"clipboard://%1\"><b>%1</b></a> (click to copy) in bug reports." ).arg(crashId) );
}
}
@@ -336,3 +343,16 @@ CrashReporter::setReportData(const QByteArray& name, const QByteArray& content,
m_formFileNames.insert( name, fileName );
}
}
+
+void
+CrashReporter::onLinkClicked(const QString& link)
+{
+ // we just have to handle clipboard "links", used to let the user copy the crash ID easily
+ // other links can be ignored
+ static const QString clipboardPrefix = "clipboard://";
+
+ if (link.startsWith(clipboardPrefix)) {
+ QString toCopyIntoClipboard = link.mid(clipboardPrefix.length());
+ QApplication::clipboard()->setText(toCopyIntoClipboard);
+ }
+}
diff --git a/src/libcrashreporter-gui/CrashReporter.h b/src/libcrashreporter-gui/CrashReporter.h
index 4a3bfa6..1da7b81 100644
--- a/src/libcrashreporter-gui/CrashReporter.h
+++ b/src/libcrashreporter-gui/CrashReporter.h
@@ -77,6 +77,7 @@ private slots:
void onProgress( qint64 done, qint64 total );
void onFail( int error, const QString& errorString );
void onSendButton();
+ void onLinkClicked(const QString& link);
};
#endif // CRASHREPORTER_H