Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make copying crash ID simple #25

Merged
merged 2 commits into from
Apr 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ if(POLICY CMP0071)
cmake_policy(SET CMP0071 NEW)
endif()

if(POLICY CMP0063)
cmake_policy(SET CMP0063 NEW)
endif()

option(ENABLE_GPL_CODE "Enable GPL-licensed depencencies of libcrashreporter-qt (dr.konqui integration)" OFF)
option(ENABLE_CRASH_REPORTER "Enable libcrashreporter-qt GUI component" ON)

Expand Down
22 changes: 21 additions & 1 deletion src/libcrashreporter-gui/CrashReporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
#include <QDir>
#include <QDateTime>
#include <QStandardPaths>
#include <QClipboard>
#include <QApplication>
#include <QLabel>

// #include "utils/TomahawkUtils.h"

Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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) );
}
}

Expand Down Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions src/libcrashreporter-gui/CrashReporter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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