Skip to content

Commit 6c41bdf

Browse files
committedMay 7, 2017
Fix #16474 - Clean up formatting of crash report data
1 parent ddbb170 commit 6c41bdf

File tree

6 files changed

+82
-54
lines changed

6 files changed

+82
-54
lines changed
 

‎src/app/qgscrashdialog.cpp

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ QgsCrashDialog::QgsCrashDialog( QWidget *parent )
4242

4343
void QgsCrashDialog::setBugReport( const QString &reportData )
4444
{
45-
mReportDetailsText->setPlainText( reportData );
45+
mReportData = reportData;
46+
mReportDetailsText->setHtml( reportData );
4647
}
4748

4849
void QgsCrashDialog::showReportWidget()
@@ -52,8 +53,19 @@ void QgsCrashDialog::showReportWidget()
5253
void QgsCrashDialog::createBugReport()
5354
{
5455
QClipboard *clipboard = QApplication::clipboard();
55-
QString userText = "User Feedback\n=============\n" + mUserFeedbackText->toPlainText();
56-
QString details = "Report Details\n==============\n" + mReportDetailsText->toPlainText();
56+
QString userText = "h2. User Feedback\n\n" + mUserFeedbackText->toPlainText();
57+
QString details = "h2. Report Details\n\n" + mReportData;
5758
QString finalText = userText + "\n\n" + details;
58-
clipboard->setText( finalText );
59+
QString markdown = htmlToMarkdown( finalText );
60+
clipboard->setText( markdown );
5961
}
62+
63+
QString QgsCrashDialog::htmlToMarkdown( const QString &html ) const
64+
{
65+
QString markdown = html;
66+
markdown.replace( "<br>", "\n" );
67+
markdown.replace( "<b>", "*" );
68+
markdown.replace( "</b>", "*" );
69+
return markdown;
70+
}
71+

‎src/app/qgscrashdialog.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,14 @@ class APP_EXPORT QgsCrashDialog : public QDialog, private Ui::QgsCrashDialog
4141

4242
void setBugReport( const QString &reportData );
4343

44+
static QString htmlToMarkdown( const QString &html );
45+
4446
private slots:
4547
void showReportWidget();
4648
void createBugReport();
49+
50+
private:
51+
QString mReportData;
4752
};
4853

4954
#endif // QGSCRASHDIALOG_H

‎src/app/qgscrashhandler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void QgsCrashHandler::showCrashDialog( const QgsStackLines &stack )
3939
QgsCrashDialog dlg( QApplication::activeWindow() );
4040
QgsCrashReport report;
4141
report.setStackTrace( stack );
42-
dlg.setBugReport( report.toString() );
42+
dlg.setBugReport( report.toHtml() );
4343
if ( dlg.exec() )
4444
{
4545
restartApplication();

‎src/app/qgscrashreport.cpp

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,15 @@ void QgsCrashReport::setFlags( QgsCrashReport::Flags flags )
3333
mFlags = flags;
3434
}
3535

36-
const QString QgsCrashReport::toString() const
36+
const QString QgsCrashReport::toHtml() const
3737
{
3838
QStringList reportData;
39-
reportData.append( "Crash ID: " + crashID() );
39+
reportData.append( "<b>Crash ID</b>: " + crashID() );
4040

4141
if ( flags().testFlag( QgsCrashReport::Stack ) )
4242
{
43-
reportData.append( "\n" );
44-
reportData.append( "Stack Trace" );
45-
reportData.append( "===========" );
43+
reportData.append( "<br>" );
44+
reportData.append( "<b>Stack Trace</b>" );
4645
if ( mStackTrace.isEmpty() )
4746
{
4847
reportData.append( "Stack trace unable to be generated." );
@@ -60,25 +59,22 @@ const QString QgsCrashReport::toString() const
6059

6160
if ( flags().testFlag( QgsCrashReport::Plugins ) )
6261
{
63-
reportData.append( "\n" );
64-
reportData.append( "Plugins" );
65-
reportData.append( "=======" );
62+
reportData.append( "<br>" );
63+
reportData.append( "<b>Plugins</b>" );
6664
// TODO Get plugin info
6765
}
6866

6967
if ( flags().testFlag( QgsCrashReport::ProjectDetails ) )
7068
{
71-
reportData.append( "\n" );
72-
reportData.append( "Project Info" );
73-
reportData.append( "============" );
69+
reportData.append( "<br>" );
70+
reportData.append( "<b>Project Info</b>" );
7471
// TODO Get project details
7572
}
7673

7774
if ( flags().testFlag( QgsCrashReport::QgisInfo ) )
7875
{
79-
reportData.append( "\n" );
80-
reportData.append( "QGIS Info" );
81-
reportData.append( "=========" );
76+
reportData.append( "<br>" );
77+
reportData.append( "<b>QGIS Info</b>" );
8278
reportData.append( QString( "QGIS Version: %1" ).arg( Qgis::QGIS_VERSION ) );
8379

8480
if ( QString( Qgis::QGIS_DEV_VERSION ) == QLatin1String( "exported" ) )
@@ -100,9 +96,8 @@ const QString QgsCrashReport::toString() const
10096

10197
if ( flags().testFlag( QgsCrashReport::SystemInfo ) )
10298
{
103-
reportData.append( "\n" );
104-
reportData.append( "System Info" );
105-
reportData.append( "===========" );
99+
reportData.append( "<br>" );
100+
reportData.append( "<b>System Info</b>" );
106101
reportData.append( QString( "CPU Type: %1" ).arg( QSysInfo::currentCpuArchitecture() ) );
107102
reportData.append( QString( "Kernel Type: %1" ).arg( QSysInfo::kernelType() ) );
108103
reportData.append( QString( "Kernel Version: %1" ).arg( QSysInfo::kernelVersion() ) );
@@ -111,7 +106,7 @@ const QString QgsCrashReport::toString() const
111106
QString report;
112107
Q_FOREACH ( QString line, reportData )
113108
{
114-
report += line + "\n";
109+
report += line + "<br>";
115110
}
116111
return report;
117112
}

‎src/app/qgscrashreport.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ class APP_EXPORT QgsCrashReport
7575
* Generate a string version of the report.
7676
* \return A formatted string including all the information from the report.
7777
*/
78-
const QString toString() const;
78+
const QString toHtml() const;
7979

8080
/**
8181
* Generates a crash ID for the crash report.

‎src/ui/qgscrashdialog.ui

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
<rect>
77
<x>0</x>
88
<y>0</y>
9-
<width>583</width>
10-
<height>644</height>
9+
<width>522</width>
10+
<height>636</height>
1111
</rect>
1212
</property>
1313
<property name="palette">
@@ -450,6 +450,16 @@
450450
<property name="topMargin">
451451
<number>1</number>
452452
</property>
453+
<item row="2" column="0" colspan="2">
454+
<widget class="QLabel" name="label_3">
455+
<property name="text">
456+
<string>Report Details</string>
457+
</property>
458+
<property name="wordWrap">
459+
<bool>true</bool>
460+
</property>
461+
</widget>
462+
</item>
453463
<item row="5" column="0" colspan="3">
454464
<layout class="QHBoxLayout" name="horizontalLayout">
455465
<property name="topMargin">
@@ -490,16 +500,20 @@
490500
</item>
491501
</layout>
492502
</item>
493-
<item row="3" column="0" colspan="3">
494-
<widget class="QPlainTextEdit" name="mReportDetailsText">
495-
<property name="sizePolicy">
496-
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
497-
<horstretch>0</horstretch>
498-
<verstretch>0</verstretch>
499-
</sizepolicy>
503+
<item row="0" column="2">
504+
<widget class="QPushButton" name="mCopyReportButton">
505+
<property name="text">
506+
<string>Copy Report</string>
500507
</property>
501-
<property name="verticalScrollBarPolicy">
502-
<enum>Qt::ScrollBarAlwaysOn</enum>
508+
</widget>
509+
</item>
510+
<item row="0" column="0" colspan="2">
511+
<widget class="QLabel" name="label">
512+
<property name="text">
513+
<string>Tell us something about when you got the crash</string>
514+
</property>
515+
<property name="wordWrap">
516+
<bool>true</bool>
503517
</property>
504518
</widget>
505519
</item>
@@ -522,29 +536,31 @@
522536
</property>
523537
</widget>
524538
</item>
525-
<item row="0" column="2">
526-
<widget class="QPushButton" name="mCopyReportButton">
527-
<property name="text">
528-
<string>Copy Report</string>
539+
<item row="6" column="0" colspan="3">
540+
<spacer name="verticalSpacer">
541+
<property name="orientation">
542+
<enum>Qt::Vertical</enum>
529543
</property>
530-
</widget>
531-
</item>
532-
<item row="0" column="0" colspan="2">
533-
<widget class="QLabel" name="label">
534-
<property name="text">
535-
<string>Tell us something about when you got the crash</string>
544+
<property name="sizeHint" stdset="0">
545+
<size>
546+
<width>20</width>
547+
<height>0</height>
548+
</size>
536549
</property>
537-
<property name="wordWrap">
538-
<bool>true</bool>
539-
</property>
540-
</widget>
550+
</spacer>
541551
</item>
542-
<item row="2" column="0" colspan="2">
543-
<widget class="QLabel" name="label_3">
544-
<property name="text">
545-
<string>Report Details</string>
552+
<item row="3" column="0" colspan="3">
553+
<widget class="QTextEdit" name="mReportDetailsText">
554+
<property name="sizePolicy">
555+
<sizepolicy hsizetype="Expanding" vsizetype="Preferred">
556+
<horstretch>0</horstretch>
557+
<verstretch>0</verstretch>
558+
</sizepolicy>
546559
</property>
547-
<property name="wordWrap">
560+
<property name="verticalScrollBarPolicy">
561+
<enum>Qt::ScrollBarAlwaysOn</enum>
562+
</property>
563+
<property name="readOnly">
548564
<bool>true</bool>
549565
</property>
550566
</widget>

0 commit comments

Comments
 (0)
Please sign in to comment.