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

Adding a new Dialog to get Bug Report in a QTextEdit from "camitk-config -b"...

Adding a new Dialog to get Bug Report in a QTextEdit from "camitk-config -b" command with a "copy to clipboard" feature.

git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@2152 ec899d31-69d1-42ba-9299-647d76f65fb3
parent 24a6e123
......@@ -23,6 +23,7 @@
* $CAMITK_LICENCE_END$
****************************************************************************/
#include "AboutAction.h"
#include "ReportBugDialog.h"
#include <Application.h>
#include <Core.h>
......@@ -32,6 +33,7 @@ using namespace camitk;
#include <QBoxLayout>
#include <QLabel>
#include <QDialogButtonBox>
#include <QPushButton>
#include <vtkVersion.h>
......@@ -65,6 +67,11 @@ Action::ApplyStatus AboutAction::apply() {
aboutDialog->setWindowTitle(tr("About ") + Application::getName() + "...");
QVBoxLayout *dialogLayout = new QVBoxLayout;
QHBoxLayout *informationLayout = new QHBoxLayout;
QGridLayout *buttonGrid = new QGridLayout;
QPushButton *reportBugButton = new QPushButton(aboutDialog);
reportBugButton->setText("Report Bug");
ReportBugDialog *bugDialog = new ReportBugDialog();
QLabel *logo = new QLabel;
logo->setPixmap(QPixmap(":/camiTKIcon"));
......@@ -88,10 +95,13 @@ Action::ApplyStatus AboutAction::apply() {
informationLayout->addWidget(logo);
informationLayout->addWidget(text);
dialogLayout->addLayout(informationLayout);
dialogLayout->addLayout(buttonGrid);
QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, SIGNAL(accepted()), aboutDialog, SLOT(accept()));
dialogLayout->addWidget(buttonBox);
connect(reportBugButton, SIGNAL(clicked()), bugDialog, SLOT(exec()));
buttonGrid->addWidget(buttonBox,0,1);
buttonGrid->addWidget(reportBugButton,0,2);
aboutDialog->setLayout(dialogLayout);
aboutDialog->setWindowIcon(QPixmap(":/camiTKIcon"));
......
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>BugReportDialog</class>
<widget class="QDialog" name="BugReportDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>Report Bug Dialog</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>10</y>
<width>781</width>
<height>47</height>
</rect>
</property>
<layout class="QVBoxLayout" name="labelLayout">
<item>
<widget class="QLabel" name="descriptionLabel">
<property name="text">
<string>Generated bug report to complete and paste in the :</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="bugSystemLinkLabel">
<property name="text">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;br/&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QTextEdit" name="bugReportTextEdit">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>781</width>
<height>491</height>
</rect>
</property>
</widget>
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>550</x>
<y>560</y>
<width>241</width>
<height>31</height>
</rect>
</property>
<layout class="QGridLayout" name="buttonLayout" rowstretch="0" rowminimumheight="0" columnminimumwidth="0,0">
<property name="leftMargin">
<number>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="1">
<widget class="QPushButton" name="closeButton">
<property name="text">
<string>Close</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QPushButton" name="copyButton">
<property name="text">
<string>Copy to Clilpboard</string>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
<tabstops>
<tabstop>closeButton</tabstop>
<tabstop>copyButton</tabstop>
<tabstop>bugReportTextEdit</tabstop>
</tabstops>
<resources/>
<connections>
<connection>
<sender>closeButton</sender>
<signal>clicked()</signal>
<receiver>BugReportDialog</receiver>
<slot>close()</slot>
<hints>
<hint type="sourcelabel">
<x>770</x>
<y>564</y>
</hint>
<hint type="destinationlabel">
<x>199</x>
<y>149</y>
</hint>
</hints>
</connection>
</connections>
</ui>
/*****************************************************************************
* $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 "ReportBugDialog.h">
#include <Core.h>
// Qt stuff
#include <QDebug>
#include <QProcess>
#include <QFileInfo>
#include <QClipboard>
// -------------------- constructor --------------------
ReportBugDialog::ReportBugDialog(QDialog* parent) : QDialog(parent) {
ui = new Ui::BugReportDialog();
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>"));
}
}
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") {
if (camitk::Core::isDebugBuild())
program = absoluteFilePath + "/camitk-config" + QString(camitk::Core::debugPostfix);
else
program = absoluteFilePath + "/camitk-config";
}
return program;
}
void ReportBugDialog::setBugReport(){
QByteArray byteArray = camitkConfigProcess->readAllStandardOutput();
QStringList strLines = QString(byteArray).split("\n");
foreach(QString line, strLines){
ui->bugReportTextEdit->append(line);
}
}
void ReportBugDialog::copyReportToClipBoard() {
QClipboard *clipboard = QApplication::clipboard();
clipboard->setText(ui->bugReportTextEdit->toPlainText());
}
// -------------------- destructor --------------------
ReportBugDialog::~ReportBugDialog() {
;
}
\ 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$
****************************************************************************/
#ifndef REPORTBUGWIDGET_H
#define REPORTBUGWIDGET_H
#include "ui_BugReportDialog.h"
#include <QDialog>
class QProcess;
class ReportBugDialog : public QDialog {
Q_OBJECT
public:
/// Default construtor
ReportBugDialog (QDialog* parent = 0);
void generateReportBug();
QString getProgramToExecute();
/// Destructor
virtual ~ReportBugDialog();
private:
Ui::BugReportDialog *ui;
QProcess *camitkConfigProcess;
private slots:
void setBugReport();
void copyReportToClipBoard();
};
#endif // REPORTBUGWIDGET_H
\ No newline at end of file
......@@ -34,6 +34,34 @@
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>BugReportDialog</name>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="14"/>
<source>Report Bug Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="32"/>
<source>Generated bug report to complete and paste in the :</source>
<translation type="unfinished"></translation>
</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>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="74"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="81"/>
<source>Copy to Clilpboard</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChangeLanguage</name>
<message>
......
......@@ -34,6 +34,34 @@
<translation></translation>
</message>
</context>
<context>
<name>BugReportDialog</name>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="14"/>
<source>Report Bug Dialog</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="32"/>
<source>Generated bug report to complete and paste in the :</source>
<translation type="unfinished"></translation>
</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>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="74"/>
<source>Close</source>
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../../../../src/sdk/actions/application/BugReportDialog.ui" line="81"/>
<source>Copy to Clilpboard</source>
<translation type="unfinished"></translation>
</message>
</context>
<context>
<name>ChangeLanguage</name>
<message>
......
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