mirror of
https://github.com/arcan1s/reportabug.git
synced 2025-04-25 07:47:18 +00:00
Compare commits
No commits in common. "master" and "V.1.0.1" have entirely different histories.
@ -1,7 +1,3 @@
|
||||
Ver.1.1.0:
|
||||
+ add abillity to load parametrs dynamically
|
||||
* some fixes
|
||||
|
||||
Ver.1.0.2:
|
||||
* some fixes
|
||||
|
||||
|
11
README.md
11
README.md
@ -4,12 +4,12 @@ reportabug
|
||||
Information
|
||||
-----------
|
||||
|
||||
Qt application/library which allows users to create an issue for GitHub projects. It may work over [GitHub](https://github.com) or [GitReport](https://gitreports.com/). For the developer configuration please use `config.h` header.
|
||||
Qt application/library which allows users to create an issue for GitHub projects. It may work over [GitHub](https://github.com) or [GitReport](https://gitreports.com/). For the developer configuration please use `config.h.in` header.
|
||||
|
||||
Configuration
|
||||
-------------
|
||||
|
||||
Edit `src/config.h` header and set up needed variables or load parametrs dynamically using `params` array (**NOTE** please use the same keys as for `config.h`).
|
||||
Edit `src/config.h.in` header and set up needed variables.
|
||||
|
||||
### Main configuration ###
|
||||
|
||||
@ -100,18 +100,15 @@ Installation
|
||||
|
||||
* declare class in you sources. For example:
|
||||
|
||||
Reportabug *reportWindow = new Reportabug(parent=this,
|
||||
debugCmd=false,
|
||||
params=0);
|
||||
Reportabug *reportWindow = new Reportabug(this, false);
|
||||
reportWindow->showWindow();
|
||||
|
||||
* link your application with this library
|
||||
|
||||
### Available cmake flags ###
|
||||
|
||||
* `-DBUILD_AS_LIBRARY:BOOL=0` - build the application but not a library
|
||||
* `-DBUILD_AS_LIBRARY:BOOL=0` - build the application but not a shared library
|
||||
* `-DBUILD_DOCS:BOOL=1` - build developer documentation
|
||||
* `-DBUILD_SHARED_LIBRARY=1` - build a shared library instead of static one
|
||||
* `-DENABLE_GITHUB=0` - disable GitHub module
|
||||
* `-DENABLE_GITREPORT=0` - disable GitReport module
|
||||
* `-DOWN_GITHUB_TOKEN=STRING` - use STRING as own GitHub token
|
||||
|
@ -13,8 +13,8 @@ set (SUBPROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (SUBPROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (SUBPROJECT_LICENSE "LGPLv3")
|
||||
set (SUBPROJECT_VERSION_MAJOR 1)
|
||||
set (SUBPROJECT_VERSION_MINOR 1)
|
||||
set (SUBPROJECT_VERSION_PATCH 0)
|
||||
set (SUBPROJECT_VERSION_MINOR 0)
|
||||
set (SUBPROJECT_VERSION_PATCH 2)
|
||||
set (SUBPROJECT_VERSION ${SUBPROJECT_VERSION_MAJOR}.${SUBPROJECT_VERSION_MINOR}.${SUBPROJECT_VERSION_PATCH})
|
||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||
string (TIMESTAMP CURRENT_YEAR "%Y")
|
||||
@ -24,9 +24,8 @@ message (STATUS "Version: ${SUBPROJECT_VERSION}")
|
||||
message (STATUS "Build date: ${CURRENT_DATE}")
|
||||
|
||||
# install options
|
||||
set (BUILD_AS_LIBRARY ON CACHE BOOL "Build the application as a library")
|
||||
set (BUILD_AS_LIBRARY ON CACHE BOOL "Build the application as a shared library")
|
||||
set (BUILD_DOCS OFF CACHE BOOL "Build developers documentation")
|
||||
set (BUILD_SHARED_LIBRARY OFF CACHE BOOL "Build the shared library")
|
||||
set (ENABLE_GITHUB ON CACHE BOOL "Enable GitHub module")
|
||||
set (ENABLE_GITREPORT ON CACHE BOOL "Enable GitReport module")
|
||||
set (USE_QT5 ON CACHE BOOL "Use Qt5 instead of Qt4")
|
||||
@ -40,11 +39,6 @@ endif ()
|
||||
if (USE_OWN_TOKEN)
|
||||
set (ENABLE_GITREPORT OFF)
|
||||
endif ()
|
||||
if (BUILD_SHARED_LIBRARY)
|
||||
set (LIBPROP SHARED)
|
||||
else ()
|
||||
set (LIBPROP STATIC)
|
||||
endif ()
|
||||
|
||||
# flags
|
||||
if (CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
@ -53,16 +53,14 @@ else ()
|
||||
endif()
|
||||
|
||||
if (BUILD_AS_LIBRARY)
|
||||
add_library (${SUBPROJECT} ${LIBPROP} ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${UI_HEADERS})
|
||||
add_library (${SUBPROJECT} SHARED ${SOURCES} ${HEADERS} ${MOC_SOURCES} ${UI_HEADERS})
|
||||
else ()
|
||||
add_executable (${SUBPROJECT} ${UI_HEADERS} ${HEADERS} ${SOURCES} ${MOC_SOURCES})
|
||||
endif ()
|
||||
target_link_libraries (${SUBPROJECT} ${QT_USED_LIBRARIES})
|
||||
# install properties
|
||||
if (BUILD_AS_LIBRARY)
|
||||
if (BUILD_SHARED_LIBRARY)
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION lib)
|
||||
endif ()
|
||||
else ()
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||
endif ()
|
||||
|
@ -35,6 +35,8 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QUrl>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
/**
|
||||
* @class GithubModule
|
||||
@ -42,10 +44,9 @@
|
||||
/**
|
||||
* @fn GithubModule
|
||||
*/
|
||||
GithubModule::GithubModule(QWidget *parent, bool debugCmd, QMap<QString, QString> params)
|
||||
GithubModule::GithubModule(QWidget *parent, bool debugCmd)
|
||||
: QObject(parent),
|
||||
debug(debugCmd),
|
||||
dynamic(params),
|
||||
mainWindow((Reportabug *)parent)
|
||||
{
|
||||
}
|
||||
@ -74,12 +75,12 @@ QByteArray GithubModule::prepareRequest(const QString title, const QString body)
|
||||
QString fixBody = body;
|
||||
fixBody.replace(QString("\n"), QString("<br>"));
|
||||
requestList.append(QString("\"body\":\"") + fixBody + QString("\""));
|
||||
if (!dynamic[QString("TAG_ASSIGNEE")].isEmpty())
|
||||
requestList.append(QString("\"assignee\":\"") + parseString(dynamic[QString("TAG_ASSIGNEE")]) + QString("\""));
|
||||
if (!dynamic[QString("TAG_MILESTONE")].isEmpty())
|
||||
requestList.append(QString("\"milestone\":") + dynamic[QString("TAG_MILESTONE")]);
|
||||
if (!dynamic[QString("TAG_LABELS")].isEmpty()) {
|
||||
QStringList labels = dynamic[QString("TAG_LABELS")].split(QChar(','));
|
||||
if (!QString(TAG_ASSIGNEE).isEmpty())
|
||||
requestList.append(QString("\"assignee\":\"") + parseString(QString(TAG_ASSIGNEE)) + QString("\""));
|
||||
if (!QString(TAG_MILESTONE).isEmpty())
|
||||
requestList.append(QString("\"milestone\":") + QString(TAG_MILESTONE));
|
||||
if (!QString(TAG_LABELS).isEmpty()) {
|
||||
QStringList labels = QString(TAG_LABELS).split(QChar(','));
|
||||
for (int i=0; i<labels.count(); i++)
|
||||
labels[i] = QString("\"") + labels[i] + QString("\"");
|
||||
requestList.append(QString("\"labels\":[") + labels.join(QChar(',')) + QString("]"));
|
||||
@ -104,11 +105,11 @@ QString GithubModule::parseString(QString line)
|
||||
|
||||
if (line.contains(QString("$OWNER")))
|
||||
line = line.split(QString("$OWNER"))[0] +
|
||||
dynamic[QString("OWNER")] +
|
||||
QString(OWNER) +
|
||||
line.split(QString("$OWNER"))[1];
|
||||
if (line.contains(QString("$PROJECT")))
|
||||
line = line.split(QString("$PROJECT"))[0] +
|
||||
dynamic[QString("PROJECT")] +
|
||||
QString(PROJECT) +
|
||||
line.split(QString("$PROJECT"))[1];
|
||||
|
||||
return line;
|
||||
@ -135,7 +136,7 @@ void GithubModule::sendReportUsingGithub(const QMap<QString, QString> info)
|
||||
QByteArray text = prepareRequest(info[QString("title")], info[QString("body")]);
|
||||
QByteArray textSize = QByteArray::number(text.size());
|
||||
// sending request
|
||||
QNetworkRequest request = QNetworkRequest(parseString(dynamic[QString("ISSUES_URL")]));
|
||||
QNetworkRequest request = QNetworkRequest(parseString(QString(ISSUES_URL)));
|
||||
request.setRawHeader("Authorization", headerData.toLocal8Bit());
|
||||
request.setRawHeader("User-Agent", "reportabug");
|
||||
request.setRawHeader("Host", "api.github.com");
|
||||
|
@ -59,11 +59,9 @@ public:
|
||||
* @brief GithubModule class constructor
|
||||
* @param parent parent object
|
||||
* @param debugCmd show debug messages
|
||||
* @param params dynamic parametrs. Needed keys are the same as in config.h
|
||||
*/
|
||||
explicit GithubModule(QWidget *parent = 0,
|
||||
bool debugCmd = false,
|
||||
QMap<QString, QString> params = QMap<QString, QString>());
|
||||
bool debugCmd = false);
|
||||
/**
|
||||
* @brief GithubModule class destructor
|
||||
*/
|
||||
@ -93,10 +91,6 @@ private:
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug;
|
||||
/**
|
||||
* @brief dynamic parametrs
|
||||
*/
|
||||
QMap<QString, QString> dynamic;
|
||||
/**
|
||||
* @brief Reportabug class
|
||||
*/
|
||||
|
@ -37,6 +37,8 @@
|
||||
#include <QWebElement>
|
||||
#include <QWebFrame>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
/**
|
||||
* @class GitreportModule
|
||||
@ -44,10 +46,9 @@
|
||||
/**
|
||||
* @fn GitreportModule
|
||||
*/
|
||||
GitreportModule::GitreportModule(QWidget *parent, bool debugCmd, QMap<QString, QString> params)
|
||||
GitreportModule::GitreportModule(QWidget *parent, bool debugCmd)
|
||||
: QObject(parent),
|
||||
debug(debugCmd),
|
||||
dynamic(params),
|
||||
mainWindow((Reportabug *)parent)
|
||||
{
|
||||
webView = new QWebView();
|
||||
@ -105,7 +106,7 @@ void GitreportModule::gitreportLoaded(const bool state)
|
||||
// captcha
|
||||
QWebElement document = webView->page()->mainFrame()->documentElement();
|
||||
QWebElement captchaImg = document.findFirst(QString("input#captcha_key"));
|
||||
QString captchaUrl = QString(dynamic[QString("CAPTCHA_URL")]) + captchaImg.attribute(QString("value"));
|
||||
QString captchaUrl = QString(CAPTCHA_URL) + captchaImg.attribute(QString("value"));
|
||||
QNetworkRequest request(captchaUrl);
|
||||
manager.get(request);
|
||||
disconnect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(setCaptcha(QNetworkReply *)));
|
||||
|
@ -49,11 +49,9 @@ public:
|
||||
* @brief GitreportModule class constructor
|
||||
* @param parent parent object
|
||||
* @param debugCmd show debug messages
|
||||
* @param params dynamic parametrs. Needed keys are the same as in config.h
|
||||
*/
|
||||
explicit GitreportModule(QWidget *parent = 0,
|
||||
bool debugCmd = false,
|
||||
QMap<QString, QString> params = QMap<QString, QString>());
|
||||
bool debugCmd = false);
|
||||
/**
|
||||
* @brief GitreportModule class destructor
|
||||
*/
|
||||
@ -95,10 +93,6 @@ private:
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug;
|
||||
/**
|
||||
* @brief dynamic parametrs
|
||||
*/
|
||||
QMap<QString, QString> dynamic;
|
||||
/**
|
||||
* @brief Reportabug class
|
||||
*/
|
||||
|
@ -44,41 +44,11 @@
|
||||
/**
|
||||
* @fn Reportabug
|
||||
*/
|
||||
Reportabug::Reportabug(QWidget *parent, bool debugCmd, QMap<QString, QString> params)
|
||||
Reportabug::Reportabug(QWidget *parent, bool debugCmd)
|
||||
: QMainWindow(parent),
|
||||
debug(debugCmd),
|
||||
dynamic(params),
|
||||
ui(new Ui::Reportabug)
|
||||
{
|
||||
// read settings
|
||||
// main
|
||||
if (!dynamic.contains(QString("OWNER")))
|
||||
dynamic[QString("OWNER")] = QString(OWNER);
|
||||
if (!dynamic.contains(QString("PROJECT")))
|
||||
dynamic[QString("PROJECT")] = QString(PROJECT);
|
||||
if (!dynamic.contains(QString("TAG_ASSIGNEE")))
|
||||
dynamic[QString("TAG_ASSIGNEE")] = QString(TAG_ASSIGNEE);
|
||||
if (!dynamic.contains(QString("TAG_BODY")))
|
||||
dynamic[QString("TAG_BODY")] = QString(TAG_BODY);
|
||||
if (!dynamic.contains(QString("TAG_LABELS")))
|
||||
dynamic[QString("TAG_LABELS")] = QString(TAG_LABELS);
|
||||
if (!dynamic.contains(QString("TAG_MILESTONE")))
|
||||
dynamic[QString("TAG_MILESTONE")] = QString(TAG_MILESTONE);
|
||||
if (!dynamic.contains(QString("TAG_TITLE")))
|
||||
dynamic[QString("TAG_TITLE")] = QString(TAG_TITLE);
|
||||
// github module
|
||||
if (!dynamic.contains(QString("GITHUB_COMBOBOX")))
|
||||
dynamic[QString("GITHUB_COMBOBOX")] = QString(GITHUB_COMBOBOX);
|
||||
if (!dynamic.contains(QString("ISSUES_URL")))
|
||||
dynamic[QString("ISSUES_URL")] = QString(ISSUES_URL);
|
||||
// gitreport module
|
||||
if (!dynamic.contains(QString("CAPTCHA_URL")))
|
||||
dynamic[QString("CAPTCHA_URL")] = QString(CAPTCHA_URL);
|
||||
if (!dynamic.contains(QString("GITREPORT_COMBOBOX")))
|
||||
dynamic[QString("GITREPORT_COMBOBOX")] = QString(GITREPORT_COMBOBOX);
|
||||
if (!dynamic.contains(QString("PUBLIC_URL")))
|
||||
dynamic[QString("PUBLIC_URL")] = QString(PUBLIC_URL);
|
||||
|
||||
ui->setupUi(this);
|
||||
initModules();
|
||||
createComboBox();
|
||||
@ -147,9 +117,9 @@ void Reportabug::createComboBox()
|
||||
|
||||
ui->comboBox->clear();
|
||||
if (modules[0])
|
||||
ui->comboBox->addItem(dynamic[QString("GITHUB_COMBOBOX")]);
|
||||
ui->comboBox->addItem(GITHUB_COMBOBOX);
|
||||
if (modules[1] || modules[2])
|
||||
ui->comboBox->addItem(dynamic[QString("GITREPORT_COMBOBOX")]);
|
||||
ui->comboBox->addItem(GITREPORT_COMBOBOX);
|
||||
}
|
||||
|
||||
|
||||
@ -238,11 +208,11 @@ QString Reportabug::parseString(QString line)
|
||||
|
||||
if (line.contains(QString("$OWNER")))
|
||||
line = line.split(QString("$OWNER"))[0] +
|
||||
dynamic[QString("OWNER")] +
|
||||
QString(OWNER) +
|
||||
line.split(QString("$OWNER"))[1];
|
||||
if (line.contains(QString("$PROJECT")))
|
||||
line = line.split(QString("$PROJECT"))[0] +
|
||||
dynamic[QString("PROJECT")] +
|
||||
QString(PROJECT) +
|
||||
line.split(QString("$PROJECT"))[1];
|
||||
|
||||
return line;
|
||||
@ -304,8 +274,8 @@ void Reportabug::updateTabs(const int index)
|
||||
int number = getNumberByIndex(index);
|
||||
ui->lineEdit_username->clear();
|
||||
ui->lineEdit_password->clear();
|
||||
ui->lineEdit_title->setText(dynamic[QString("TAG_TITLE")]);
|
||||
ui->textEdit->setPlainText(dynamic[QString("TAG_BODY")]);
|
||||
ui->lineEdit_title->setText(QString(TAG_TITLE));
|
||||
ui->textEdit->setPlainText(QString(TAG_BODY));
|
||||
ui->lineEdit_captcha->clear();
|
||||
|
||||
// it is out of conditional because I don't want a lot of ifdef/endif
|
||||
@ -341,7 +311,7 @@ void Reportabug::updateTabs(const int index)
|
||||
ui->lineEdit_password->setPlaceholderText(QApplication::translate("Reportabug", "email"));
|
||||
ui->lineEdit_password->setEchoMode(QLineEdit::Normal);
|
||||
|
||||
gitreport->webView->load(QUrl(parseString(dynamic[QString("PUBLIC_URL")])));
|
||||
gitreport->webView->load(QUrl(parseString(QString(PUBLIC_URL))));
|
||||
disconnect(gitreport->webView, SIGNAL(loadFinished(bool)), gitreport, SLOT(gitreportLoaded(bool)));
|
||||
disconnect(gitreport->webView, SIGNAL(loadFinished(bool)), gitreport, SLOT(gitreportFinished(bool)));
|
||||
connect(gitreport->webView, SIGNAL(loadFinished(bool)), gitreport, SLOT(gitreportLoaded(bool)));
|
||||
|
@ -26,6 +26,7 @@
|
||||
#define REPORTABUG_H
|
||||
|
||||
#include <QKeyEvent>
|
||||
#include <QLocale>
|
||||
#include <QMainWindow>
|
||||
|
||||
|
||||
@ -48,11 +49,9 @@ public:
|
||||
* @brief Reportabug class constructor
|
||||
* @param parent parent object
|
||||
* @param debugCmd show debug messages
|
||||
* @param params dynamic parametrs. Needed keys are the same as in config.h
|
||||
*/
|
||||
explicit Reportabug(QWidget *parent = 0,
|
||||
bool debugCmd = false,
|
||||
QMap<QString, QString> params = QMap<QString, QString>());
|
||||
bool debugCmd = false);
|
||||
/**
|
||||
* @brief Reportabug class destructor
|
||||
*/
|
||||
@ -87,10 +86,6 @@ private:
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug;
|
||||
/**
|
||||
* @brief dynamic parametrs
|
||||
*/
|
||||
QMap<QString, QString> dynamic;
|
||||
/**
|
||||
* @brief contains information about enabled modules
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user