Some more GUI changes.

This commit is contained in:
dfighter1985 2015-03-02 21:06:01 +01:00
parent da6391ec1e
commit a579fbc924
3 changed files with 66 additions and 40 deletions

View file

@ -27,6 +27,7 @@
#include <QFile>
#include <QPushButton>
#include <QHBoxLayout>
#include <QCheckBox>
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 );

View file

@ -49,12 +49,13 @@ public:
void setup( const std::vector< std::pair< std::string, std::string > > &params );
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;

View file

@ -18,14 +18,14 @@
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="2">
<widget class="QLabel" name="label">
<widget class="QLabel" name="descrLabel">
<property name="text">
<string>What were you doing when the crash occured?</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QLabel" name="label_2">
<widget class="QLabel" name="reportLabel">
<property name="text">
<string>Contents of the report ( automatically generated )</string>
</property>