mirror of
https://github.com/arcan1s/reportabug.git
synced 2025-04-24 15:27:18 +00:00
fix newlines
This commit is contained in:
parent
800bb7375b
commit
f99afa8365
@ -26,7 +26,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
|
|
||||||
Reportabug w;
|
Reportabug w(0, true);
|
||||||
w.show();
|
w.show();
|
||||||
return a.exec();
|
return a.exec();
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,9 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
|
|
||||||
Reportabug::Reportabug(QWidget *parent)
|
Reportabug::Reportabug(QWidget *parent, bool debugCmd)
|
||||||
: QMainWindow(parent),
|
: QMainWindow(parent),
|
||||||
|
debug(debugCmd),
|
||||||
ui(new Ui::Reportabug)
|
ui(new Ui::Reportabug)
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
@ -42,12 +43,16 @@ Reportabug::Reportabug(QWidget *parent)
|
|||||||
|
|
||||||
Reportabug::~Reportabug()
|
Reportabug::~Reportabug()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[~Reportabug]";
|
||||||
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Reportabug::createActions()
|
void Reportabug::createActions()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[createActions]";
|
||||||
|
|
||||||
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTabs(int)));
|
connect(ui->comboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(updateTabs(int)));
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
|
connect(ui->buttonBox->button(QDialogButtonBox::Close), SIGNAL(clicked(bool)), this, SLOT(close()));
|
||||||
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(sendReport()));
|
connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(sendReport()));
|
||||||
@ -56,6 +61,8 @@ void Reportabug::createActions()
|
|||||||
|
|
||||||
void Reportabug::createComboBox()
|
void Reportabug::createComboBox()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[createComboBox]";
|
||||||
|
|
||||||
ui->comboBox->clear();
|
ui->comboBox->clear();
|
||||||
if (ENABLE_GITHUB)
|
if (ENABLE_GITHUB)
|
||||||
ui->comboBox->addItem(QString(GITHUB_COMBOBOX));
|
ui->comboBox->addItem(QString(GITHUB_COMBOBOX));
|
||||||
@ -66,6 +73,9 @@ void Reportabug::createComboBox()
|
|||||||
|
|
||||||
int Reportabug::getNumberByIndex(const int index)
|
int Reportabug::getNumberByIndex(const int index)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[getNumberByIndex]";
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[getNumberByIndex]" << ":" << "Index" << index;
|
||||||
|
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
// nothing to do
|
// nothing to do
|
||||||
return -1;
|
return -1;
|
||||||
@ -87,39 +97,18 @@ int Reportabug::getNumberByIndex(const int index)
|
|||||||
// ESC press event
|
// ESC press event
|
||||||
void Reportabug::keyPressEvent(QKeyEvent *pressedKey)
|
void Reportabug::keyPressEvent(QKeyEvent *pressedKey)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[keyPressEvent]";
|
||||||
|
|
||||||
if (pressedKey->key() == Qt::Key_Escape)
|
if (pressedKey->key() == Qt::Key_Escape)
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QString Reportabug::parseCmd(QString line,
|
|
||||||
const QString password,
|
|
||||||
const QString text,
|
|
||||||
const QString username)
|
|
||||||
{
|
|
||||||
if (line.contains(QString("$ISSUES_URL")))
|
|
||||||
line = line.split(QString("$ISSUES_URL"))[0] +
|
|
||||||
parseString(QString(ISSUES_URL)) +
|
|
||||||
line.split(QString("$ISSUES_URL"))[1];
|
|
||||||
if (line.contains(QString("$PASSWORD")))
|
|
||||||
line = line.split(QString("$PASSWORD"))[0] +
|
|
||||||
password +
|
|
||||||
line.split(QString("$PASSWORD"))[1];
|
|
||||||
if (line.contains(QString("$TEXT")))
|
|
||||||
line = line.split(QString("$TEXT"))[0] +
|
|
||||||
text +
|
|
||||||
line.split(QString("$TEXT"))[1];
|
|
||||||
if (line.contains(QString("$USERNAME")))
|
|
||||||
line = line.split(QString("$USERNAME"))[0] +
|
|
||||||
username +
|
|
||||||
line.split(QString("$USERNAME"))[1];
|
|
||||||
|
|
||||||
return line;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
QString Reportabug::parseString(QString line)
|
QString Reportabug::parseString(QString line)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[parseString]";
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[parseString]" << ":" << "Parse line" << line;
|
||||||
|
|
||||||
if (line.contains(QString("$OWNER")))
|
if (line.contains(QString("$OWNER")))
|
||||||
line = line.split(QString("$OWNER"))[0] +
|
line = line.split(QString("$OWNER"))[0] +
|
||||||
QString(OWNER) +
|
QString(OWNER) +
|
||||||
@ -135,9 +124,15 @@ QString Reportabug::parseString(QString line)
|
|||||||
|
|
||||||
QByteArray Reportabug::prepareRequest(const QString title, const QString body)
|
QByteArray Reportabug::prepareRequest(const QString title, const QString body)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[prepareRequest]";
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[prepareRequest]" << ":" << "Title" << title;
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[prepareRequest]" << ":" << "Title" << body;
|
||||||
|
|
||||||
QStringList requestList;
|
QStringList requestList;
|
||||||
requestList.append(QString("\"title\":\"") + title + QString("\""));
|
requestList.append(QString("\"title\":\"") + title + QString("\""));
|
||||||
requestList.append(QString("\"body\":\"") + body + QString("\""));
|
QString fixBody = body;
|
||||||
|
fixBody.replace(QString("\n"), QString("<br>"));
|
||||||
|
requestList.append(QString("\"body\":\"") + fixBody + QString("\""));
|
||||||
if (!QString(TAG_ASSIGNEE).isEmpty())
|
if (!QString(TAG_ASSIGNEE).isEmpty())
|
||||||
requestList.append(QString("\"assignee\":\"") + parseString(QString(TAG_ASSIGNEE)) + QString("\""));
|
requestList.append(QString("\"assignee\":\"") + parseString(QString(TAG_ASSIGNEE)) + QString("\""));
|
||||||
if (!QString(TAG_MILESTONE).isEmpty())
|
if (!QString(TAG_MILESTONE).isEmpty())
|
||||||
@ -160,7 +155,10 @@ QByteArray Reportabug::prepareRequest(const QString title, const QString body)
|
|||||||
|
|
||||||
void Reportabug::sendReport()
|
void Reportabug::sendReport()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[sendReport]";
|
||||||
|
|
||||||
int number = getNumberByIndex(ui->comboBox->currentIndex());
|
int number = getNumberByIndex(ui->comboBox->currentIndex());
|
||||||
|
|
||||||
if (number == -1)
|
if (number == -1)
|
||||||
return;
|
return;
|
||||||
else if (number == 0)
|
else if (number == 0)
|
||||||
@ -172,8 +170,12 @@ void Reportabug::sendReport()
|
|||||||
|
|
||||||
void Reportabug::updateTabs(const int index)
|
void Reportabug::updateTabs(const int index)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[updateTabs]";
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[updateTabs]" << ":" << "Index" << index;
|
||||||
|
|
||||||
int number = getNumberByIndex(index);
|
int number = getNumberByIndex(index);
|
||||||
ui->stackedWidget->setCurrentIndex(number + 1);
|
ui->stackedWidget->setCurrentIndex(number + 1);
|
||||||
|
|
||||||
if (number == -1)
|
if (number == -1)
|
||||||
return;
|
return;
|
||||||
else if (number == 0)
|
else if (number == 0)
|
||||||
@ -185,23 +187,30 @@ void Reportabug::updateTabs(const int index)
|
|||||||
|
|
||||||
void Reportabug::updateGithubTab()
|
void Reportabug::updateGithubTab()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[updateGithubTab]";
|
||||||
|
|
||||||
ui->lineEdit_username->clear();
|
ui->lineEdit_username->clear();
|
||||||
ui->lineEdit_password->clear();
|
ui->lineEdit_password->clear();
|
||||||
ui->lineEdit_title->setText(QString(TAG_TITLE));
|
ui->lineEdit_title->setText(QString(TAG_TITLE));
|
||||||
ui->plainTextEdit->setPlainText(QString(TAG_BODY));
|
ui->textEdit->setPlainText(QString(TAG_BODY));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Reportabug::updateGitreportTab()
|
void Reportabug::updateGitreportTab()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[updateGitreportTab]";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Reportabug::replyFinished(QNetworkReply *reply)
|
void Reportabug::replyFinished(QNetworkReply *reply)
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[replyFinished]";
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[replyFinished]" << ":" << "Error state" << reply->error();
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[replyFinished]" << ":" << "Reply size" << reply->readBufferSize();
|
||||||
|
|
||||||
int state = true;
|
int state = true;
|
||||||
QString answer = reply->readAll();
|
QString answer = reply->readAll();
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[replyFinished]" << ":" << answer;
|
||||||
QString messageBody, messageTitle;
|
QString messageBody, messageTitle;
|
||||||
QMessageBox::Icon icon = QMessageBox::NoIcon;
|
QMessageBox::Icon icon = QMessageBox::NoIcon;
|
||||||
if (answer.contains(QString("\"html_url\":"))) {
|
if (answer.contains(QString("\"html_url\":"))) {
|
||||||
@ -255,7 +264,9 @@ void Reportabug::replyFinished(QNetworkReply *reply)
|
|||||||
|
|
||||||
void Reportabug::sendReportUsingGithub()
|
void Reportabug::sendReportUsingGithub()
|
||||||
{
|
{
|
||||||
// authorization
|
if (debug) qDebug() << "[Reportabug]" << "[sendReportUsingGithub]";
|
||||||
|
|
||||||
|
// authentication
|
||||||
QString username = ui->lineEdit_username->text();
|
QString username = ui->lineEdit_username->text();
|
||||||
QString password = ui->lineEdit_password->text();
|
QString password = ui->lineEdit_password->text();
|
||||||
QString concatenated = username + QString(":") + password;
|
QString concatenated = username + QString(":") + password;
|
||||||
@ -263,7 +274,7 @@ void Reportabug::sendReportUsingGithub()
|
|||||||
QString headerData = QString("Basic ") + userData;
|
QString headerData = QString("Basic ") + userData;
|
||||||
// text
|
// text
|
||||||
QString title = ui->lineEdit_title->text();
|
QString title = ui->lineEdit_title->text();
|
||||||
QString body = ui->plainTextEdit->toPlainText();
|
QString body = ui->textEdit->toPlainText();
|
||||||
QByteArray text = prepareRequest(title, body);
|
QByteArray text = prepareRequest(title, body);
|
||||||
QByteArray textSize = QByteArray::number(text.size());
|
QByteArray textSize = QByteArray::number(text.size());
|
||||||
// sending request
|
// sending request
|
||||||
@ -282,5 +293,5 @@ void Reportabug::sendReportUsingGithub()
|
|||||||
|
|
||||||
void Reportabug::sendReportUsingGitreport()
|
void Reportabug::sendReportUsingGitreport()
|
||||||
{
|
{
|
||||||
|
if (debug) qDebug() << "[Reportabug]" << "[sendReportUsingGitreport]";
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,8 @@ class Reportabug : public QMainWindow
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit Reportabug(QWidget *parent = 0);
|
explicit Reportabug(QWidget *parent = 0,
|
||||||
|
bool debugCmd = false);
|
||||||
~Reportabug();
|
~Reportabug();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
@ -50,16 +51,13 @@ private slots:
|
|||||||
void replyFinished(QNetworkReply *reply);
|
void replyFinished(QNetworkReply *reply);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
bool debug;
|
||||||
Ui::Reportabug *ui;
|
Ui::Reportabug *ui;
|
||||||
void createActions();
|
void createActions();
|
||||||
void createComboBox();
|
void createComboBox();
|
||||||
int getNumberByIndex(const int index);
|
int getNumberByIndex(const int index);
|
||||||
// ESC pressed event
|
// ESC pressed event
|
||||||
void keyPressEvent(QKeyEvent *pressedKey);
|
void keyPressEvent(QKeyEvent *pressedKey);
|
||||||
QString parseCmd(QString line,
|
|
||||||
const QString password = QString(),
|
|
||||||
const QString text = QString(),
|
|
||||||
const QString username = QString());
|
|
||||||
QString parseString(QString line);
|
QString parseString(QString line);
|
||||||
QByteArray prepareRequest(const QString title, const QString body);
|
QByteArray prepareRequest(const QString title, const QString body);
|
||||||
};
|
};
|
||||||
|
@ -101,10 +101,13 @@
|
|||||||
</layout>
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPlainTextEdit" name="plainTextEdit">
|
<widget class="QTextEdit" name="textEdit">
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string>Text of the report</string>
|
<string>Text of the report</string>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="acceptRichText">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
|
Loading…
Reference in New Issue
Block a user