mirror of
https://port.numenaute.org/aleajactaest/khanat-opennel-code.git
synced 2024-12-25 18:30:53 +00:00
Merge with feature-crashreport
This commit is contained in:
commit
98ff7c1535
4 changed files with 200 additions and 65 deletions
|
@ -88,5 +88,11 @@ int main( int argc, char **argv )
|
||||||
w.setup( params );
|
w.setup( params );
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
return app.exec();
|
int ret = app.exec();
|
||||||
|
|
||||||
|
if( ret != EXIT_SUCCESS )
|
||||||
|
return ret;
|
||||||
|
else
|
||||||
|
return w.getReturnValue();
|
||||||
|
|
||||||
}
|
}
|
|
@ -25,18 +25,24 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
|
#include <QPushButton>
|
||||||
|
#include <QHBoxLayout>
|
||||||
|
#include <QCheckBox>
|
||||||
|
|
||||||
CCrashReportWidget::CCrashReportWidget( QWidget *parent ) :
|
CCrashReportWidget::CCrashReportWidget( QWidget *parent ) :
|
||||||
QWidget( parent )
|
QWidget( parent )
|
||||||
{
|
{
|
||||||
|
m_developerMode = false;
|
||||||
|
m_forceSend = false;
|
||||||
|
m_devSendReport = false;
|
||||||
|
m_returnValue = ERET_NULL;
|
||||||
|
|
||||||
m_ui.setupUi( this );
|
m_ui.setupUi( this );
|
||||||
|
|
||||||
m_socket = new CCrashReportSocket( this );
|
m_socket = new CCrashReportSocket( this );
|
||||||
|
|
||||||
QTimer::singleShot( 1, this, SLOT( onLoad() ) );
|
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_ui.emailCB, SIGNAL( stateChanged( int ) ), this, SLOT( onCBClicked() ) );
|
||||||
|
|
||||||
connect( m_socket, SIGNAL( reportSent() ), this, SLOT( onReportSent() ) );
|
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" )
|
if( k == "log" )
|
||||||
{
|
{
|
||||||
m_fileName = v.c_str();
|
m_fileName = v.c_str();
|
||||||
|
if( !QFile::exists( m_fileName ) )
|
||||||
|
m_fileName.clear();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if( k == "host" )
|
if( k == "host" )
|
||||||
|
@ -70,25 +78,105 @@ void CCrashReportWidget::setup( const std::vector< std::pair< std::string, std::
|
||||||
{
|
{
|
||||||
setWindowTitle( v.c_str() );
|
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()
|
void CCrashReportWidget::onLoad()
|
||||||
{
|
{
|
||||||
if( !checkSettings() )
|
if( m_fileName.isEmpty() )
|
||||||
{
|
|
||||||
close();
|
|
||||||
return;
|
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 )
|
||||||
{
|
{
|
||||||
QMessageBox::information( this,
|
m_fileName.clear();
|
||||||
tr( "No log file found" ),
|
|
||||||
tr( "There was no log file found, therefore nothing to report. Exiting..." ) );
|
|
||||||
close();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,12 +187,25 @@ void CCrashReportWidget::onLoad()
|
||||||
|
|
||||||
void CCrashReportWidget::onSendClicked()
|
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 );
|
QApplication::setOverrideCursor( Qt::WaitCursor );
|
||||||
|
|
||||||
SCrashReportData data;
|
SCrashReportData data;
|
||||||
data.description = m_ui.descriptionEdit->toPlainText();
|
data.description = m_ui.descriptionEdit->toPlainText();
|
||||||
data.report = m_ui.reportEdit->toPlainText();
|
data.report = m_ui.reportEdit->toPlainText();
|
||||||
|
|
||||||
|
if( m_ui.emailCB->isChecked() )
|
||||||
data.email = m_ui.emailEdit->text();
|
data.email = m_ui.emailEdit->text();
|
||||||
|
|
||||||
m_socket->sendReport( data );
|
m_socket->sendReport( data );
|
||||||
|
@ -120,6 +221,45 @@ 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 );
|
||||||
|
|
||||||
|
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()
|
void CCrashReportWidget::onReportSent()
|
||||||
{
|
{
|
||||||
QApplication::setOverrideCursor( Qt::ArrowCursor );
|
QApplication::setOverrideCursor( Qt::ArrowCursor );
|
||||||
|
@ -142,30 +282,11 @@ 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()
|
||||||
{
|
{
|
||||||
|
if( !m_fileName.isEmpty() )
|
||||||
QFile::remove( m_fileName );
|
QFile::remove( m_fileName );
|
||||||
|
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,16 @@ class CCrashReportWidget : public QWidget
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
enum EReturnValue
|
||||||
|
{
|
||||||
|
ERET_NULL = 0,
|
||||||
|
ERET_ALWAYS_IGNORE = 21,
|
||||||
|
ERET_IGNORE = 22,
|
||||||
|
ERET_ABORT = 23,
|
||||||
|
ERET_BREAK = 24
|
||||||
|
};
|
||||||
|
|
||||||
CCrashReportWidget( QWidget *parent = NULL );
|
CCrashReportWidget( QWidget *parent = NULL );
|
||||||
~CCrashReportWidget();
|
~CCrashReportWidget();
|
||||||
|
|
||||||
|
@ -38,22 +48,34 @@ public:
|
||||||
|
|
||||||
void setup( const std::vector< std::pair< std::string, std::string > > ¶ms );
|
void setup( const std::vector< std::pair< std::string, std::string > > ¶ms );
|
||||||
|
|
||||||
|
EReturnValue getReturnValue() const{ return m_returnValue; }
|
||||||
|
|
||||||
private Q_SLOTS:
|
private Q_SLOTS:
|
||||||
void onLoad();
|
void onLoad();
|
||||||
void onSendClicked();
|
void onSendClicked();
|
||||||
void onCancelClicked();
|
void onCancelClicked();
|
||||||
void onCBClicked();
|
void onCBClicked();
|
||||||
|
void onSendCBClicked();
|
||||||
|
|
||||||
|
void onAlwaysIgnoreClicked();
|
||||||
|
void onIgnoreClicked();
|
||||||
|
void onAbortClicked();
|
||||||
|
void onBreakClicked();
|
||||||
|
|
||||||
void onReportSent();
|
void onReportSent();
|
||||||
void onReportFailed();
|
void onReportFailed();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool checkSettings();
|
|
||||||
void removeAndQuit();
|
void removeAndQuit();
|
||||||
|
|
||||||
Ui::CrashReportWidget m_ui;
|
Ui::CrashReportWidget m_ui;
|
||||||
QString m_fileName;
|
QString m_fileName;
|
||||||
CCrashReportSocket *m_socket;
|
CCrashReportSocket *m_socket;
|
||||||
|
bool m_developerMode;
|
||||||
|
bool m_forceSend;
|
||||||
|
bool m_devSendReport;
|
||||||
|
|
||||||
|
EReturnValue m_returnValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -9,8 +9,8 @@
|
||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>400</width>
|
<width>406</width>
|
||||||
<height>407</height>
|
<height>430</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
|
@ -18,40 +18,30 @@
|
||||||
</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="1" column="0" colspan="2">
|
|
||||||
<widget class="QPlainTextEdit" name="descriptionEdit"/>
|
|
||||||
</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>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="3" column="0" colspan="2">
|
<item row="1" column="0" colspan="3">
|
||||||
<widget class="QPlainTextEdit" name="reportEdit">
|
<widget class="QPlainTextEdit" name="descriptionEdit"/>
|
||||||
<property name="enabled">
|
|
||||||
<bool>true</bool>
|
|
||||||
</property>
|
|
||||||
<property name="textInteractionFlags">
|
|
||||||
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" colspan="2">
|
<item row="4" column="0" colspan="3">
|
||||||
<widget class="QCheckBox" name="emailCB">
|
<widget class="QCheckBox" name="emailCB">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Email me if you have further questions, or updates on this issue</string>
|
<string>Email me if you have further questions, or updates on this issue</string>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="5" column="0" colspan="2">
|
<item row="5" column="0" colspan="3">
|
||||||
<widget class="QLineEdit" name="emailEdit">
|
<widget class="QLineEdit" name="emailEdit">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
@ -61,17 +51,13 @@
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="6" column="0">
|
<item row="3" column="0" colspan="3">
|
||||||
<widget class="QPushButton" name="sendButton">
|
<widget class="QPlainTextEdit" name="reportEdit">
|
||||||
<property name="text">
|
<property name="enabled">
|
||||||
<string>Send</string>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
<property name="textInteractionFlags">
|
||||||
</item>
|
<set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
|
||||||
<item row="6" column="1">
|
|
||||||
<widget class="QPushButton" name="canceButton">
|
|
||||||
<property name="text">
|
|
||||||
<string>Cancel</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
|
Loading…
Reference in a new issue