From 653840d69f317cf8cef8f4d6dd1757b6c26534ba Mon Sep 17 00:00:00 2001 From: arcan1s Date: Fri, 1 Aug 2014 09:17:04 +0400 Subject: [PATCH] release 1.1.0 --- CHANGELOG | 4 +++ README.md | 11 +++++--- sources/src/githubmodule.cpp | 23 ++++++++--------- sources/src/githubmodule.h | 8 +++++- sources/src/gitreportmodule.cpp | 7 +++-- sources/src/gitreportmodule.h | 8 +++++- sources/src/reportabug.cpp | 46 +++++++++++++++++++++++++++------ sources/src/reportabug.h | 9 +++++-- 8 files changed, 84 insertions(+), 32 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8631294..bee1457 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +Ver.1.1.0: ++ add abillity to load parametrs dynamically +* some fixes + Ver.1.0.2: * some fixes diff --git a/README.md b/README.md index e1669d2..791ddf1 100644 --- a/README.md +++ b/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.in` 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` header. Configuration ------------- -Edit `src/config.h.in` header and set up needed variables. +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`). ### Main configuration ### @@ -100,15 +100,18 @@ Installation * declare class in you sources. For example: - Reportabug *reportWindow = new Reportabug(this, false); + Reportabug *reportWindow = new Reportabug(parent=this, + debugCmd=false, + params=0); reportWindow->showWindow(); * link your application with this library ### Available cmake flags ### -* `-DBUILD_AS_LIBRARY:BOOL=0` - build the application but not a shared library +* `-DBUILD_AS_LIBRARY:BOOL=0` - build the application but not a 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 diff --git a/sources/src/githubmodule.cpp b/sources/src/githubmodule.cpp index e71e6c5..470284b 100644 --- a/sources/src/githubmodule.cpp +++ b/sources/src/githubmodule.cpp @@ -35,8 +35,6 @@ #include #include -#include "config.h" - /** * @class GithubModule @@ -44,9 +42,10 @@ /** * @fn GithubModule */ -GithubModule::GithubModule(QWidget *parent, bool debugCmd) +GithubModule::GithubModule(QWidget *parent, bool debugCmd, QMap params) : QObject(parent), debug(debugCmd), + dynamic(params), mainWindow((Reportabug *)parent) { } @@ -75,12 +74,12 @@ QByteArray GithubModule::prepareRequest(const QString title, const QString body) QString fixBody = body; fixBody.replace(QString("\n"), QString("
")); requestList.append(QString("\"body\":\"") + fixBody + QString("\"")); - 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(',')); + 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(',')); for (int i=0; i info) QByteArray text = prepareRequest(info[QString("title")], info[QString("body")]); QByteArray textSize = QByteArray::number(text.size()); // sending request - QNetworkRequest request = QNetworkRequest(parseString(QString(ISSUES_URL))); + QNetworkRequest request = QNetworkRequest(parseString(dynamic[QString("ISSUES_URL")])); request.setRawHeader("Authorization", headerData.toLocal8Bit()); request.setRawHeader("User-Agent", "reportabug"); request.setRawHeader("Host", "api.github.com"); diff --git a/sources/src/githubmodule.h b/sources/src/githubmodule.h index 81d3aa8..4fa7345 100644 --- a/sources/src/githubmodule.h +++ b/sources/src/githubmodule.h @@ -59,9 +59,11 @@ 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); + bool debugCmd = false, + QMap params = QMap()); /** * @brief GithubModule class destructor */ @@ -91,6 +93,10 @@ private: * @brief show debug messages */ bool debug; + /** + * @brief dynamic parametrs + */ + QMap dynamic; /** * @brief Reportabug class */ diff --git a/sources/src/gitreportmodule.cpp b/sources/src/gitreportmodule.cpp index d8690c2..accde72 100644 --- a/sources/src/gitreportmodule.cpp +++ b/sources/src/gitreportmodule.cpp @@ -37,8 +37,6 @@ #include #include -#include "config.h" - /** * @class GitreportModule @@ -46,9 +44,10 @@ /** * @fn GitreportModule */ -GitreportModule::GitreportModule(QWidget *parent, bool debugCmd) +GitreportModule::GitreportModule(QWidget *parent, bool debugCmd, QMap params) : QObject(parent), debug(debugCmd), + dynamic(params), mainWindow((Reportabug *)parent) { webView = new QWebView(); @@ -106,7 +105,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(CAPTCHA_URL) + captchaImg.attribute(QString("value")); + QString captchaUrl = QString(dynamic[QString("CAPTCHA_URL")]) + captchaImg.attribute(QString("value")); QNetworkRequest request(captchaUrl); manager.get(request); disconnect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(setCaptcha(QNetworkReply *))); diff --git a/sources/src/gitreportmodule.h b/sources/src/gitreportmodule.h index aa55013..62b1f5f 100644 --- a/sources/src/gitreportmodule.h +++ b/sources/src/gitreportmodule.h @@ -49,9 +49,11 @@ 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); + bool debugCmd = false, + QMap params = QMap()); /** * @brief GitreportModule class destructor */ @@ -93,6 +95,10 @@ private: * @brief show debug messages */ bool debug; + /** + * @brief dynamic parametrs + */ + QMap dynamic; /** * @brief Reportabug class */ diff --git a/sources/src/reportabug.cpp b/sources/src/reportabug.cpp index 18dfd11..a15f68f 100644 --- a/sources/src/reportabug.cpp +++ b/sources/src/reportabug.cpp @@ -44,11 +44,41 @@ /** * @fn Reportabug */ -Reportabug::Reportabug(QWidget *parent, bool debugCmd) +Reportabug::Reportabug(QWidget *parent, bool debugCmd, QMap params) : 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(); @@ -117,9 +147,9 @@ void Reportabug::createComboBox() ui->comboBox->clear(); if (modules[0]) - ui->comboBox->addItem(GITHUB_COMBOBOX); + ui->comboBox->addItem(dynamic[QString("GITHUB_COMBOBOX")]); if (modules[1] || modules[2]) - ui->comboBox->addItem(GITREPORT_COMBOBOX); + ui->comboBox->addItem(dynamic[QString("GITREPORT_COMBOBOX")]); } @@ -208,11 +238,11 @@ QString Reportabug::parseString(QString line) if (line.contains(QString("$OWNER"))) line = line.split(QString("$OWNER"))[0] + - QString(OWNER) + + dynamic[QString("OWNER")] + line.split(QString("$OWNER"))[1]; if (line.contains(QString("$PROJECT"))) line = line.split(QString("$PROJECT"))[0] + - QString(PROJECT) + + dynamic[QString("PROJECT")] + line.split(QString("$PROJECT"))[1]; return line; @@ -274,8 +304,8 @@ void Reportabug::updateTabs(const int index) int number = getNumberByIndex(index); ui->lineEdit_username->clear(); ui->lineEdit_password->clear(); - ui->lineEdit_title->setText(QString(TAG_TITLE)); - ui->textEdit->setPlainText(QString(TAG_BODY)); + ui->lineEdit_title->setText(dynamic[QString("TAG_TITLE")]); + ui->textEdit->setPlainText(dynamic[QString("TAG_BODY")]); ui->lineEdit_captcha->clear(); // it is out of conditional because I don't want a lot of ifdef/endif @@ -311,7 +341,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(QString(PUBLIC_URL)))); + gitreport->webView->load(QUrl(parseString(dynamic[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))); diff --git a/sources/src/reportabug.h b/sources/src/reportabug.h index 1c10618..963f44a 100644 --- a/sources/src/reportabug.h +++ b/sources/src/reportabug.h @@ -26,7 +26,6 @@ #define REPORTABUG_H #include -#include #include @@ -49,9 +48,11 @@ 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); + bool debugCmd = false, + QMap params = QMap()); /** * @brief Reportabug class destructor */ @@ -86,6 +87,10 @@ private: * @brief show debug messages */ bool debug; + /** + * @brief dynamic parametrs + */ + QMap dynamic; /** * @brief contains information about enabled modules */