diff --git a/sources/src/CMakeLists.txt b/sources/src/CMakeLists.txt index 95d5625..fc4afe5 100644 --- a/sources/src/CMakeLists.txt +++ b/sources/src/CMakeLists.txt @@ -10,11 +10,10 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/../ ${CMAKE_CURRENT_BINARY_DIR}) if (USE_QT5) - find_package(Qt5Core REQUIRED) - find_package(Qt5Widgets REQUIRED) - add_definitions(${Qt5Core_DEFINITIONS}) - add_definitions(${Qt5Widgets_DEFINITIONS}) - add_definitions(${Qt5LinguistTools_DEFINITIONS}) + find_package (Qt5Core REQUIRED) + find_package (Qt5Widgets REQUIRED) + add_definitions (${Qt5Core_DEFINITIONS}) + add_definitions (${Qt5Widgets_DEFINITIONS}) qt5_wrap_cpp (MOC_SOURCES ${HEADERS}) qt5_wrap_ui (UI_HEADERS ${FORMS}) diff --git a/sources/src/config.h b/sources/src/config.h new file mode 100644 index 0000000..c5c5e3d --- /dev/null +++ b/sources/src/config.h @@ -0,0 +1,61 @@ +/*************************************************************************** + * This file is part of reportabug * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 3.0 of the License, or (at your option) any later version. * + * * + * This library 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 for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library. * + ***************************************************************************/ + +#ifndef CONFIG_H +#define CONFIG_H + + +/* + * configuration of creating an issue using GitHub API + */ +// enable this function +#define ENABLE_GITHUB true +// combobox text +#define GITHUB_COMBOBOX "I want to report a bug using my GitHub account" +// the owner of the source repository +#define OWNER "arcan1s" +// project name +#define PROJECT "reportabug" +// issues url; in the most cases do not touch it +// available tags are $PROJECT, $OWNER +#define ISSUES_URL "https://api.github.com/repos/$OWNER/$PROJECT/issues" +// tags defaults +#define TAG_TITLE "A new bug" +#define TAG_BODY "Some error occurs" +// the following tags will work only if user has push access +// if they will be empty, they will be ignored +#define TAG_ASSIGNEE "$OWNER" +#define TAG_MILESTONE "" +// comma separated +#define TAG_LABELS "auto" + +/* + * configuration of creating an issue using GitReports + * + * please, visit the following site: https://gitreports.com/ + * and set up it for your repository + */ +// enable this function +#define ENABLE_GITREPORT true +// combobox text +#define GITREPORT_COMBOBOX "GitHub? I don't understand what do you want from me!" +// public link; in the most cases do not touch it +// available tags are $PROJECT, $OWNER +#define PUBLIC_URL "https://gitreports.com/issue/$OWNER/$PROJECT" + + +#endif /* CONFIG_H */ diff --git a/sources/src/main.cpp b/sources/src/main.cpp index 37891da..9045950 100644 --- a/sources/src/main.cpp +++ b/sources/src/main.cpp @@ -18,7 +18,7 @@ #include -#include "mainwindow.h" +#include "reportabug.h" #include "version.h" @@ -26,7 +26,7 @@ int main(int argc, char *argv[]) { QApplication a(argc, argv); - MainWindow w; + Reportabug w; w.show(); return a.exec(); } diff --git a/sources/src/reportabug.cpp b/sources/src/reportabug.cpp new file mode 100644 index 0000000..1a81136 --- /dev/null +++ b/sources/src/reportabug.cpp @@ -0,0 +1,148 @@ +/*************************************************************************** + * This file is part of reportabug * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 3.0 of the License, or (at your option) any later version. * + * * + * This library 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 for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library. * + ***************************************************************************/ + +#include "reportabug.h" +#include "ui_reportabug.h" + +#include +#include + +#include "config.h" + + +Reportabug::Reportabug(QWidget *parent) + : QMainWindow(parent), + ui(new Ui::Reportabug) +{ + ui->setupUi(this); + createComboBox(); + createActions(); + updateTabs(ui->comboBox->currentIndex()); +} + + +Reportabug::~Reportabug() +{ + delete ui; +} + + +void Reportabug::createActions() +{ + 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::Ok), SIGNAL(clicked(bool)), this, SLOT(sendReport())); + connect(ui->buttonBox->button(QDialogButtonBox::Ok), SIGNAL(clicked(bool)), this, SLOT(close())); +} + + +void Reportabug::createComboBox() +{ + ui->comboBox->clear(); + if (ENABLE_GITHUB) + ui->comboBox->addItem(QString(GITHUB_COMBOBOX)); + if (ENABLE_GITREPORT) + ui->comboBox->addItem(QString(GITREPORT_COMBOBOX)); +} + + +int Reportabug::getNumberByIndex(const int index) +{ + if (index == -1) + // nothing to do + return -1; + else if ((ENABLE_GITHUB) && (ENABLE_GITREPORT)) + // both are enabled + return index; + else if (ENABLE_GITHUB) + // only github is enabled + return 0; + else if (ENABLE_GITREPORT) + // only gitreport is enabled + return 1; + else + // nothing to do + return -1; +} + + +// ESC press event +void Reportabug::keyPressEvent(QKeyEvent *pressedKey) +{ + if (pressedKey->key() == Qt::Key_Escape) + close(); +} + + +QString Reportabug::parseString(QString line) +{ + if (line.contains(QString("$OWNER"))) + line = line.split(QString("$OWNER"))[0] + QString(OWNER) + line.split(QString("$OWNER"))[1]; + if (line.contains(QString("$PROJECT"))) + line = line.split(QString("$PROJECT"))[0] + QString(PROJECT) + line.split(QString("$PROJECT"))[1]; + + return line; +} + + +void Reportabug::sendReport() +{ + int number = getNumberByIndex(ui->comboBox->currentIndex()); + if (number == -1) + return; + else if (number == 0) + sendReportUsingGithub(); + else if (number == 1) + sendReportUsingGitreport(); +} + + +void Reportabug::updateTabs(const int index) +{ + int number = getNumberByIndex(index); + ui->stackedWidget->setCurrentIndex(number + 1); + if (number == -1) + return; + else if (number == 0) + sendReportUsingGithub(); + else if (number == 1) + sendReportUsingGitreport(); +} + + +void Reportabug::updateGithubTab() +{ + +} + + +void Reportabug::updateGitreportTab() +{ + +} + + +void Reportabug::sendReportUsingGithub() +{ + +} + + +void Reportabug::sendReportUsingGitreport() +{ + +} diff --git a/sources/src/reportabug.h b/sources/src/reportabug.h new file mode 100644 index 0000000..d179a76 --- /dev/null +++ b/sources/src/reportabug.h @@ -0,0 +1,60 @@ +/*************************************************************************** + * This file is part of reportabug * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Lesser General Public * + * License as published by the Free Software Foundation; either * + * version 3.0 of the License, or (at your option) any later version. * + * * + * This library 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 for more details. * + * * + * You should have received a copy of the GNU Lesser General Public * + * License along with this library. * + ***************************************************************************/ + +#ifndef REPORTABUG_H +#define REPORTABUG_H + +#include +#include + + +namespace Ui { +class Reportabug; +} + +class Reportabug : public QMainWindow +{ + Q_OBJECT + +public: + explicit Reportabug(QWidget *parent = 0); + ~Reportabug(); + +public slots: + // send report + void sendReport(); + // update functions + void updateTabs(const int index); + void updateGithubTab(); + void updateGitreportTab(); + +private slots: + void sendReportUsingGithub(); + void sendReportUsingGitreport(); + +private: + Ui::Reportabug *ui; + void createActions(); + void createComboBox(); + int getNumberByIndex(const int index); + // ESC pressed event + void keyPressEvent(QKeyEvent *pressedKey); + QString parseString(QString line); +}; + + +#endif /* REPORTABUG_H */ diff --git a/sources/src/reportabug.ui b/sources/src/reportabug.ui new file mode 100644 index 0000000..38b10e0 --- /dev/null +++ b/sources/src/reportabug.ui @@ -0,0 +1,133 @@ + + + Reportabug + + + + 0 + 0 + 547 + 378 + + + + Report a bug + + + + + + + + + + + + + + + + + + 100 + 0 + + + + Username + + + + + + + Your GitHub account + + + + + + + + 100 + 0 + + + + Password + + + + + + + GitHub account password + + + QLineEdit::Password + + + + + + + + + + + + 150 + 0 + + + + Title + + + + + + + Title of the report + + + + + + + + + Text of the report + + + + + + + + + + + + + + + + + + QDialogButtonBox::Close|QDialogButtonBox::Ok + + + + + + + + + Close + + + + + +