diff --git a/code/nel/tools/misc/crash_report/crash_report.cpp b/code/nel/tools/misc/crash_report/crash_report.cpp index e083de126..0c9e4fc93 100644 --- a/code/nel/tools/misc/crash_report/crash_report.cpp +++ b/code/nel/tools/misc/crash_report/crash_report.cpp @@ -88,5 +88,11 @@ int main( int argc, char **argv ) w.setup( params ); w.show(); - return app.exec(); + int ret = app.exec(); + + if( ret != EXIT_SUCCESS ) + return ret; + else + return w.getReturnValue(); + } \ No newline at end of file diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.cpp b/code/nel/tools/misc/crash_report/crash_report_widget.cpp index 968978f94..00b4c33bf 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -25,18 +25,24 @@ #include #include #include +#include +#include +#include CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) { + m_developerMode = false; + m_forceSend = false; + m_devSendReport = false; + m_returnValue = ERET_NULL; + m_ui.setupUi( this ); m_socket = new CCrashReportSocket( this ); QTimer::singleShot( 1, this, SLOT( onLoad() ) ); - connect( m_ui.sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); - connect( m_ui.canceButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( m_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) ); connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) ); @@ -59,6 +65,8 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: if( k == "log" ) { m_fileName = v.c_str(); + if( !QFile::exists( m_fileName ) ) + m_fileName.clear(); } else if( k == "host" ) @@ -70,25 +78,105 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: { setWindowTitle( v.c_str() ); } + else + if( k == "dev" ) + { + m_developerMode = true; + } + else + if( k == "sendreport" ) + { + m_forceSend = true; + } + } + + if( m_fileName.isEmpty() ) + { + m_ui.reportLabel->hide(); + m_ui.reportEdit->hide(); + } + + + if( m_socket->url().isEmpty() || m_fileName.isEmpty() ) + { + m_ui.descriptionEdit->hide(); + m_ui.emailCB->hide(); + m_ui.emailEdit->hide(); + m_ui.descrLabel->hide(); + } + + QHBoxLayout *hbl = new QHBoxLayout( this ); + + if( m_developerMode ) + { + if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() ) + { + m_ui.emailCB->setEnabled( false ); + + QCheckBox *cb = new QCheckBox( tr( "Send report" ), this ); + m_ui.gridLayout->addWidget( cb, 4, 0, 1, 1 ); + + m_ui.gridLayout->addWidget( m_ui.emailCB, 5, 0, 1, 1 ); + m_ui.gridLayout->addWidget( m_ui.emailEdit, 6, 0, 1, 1 ); + + connect( cb, SIGNAL( stateChanged( int ) ), this, SLOT( onSendCBClicked() ) ); + } + + QPushButton *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this ); + QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this ); + QPushButton *abortButton = new QPushButton( tr( "Abort" ), this ); + QPushButton *breakButton = new QPushButton( tr( "Break" ), this ); + + hbl->addWidget( alwaysIgnoreButton ); + hbl->addWidget( ignoreButton ); + hbl->addWidget( abortButton ); + hbl->addWidget( breakButton ); + + m_ui.gridLayout->addLayout( hbl, 7, 0, 1, 3 ); + + connect( alwaysIgnoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onAlwaysIgnoreClicked() ) ); + connect( ignoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onIgnoreClicked() ) ); + connect( abortButton, SIGNAL( clicked( bool ) ), this, SLOT( onAbortClicked() ) ); + connect( breakButton, SIGNAL( clicked( bool ) ), this, SLOT( onBreakClicked() ) ); + } + else + { + // If -host is specified, offer the send function + if( !m_socket->url().isEmpty() && !m_fileName.isEmpty() ) + { + QPushButton *sendButton = new QPushButton( tr( "Send report" ), this ); + connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); + hbl->addWidget( sendButton ); + + if( !m_forceSend ) + { + QPushButton *cancelButton = new QPushButton( tr( "Don't send report" ), this ); + connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + hbl->addWidget( cancelButton ); + } + } + // Otherwise only offer exit + else + { + QPushButton *exitButton = new QPushButton( tr( "Exit" ), this ); + connect( exitButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); + hbl->addWidget( exitButton ); + } + + m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 ); } } void CCrashReportWidget::onLoad() { - if( !checkSettings() ) - { - close(); + if( m_fileName.isEmpty() ) return; - } QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); if( !b ) { - QMessageBox::information( this, - tr( "No log file found" ), - tr( "There was no log file found, therefore nothing to report. Exiting..." ) ); - close(); + m_fileName.clear(); return; } @@ -99,13 +187,26 @@ void CCrashReportWidget::onLoad() void CCrashReportWidget::onSendClicked() { - m_ui.sendButton->setEnabled( false ); + if( m_developerMode && !m_devSendReport ) + { + close(); + return; + } + + if( m_socket->url().isEmpty() || m_fileName.isEmpty() ) + { + close(); + return; + } + QApplication::setOverrideCursor( Qt::WaitCursor ); SCrashReportData data; data.description = m_ui.descriptionEdit->toPlainText(); data.report = m_ui.reportEdit->toPlainText(); - data.email = m_ui.emailEdit->text(); + + if( m_ui.emailCB->isChecked() ) + data.email = m_ui.emailEdit->text(); m_socket->sendReport( data ); } @@ -120,6 +221,45 @@ void CCrashReportWidget::onCBClicked() m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); } +void CCrashReportWidget::onSendCBClicked() +{ + bool b = m_ui.emailCB->isEnabled(); + + if( b ) + { + m_ui.emailCB->setChecked( false ); + } + + m_ui.emailCB->setEnabled( !b ); + + m_devSendReport = !m_devSendReport; +} + +void CCrashReportWidget::onAlwaysIgnoreClicked() +{ + m_returnValue = ERET_ALWAYS_IGNORE; + onSendClicked(); +} + +void CCrashReportWidget::onIgnoreClicked() +{ + m_returnValue = ERET_IGNORE; + onSendClicked(); +} + +void CCrashReportWidget::onAbortClicked() +{ + m_returnValue = ERET_ABORT; + onSendClicked(); +} + +void CCrashReportWidget::onBreakClicked() +{ + m_returnValue = ERET_BREAK; + onSendClicked(); +} + + void CCrashReportWidget::onReportSent() { QApplication::setOverrideCursor( Qt::ArrowCursor ); @@ -142,30 +282,11 @@ void CCrashReportWidget::onReportFailed() removeAndQuit(); } -bool CCrashReportWidget::checkSettings() -{ - if( m_fileName.isEmpty() ) - { - QMessageBox::information( this, - tr( "No log file specified." ), - tr( "No log file specified. Exiting..." ) ); - return false; - } - - if( m_socket->url().isEmpty() ) - { - QMessageBox::information( this, - tr( "No host specified." ), - tr( "No host specified. Exiting..." ) ); - return false; - } - - return true; -} - void CCrashReportWidget::removeAndQuit() { - QFile::remove( m_fileName ); + if( !m_fileName.isEmpty() ) + QFile::remove( m_fileName ); + close(); } diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.h b/code/nel/tools/misc/crash_report/crash_report_widget.h index 61b56e340..f40e40854 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -31,29 +31,51 @@ class CCrashReportWidget : public QWidget { Q_OBJECT public: + + enum EReturnValue + { + ERET_NULL = 0, + ERET_ALWAYS_IGNORE = 21, + ERET_IGNORE = 22, + ERET_ABORT = 23, + ERET_BREAK = 24 + }; + CCrashReportWidget( QWidget *parent = NULL ); ~CCrashReportWidget(); void setFileName( const char *fn ){ m_fileName = fn; } void setup( const std::vector< std::pair< std::string, std::string > > ¶ms ); - + + EReturnValue getReturnValue() const{ return m_returnValue; } + private Q_SLOTS: void onLoad(); void onSendClicked(); void onCancelClicked(); void onCBClicked(); + void onSendCBClicked(); + + void onAlwaysIgnoreClicked(); + void onIgnoreClicked(); + void onAbortClicked(); + void onBreakClicked(); void onReportSent(); void onReportFailed(); private: - bool checkSettings(); void removeAndQuit(); Ui::CrashReportWidget m_ui; QString m_fileName; CCrashReportSocket *m_socket; + bool m_developerMode; + bool m_forceSend; + bool m_devSendReport; + + EReturnValue m_returnValue; }; #endif diff --git a/code/nel/tools/misc/crash_report/crash_report_widget.ui b/code/nel/tools/misc/crash_report/crash_report_widget.ui index 589810578..dec7e74ca 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -9,8 +9,8 @@ 0 0 - 400 - 407 + 406 + 430 @@ -18,40 +18,30 @@ - + What were you doing when the crash occured? - - - - + Contents of the report ( automatically generated ) - - - - true - - - Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse - - + + - + Email me if you have further questions, or updates on this issue - + false @@ -61,17 +51,13 @@ - - - - Send + + + + true - - - - - - Cancel + + Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse