Adding #685 (Adding a report issue button) (#1165)

* Added GUI elements for automatically opening Github issues

* Made the UI button for reporting issues a little more concise

* Added URL opener, in debugging stages of getting relevant OS details

* Fixed the url to fill in the OS info and Cutter version parameters

* Removed some .orig files that astyle made and I pushed

* Made the title of the issue empty so the User has to enter it

* Removed extra new lines

* Removed my astyle silliness

* Report button will now give information about the file being analyzed.

* Fixed indentation

* Added meaningful names to variables, added a method to determine if certain items exist before accessing them. Also fixed some camelCasing issues :D

* URL declaration is now done once, fixed if/else formatting
This commit is contained in:
Philip Nelson 2019-02-07 05:52:08 -05:00 committed by Itay Cohen
parent bcb3a162f7
commit 277a0ada2f
3 changed files with 48 additions and 6 deletions

View File

@ -1,6 +1,7 @@
#include "MainWindow.h"
#include "ui_MainWindow.h"
#include "common/Helpers.h"
#include "CutterConfig.h"
// Qt Headers
#include <QApplication>
@ -20,6 +21,9 @@
#include <QMessageBox>
#include <QProcess>
#include <QPropertyAnimation>
#include <QSysInfo>
#include <QJsonObject>
#include <QScrollBar>
#include <QSettings>
#include <QShortcut>
@ -263,7 +267,8 @@ void MainWindow::initUI()
QShortcut *refresh_shortcut = new QShortcut(QKeySequence(QKeySequence::Refresh), this);
connect(refresh_shortcut, SIGNAL(activated()), this, SLOT(refreshAll()));
connect(core, SIGNAL(projectSaved(bool, const QString &)), this, SLOT(projectSaved(bool, const QString &)));
connect(core, SIGNAL(projectSaved(bool, const QString &)), this, SLOT(projectSaved(bool,
const QString &)));
connect(core, &CutterCore::changeDebugView, this, &MainWindow::changeDebugView);
connect(core, &CutterCore::changeDefinedView, this, &MainWindow::changeDefinedView);
@ -449,8 +454,8 @@ void MainWindow::setFilename(const QString &fn)
void MainWindow::closeEvent(QCloseEvent *event)
{
QMessageBox::StandardButton ret = QMessageBox::question(this, APPNAME,
tr("Do you really want to exit?\nSave your project before closing!"),
(QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel));
tr("Do you really want to exit?\nSave your project before closing!"),
(QMessageBox::StandardButtons)(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel));
if (ret == QMessageBox::Cancel) {
event->ignore();
return;
@ -810,7 +815,8 @@ void MainWindow::on_actionRun_Script_triggered()
dialog.setViewMode(QFileDialog::Detail);
dialog.setDirectory(QDir::home());
const QString &fileName = QDir::toNativeSeparators(dialog.getOpenFileName(this, tr("Select radare2 script")));
const QString &fileName = QDir::toNativeSeparators(dialog.getOpenFileName(this,
tr("Select radare2 script")));
if (fileName.isEmpty()) // Cancel was pressed
return;
@ -854,8 +860,8 @@ void MainWindow::on_actionReset_settings_triggered()
{
QMessageBox::StandardButton ret =
(QMessageBox::StandardButton)QMessageBox::question(this, APPNAME,
tr("Do you really want to clear all settings?"),
QMessageBox::Ok | QMessageBox::Cancel);
tr("Do you really want to clear all settings?"),
QMessageBox::Ok | QMessageBox::Cancel);
if (ret == QMessageBox::Ok) {
Config()->resetAll();
}
@ -916,6 +922,35 @@ void MainWindow::on_actionAbout_triggered()
a->setAttribute(Qt::WA_DeleteOnClose);
a->open();
}
void MainWindow::on_actionIssue_triggered()
{
QString url, osInfo, format, arch, type;
//Pull in info needed for git issue
osInfo = QString(QSysInfo::productType()) + " " + QString(QSysInfo::productVersion());
QJsonDocument docu = Core()->getFileInfo();
QJsonObject coreObj = docu.object()["core"].toObject();
QJsonObject binObj = docu.object()["bin"].toObject();
if (!binObj.QJsonObject::isEmpty()) {
format = coreObj["format"].toString();
arch = binObj["arch"].toString();
if (!binObj["type"].isUndefined()) {
type = coreObj["type"].toString();
} else {
type = "N/A";
}
} else {
format = coreObj["format"].toString();
arch = "N/A";
type = "N/A";
}
url =
"https://github.com/radareorg/cutter/issues/new?&body=**Environment information**\n* Operating System: "
+ osInfo + "\n* Cutter version: " + CUTTER_VERSION_FULL +
"\n* File format: " + format + "\n * Arch: " + arch + "\n * Type: " + type +
"\n\n**Describe the bug**\nA clear and concise description of what the bug is.\n\n**To Reproduce**\nSteps to reproduce the behavior:\n1. Go to '...'\n2. Click on '....'\n3. Scroll down to '....'\n4. See error\n\n**Expected behavior**\nA clear and concise description of what you expected to happen.\n\n**Screenshots**\nIf applicable, add screenshots to help explain your problem.\n\n**Additional context**\nAdd any other context about the problem here.";
QDesktopServices::openUrl(QUrl(url, QUrl::TolerantMode));
}
void MainWindow::on_actionRefresh_Panels_triggered()
{

View File

@ -131,6 +131,7 @@ public slots:
private slots:
void on_actionAbout_triggered();
void on_actionIssue_triggered();
void on_actionExtraGraph_triggered();
void on_actionExtraHexdump_triggered();
void on_actionExtraDisassembly_triggered();

View File

@ -136,6 +136,7 @@ QToolTip {
<string>Help</string>
</property>
<addaction name="actionAbout"/>
<addaction name="actionIssue"/>
</widget>
<widget class="QMenu" name="menuEdit">
<property name="title">
@ -278,6 +279,11 @@ QToolTip {
<string>About</string>
</property>
</action>
<action name="actionIssue">
<property name="text">
<string>Report an issue</string>
</property>
</action>
<action name="actionNew">
<property name="text">
<string>New</string>