Commit e682ab1d authored by Jean-Loup Haberbusch's avatar Jean-Loup Haberbusch Committed by jean-loup
Browse files

re-implement Bug Report Dialog feature with Thread

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@2155 ec899d31-69d1-42ba-9299-647d76f65fb3
parent ea6b1260
......@@ -73,6 +73,8 @@ Action::ApplyStatus AboutAction::apply() {
ReportBugDialog *bugDialog = new ReportBugDialog();
bugDialog->setBugReport();
QLabel *logo = new QLabel;
logo->setPixmap(QPixmap(":/camiTKIcon"));
......
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2015 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "GenerateBugReportProcess.h"
#include <Core.h>
class QThread;
void GenerateBugReportProcess::run() {
QString result(camitk::Core::getBugReport());
emit resultReady(result);
}
\ No newline at end of file
/*****************************************************************************
* $CAMITK_LICENCE_BEGIN$
*
* CamiTK - Computer Assisted Medical Intervention ToolKit
* (c) 2001-2015 UJF-Grenoble 1, CNRS, TIMC-IMAG UMR 5525 (GMCAO)
*
* Visit http://camitk.imag.fr for more information
*
* This file is part of CamiTK.
*
* CamiTK is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License version 3
* only, as published by the Free Software Foundation.
*
* CamiTK is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License version 3 for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* version 3 along with CamiTK. If not, see <http://www.gnu.org/licenses/>.
*
* $CAMITK_LICENCE_END$
****************************************************************************/
#include <QThread>
class GenerateBugReportProcess : public QThread
{
Q_OBJECT
public:
void run();
signals:
void resultReady(const QString &s);
};
\ No newline at end of file
......@@ -24,12 +24,9 @@
****************************************************************************/
#include "ReportBugDialog.h"
#include <Core.h>
// Qt stuff
#include <QDebug>
#include <QProcess>
#include <QFileInfo>
#include <QClipboard>
......@@ -40,69 +37,20 @@ ReportBugDialog::ReportBugDialog(QDialog* parent) : QDialog(parent) {
ui->setupUi(this);
ui->bugSystemLinkLabel->setOpenExternalLinks(true);
ui->bugSystemLinkLabel->setText(tr("<a href='https://bugzilla-timc.imag.fr/'>Bugzilla Bug Report Tool</a>"));
camitkConfigProcess = new QProcess;
generateReportBug();
connect(ui->copyButton, SIGNAL(clicked()), this, SLOT(copyReportToClipBoard()));
}
void ReportBugDialog::generateReportBug() {
QFileInfo checkFile(getProgramToExecute());
// check if file exists and if yes: Is it really a file and no directory?
if (checkFile.exists() && checkFile.isFile()) {
QStringList arguments;
arguments << "-b";
camitkConfigProcess->start(getProgramToExecute(), arguments);
connect(camitkConfigProcess, SIGNAL(readyReadStandardOutput()), this, SLOT(setBugReport()));
camitkConfigProcess->waitForFinished();
camitkConfigProcess->close();
}
else {
ui->bugReportTextEdit->append(tr("<b><font color='red'>Impossible to load ") + getProgramToExecute() + (" command !</font></b>"));
}
ui->bugReportTextEdit->setText("<font color='red'>Processing, please wait.....</font>");
}
QString ReportBugDialog::getProgramToExecute(){
QString stringOS;
QFileInfo checkFile(".");
QString absoluteFilePath = checkFile.absoluteFilePath();
QString program("");
// Some OS checking
#ifdef _WIN32
stringOS = "WIN32";
#endif
#ifdef __APPLE__
stringOS = "APPLE";
#endif
#ifdef __linux__
stringOS = "LINUX";
#endif
if (stringOS == "WIN32")
{
if (camitk::Core::isDebugBuild())
program = absoluteFilePath + "/camitk-config" + QString(camitk::Core::debugPostfix) + ".exe";
else
program = absoluteFilePath + "/camitk-config.exe";
}
else if (stringOS == "APPLE" || stringOS == "LINUX") {
program = absoluteFilePath + "/camitk-config";
}
return program;
void ReportBugDialog::showBugReport(const QString &bugReport){
ui->bugReportTextEdit->setText(bugReport);
}
void ReportBugDialog::setBugReport(){
QByteArray byteArray = camitkConfigProcess->readAllStandardOutput();
QStringList strLines = QString(byteArray).split("\n");
foreach(QString line, strLines){
ui->bugReportTextEdit->append(line);
}
void ReportBugDialog::setBugReport() {
GenerateBugReportProcess *bGProcess = new GenerateBugReportProcess();
connect(bGProcess, SIGNAL(resultReady(QString)), this, SLOT(showBugReport(QString)));
connect(bGProcess, SIGNAL(finished()), bGProcess, SLOT(deleteLater()));
bGProcess->start();
}
void ReportBugDialog::copyReportToClipBoard() {
......@@ -110,6 +58,7 @@ void ReportBugDialog::copyReportToClipBoard() {
clipboard->setText(ui->bugReportTextEdit->toPlainText());
}
// -------------------- destructor --------------------
ReportBugDialog::~ReportBugDialog() {
;
......
......@@ -27,18 +27,18 @@
#define REPORTBUGWIDGET_H
#include "ui_BugReportDialog.h"
#include "generateBugReportProcess.h"
#include <QDialog>
class QProcess;
class ReportBugDialog : public QDialog {
Q_OBJECT
QThread generateBugReportProcess;
public:
/// Default construtor
ReportBugDialog (QDialog* parent = 0);
void generateReportBug();
QString getProgramToExecute();
void setBugReport();
/// Destructor
......@@ -46,11 +46,10 @@ public:
private:
Ui::BugReportDialog *ui;
QProcess *camitkConfigProcess;
private slots:
void setBugReport();
void copyReportToClipBoard();
void showBugReport(const QString &bugReport);
};
#endif // REPORTBUGWIDGET_H
\ No newline at end of file
......@@ -48,7 +48,7 @@
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="39"/>
<source>&lt;a href=&quot;https://timc-bugzilla.imag.fr&quot;&gt;Bugzilla Bug Report Tool&lt;/a&gt;</source>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
......@@ -221,6 +221,14 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ReportBugDialog</name>
<message>
<location filename="../../../../src/sdk/actions/application/ReportBugDialog.cpp" line="40"/>
<source>&lt;a href=&apos;https://bugzilla-timc.imag.fr/&apos;&gt;Bugzilla Bug Report Tool&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SaveAction</name>
<message>
......
......@@ -48,7 +48,7 @@
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="39"/>
<source>&lt;a href=&quot;https://timc-bugzilla.imag.fr&quot;&gt;Bugzilla Bug Report Tool&lt;/a&gt;</source>
<source>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation type="unfinished"></translation>
</message>
<message>
......@@ -229,6 +229,14 @@
<translation>Détruire Component</translation>
</message>
</context>
<context>
<name>ReportBugDialog</name>
<message>
<location filename="../../../../src/sdk/actions/application/ReportBugDialog.cpp" line="40"/>
<source>&lt;a href=&apos;https://bugzilla-timc.imag.fr/&apos;&gt;Bugzilla Bug Report Tool&lt;/a&gt;</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>SaveAction</name>
<message>
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment