From 374d966069911a3daf60f551937aed308aac9173 Mon Sep 17 00:00:00 2001 From: dfighter1985 Date: Mon, 2 Mar 2015 21:06:01 +0100 Subject: [PATCH] Some more GUI changes. --HG-- branch : feature-crashreport --- .../misc/crash_report/crash_report_widget.cpp | 98 ++++++++++++------- .../misc/crash_report/crash_report_widget.h | 4 +- .../misc/crash_report/crash_report_widget.ui | 4 +- 3 files changed, 66 insertions(+), 40 deletions(-) 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 609c58562..350a35ff8 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.cpp +++ b/code/nel/tools/misc/crash_report/crash_report_widget.cpp @@ -27,6 +27,7 @@ #include #include #include +#include CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : QWidget( parent ) @@ -85,10 +86,38 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: } } + if( m_fileName.isEmpty() ) + { + m_ui.reportLabel->hide(); + m_ui.reportEdit->hide(); + } + + // When no -host specified no custom entry and email fields + if( m_socket->url().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_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 ); @@ -99,7 +128,7 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: hbl->addWidget( abortButton ); hbl->addWidget( breakButton ); - m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 ); + 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() ) ); @@ -108,15 +137,26 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: } else { - QPushButton *sendButton = new QPushButton( tr( "Send report" ), this ); - connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); - hbl->addWidget( sendButton ); - - if( !m_forceSend ) + // If -host is specified, offer the send function + if( !m_socket->url().isEmpty() ) { - QPushButton *cancelButton = new QPushButton( tr( "Don't send report" ), this ); - connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); - hbl->addWidget( cancelButton ); + 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 ); @@ -125,13 +165,8 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std:: void CCrashReportWidget::onLoad() { - return; - - if( !checkSettings() ) - { - close(); + if( m_fileName.isEmpty() ) return; - } QFile f( m_fileName ); bool b = f.open( QFile::ReadOnly | QFile::Text ); @@ -171,6 +206,18 @@ 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 ); +} + void CCrashReportWidget::onAlwaysIgnoreClicked() { m_returnValue = ERET_ALWAYS_IGNORE; @@ -218,27 +265,6 @@ 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 ); 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 db3d85b47..a0468a565 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.h +++ b/code/nel/tools/misc/crash_report/crash_report_widget.h @@ -49,12 +49,13 @@ public: 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(); @@ -65,7 +66,6 @@ private Q_SLOTS: void onReportFailed(); private: - bool checkSettings(); void removeAndQuit(); Ui::CrashReportWidget m_ui; 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 ed252eb07..dec7e74ca 100644 --- a/code/nel/tools/misc/crash_report/crash_report_widget.ui +++ b/code/nel/tools/misc/crash_report/crash_report_widget.ui @@ -18,14 +18,14 @@ - + What were you doing when the crash occured? - + Contents of the report ( automatically generated )