Some more GUI changes.

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

View file

@ -27,6 +27,7 @@
#include <QFile> #include <QFile>
#include <QPushButton> #include <QPushButton>
#include <QHBoxLayout> #include <QHBoxLayout>
#include <QCheckBox>
CCrashReportWidget::CCrashReportWidget( QWidget *parent ) : CCrashReportWidget::CCrashReportWidget( QWidget *parent ) :
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 ); QHBoxLayout *hbl = new QHBoxLayout( this );
if( m_developerMode ) 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 *alwaysIgnoreButton = new QPushButton( tr( "Always Ignore" ), this );
QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this ); QPushButton *ignoreButton = new QPushButton( tr( "Ignore" ), this );
QPushButton *abortButton = new QPushButton( tr( "Abort" ), 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( abortButton );
hbl->addWidget( breakButton ); 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( alwaysIgnoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onAlwaysIgnoreClicked() ) );
connect( ignoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onIgnoreClicked() ) ); connect( ignoreButton, SIGNAL( clicked( bool ) ), this, SLOT( onIgnoreClicked() ) );
@ -107,6 +136,9 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::
connect( breakButton, SIGNAL( clicked( bool ) ), this, SLOT( onBreakClicked() ) ); connect( breakButton, SIGNAL( clicked( bool ) ), this, SLOT( onBreakClicked() ) );
} }
else else
{
// If -host is specified, offer the send function
if( !m_socket->url().isEmpty() )
{ {
QPushButton *sendButton = new QPushButton( tr( "Send report" ), this ); QPushButton *sendButton = new QPushButton( tr( "Send report" ), this );
connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) ); connect( sendButton, SIGNAL( clicked( bool ) ), this, SLOT( onSendClicked() ) );
@ -118,6 +150,14 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::
connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) ); connect( cancelButton, SIGNAL( clicked( bool ) ), this, SLOT( onCancelClicked() ) );
hbl->addWidget( cancelButton ); 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 ); m_ui.gridLayout->addLayout( hbl, 6, 0, 1, 3 );
} }
@ -125,14 +165,9 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::
void CCrashReportWidget::onLoad() void CCrashReportWidget::onLoad()
{ {
if( m_fileName.isEmpty() )
return; return;
if( !checkSettings() )
{
close();
return;
}
QFile f( m_fileName ); QFile f( m_fileName );
bool b = f.open( QFile::ReadOnly | QFile::Text ); bool b = f.open( QFile::ReadOnly | QFile::Text );
if( !b ) if( !b )
@ -171,6 +206,18 @@ void CCrashReportWidget::onCBClicked()
m_ui.emailEdit->setEnabled( m_ui.emailCB->isChecked() ); 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() void CCrashReportWidget::onAlwaysIgnoreClicked()
{ {
m_returnValue = ERET_ALWAYS_IGNORE; m_returnValue = ERET_ALWAYS_IGNORE;
@ -218,27 +265,6 @@ void CCrashReportWidget::onReportFailed()
removeAndQuit(); 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() void CCrashReportWidget::removeAndQuit()
{ {
QFile::remove( m_fileName ); QFile::remove( m_fileName );

View file

@ -55,6 +55,7 @@ private Q_SLOTS:
void onSendClicked(); void onSendClicked();
void onCancelClicked(); void onCancelClicked();
void onCBClicked(); void onCBClicked();
void onSendCBClicked();
void onAlwaysIgnoreClicked(); void onAlwaysIgnoreClicked();
void onIgnoreClicked(); void onIgnoreClicked();
@ -65,7 +66,6 @@ private Q_SLOTS:
void onReportFailed(); void onReportFailed();
private: private:
bool checkSettings();
void removeAndQuit(); void removeAndQuit();
Ui::CrashReportWidget m_ui; Ui::CrashReportWidget m_ui;

View file

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