mirror of
https://github.com/arcan1s/reportabug.git
synced 2025-04-24 15:27:18 +00:00
Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
653840d69f | ||
|
49ad399c62 | ||
|
064c3f502e | ||
|
33fdd14e79 |
1
.gitignore
vendored
1
.gitignore
vendored
@ -22,6 +22,7 @@ qrc_*.cpp
|
||||
ui_*.h
|
||||
Makefile*
|
||||
*-build-*
|
||||
*.qm
|
||||
|
||||
# QtCreator
|
||||
|
||||
|
10
CHANGELOG
10
CHANGELOG
@ -1,2 +1,12 @@
|
||||
Ver.1.1.0:
|
||||
+ add abillity to load parametrs dynamically
|
||||
* some fixes
|
||||
|
||||
Ver.1.0.2:
|
||||
* some fixes
|
||||
|
||||
Ver.1.0.1:
|
||||
* fix captcha
|
||||
|
||||
Ver.1.0:
|
||||
First release
|
||||
|
21
README.md
21
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 ###
|
||||
|
||||
@ -50,13 +50,11 @@ This module requires `QtNetwork` module. To enable this module set up your token
|
||||
|
||||
Available variables:
|
||||
|
||||
* `CAPTCHA_KEY` - captcha key. It may be found in the source of the `PUBLIC_URL` page. Default is `7f6ef90bce7389088a52c5c9101aad206b21b56d`.
|
||||
* `CAPTCHA_TEXT` - captcha text. It may be found in the source of the `PUBLIC_URL` page. Default is `QJNZXY`.
|
||||
* `CAPTCHA_TIME` - captcha time. It may be found in the source of the `PUBLIC_URL` page. Default is `1406531273`.
|
||||
* `CAPTCHA_URL` - captcha url, in the most cases do not touch it. Default is `https://gitreports.com/simple_captcha?code=`.
|
||||
* `GITREPORT_COMBOBOX` - text of this module into comboBox.
|
||||
* `PUBLIC_URL` - issues url, in the most cases do not touch it. Default is `https://gitreports.com/issue/$OWNER/$PROJECT`. Available tags here are `$PROJECT`, `$OWNER`.
|
||||
|
||||
This module requires `QtWebKit` module. To disable this module use `-DENABLE_GITREPORT=0` cmake flag.
|
||||
This module requires `QtWebKit` and `QtNetwork` modules. To disable this module use `-DENABLE_GITREPORT=0` cmake flag.
|
||||
|
||||
Instruction
|
||||
===========
|
||||
@ -65,17 +63,17 @@ Dependencies
|
||||
------------
|
||||
|
||||
* qt5-base (if Qt5 is used) or qt4 (if Qt4 is used)
|
||||
* qt5-network (if Qt5 is used)
|
||||
|
||||
### Optional dependencies ###
|
||||
|
||||
* qt5-network (if Qt5 is used) *(requires for GitHub module)*
|
||||
* qt5-webkit (if Qt5 is used) or qtwebkit (if Qt4 is used) *(requires for GitReport module)*
|
||||
* doxygen *(developers documentation)*
|
||||
|
||||
### Make dependencies ###
|
||||
|
||||
* automoc4
|
||||
* cmake
|
||||
* doxygen *(optional, developers documentation)*
|
||||
|
||||
Installation
|
||||
------------
|
||||
@ -102,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
|
||||
|
@ -3,7 +3,7 @@
|
||||
ARCHIVE="reportabug"
|
||||
SRCDIR="sources"
|
||||
FILES="AUTHORS CHANGELOG COPYING README.md"
|
||||
IGNORELIST="build *.cppcheck"
|
||||
IGNORELIST="build *.cppcheck *.qm"
|
||||
VERSION=$(grep -m1 PROJECT_VERSION_MAJOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_MINOR sources/CMakeLists.txt | awk '{print $3}' | cut -c 1).\
|
||||
$(grep -m1 PROJECT_VERSION_PATCH sources/CMakeLists.txt | awk '{print $3}' | cut -c 1)
|
||||
|
@ -4,6 +4,7 @@ cmake_policy (SET CMP0003 OLD)
|
||||
cmake_policy (SET CMP0002 OLD)
|
||||
cmake_policy (SET CMP0011 NEW)
|
||||
cmake_policy (SET CMP0015 NEW)
|
||||
cmake_policy (SET CMP0048 OLD)
|
||||
|
||||
project (reportabug)
|
||||
|
||||
@ -12,7 +13,7 @@ set (SUBPROJECT_AUTHOR "Evgeniy Alekseev")
|
||||
set (SUBPROJECT_CONTACT "esalexeev@gmail.com")
|
||||
set (SUBPROJECT_LICENSE "LGPLv3")
|
||||
set (SUBPROJECT_VERSION_MAJOR 1)
|
||||
set (SUBPROJECT_VERSION_MINOR 0)
|
||||
set (SUBPROJECT_VERSION_MINOR 1)
|
||||
set (SUBPROJECT_VERSION_PATCH 0)
|
||||
set (SUBPROJECT_VERSION ${SUBPROJECT_VERSION_MAJOR}.${SUBPROJECT_VERSION_MINOR}.${SUBPROJECT_VERSION_PATCH})
|
||||
string (TIMESTAMP CURRENT_DATE "%Y-%m-%d %H:%M" UTC)
|
||||
@ -23,11 +24,12 @@ message (STATUS "Version: ${SUBPROJECT_VERSION}")
|
||||
message (STATUS "Build date: ${CURRENT_DATE}")
|
||||
|
||||
# install options
|
||||
option (BUILD_AS_LIBRARY "Build the application as a shared library" ON)
|
||||
option (BUILD_DOCS "Build developers documentation" OFF)
|
||||
option (ENABLE_GITHUB "Enable GitHub module" ON)
|
||||
option (ENABLE_GITREPORT "Enable GitReport module" ON)
|
||||
option (USE_QT5 "Use Qt5 instead of Qt4" ON)
|
||||
set (BUILD_AS_LIBRARY ON CACHE BOOL "Build the application as a 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")
|
||||
set (OWN_GITHUB_TOKEN "" CACHE STRING "Use own GitHub token instead of GitReport")
|
||||
# set flags
|
||||
if (OWN_GITHUB_TOKEN STREQUAL "")
|
||||
@ -38,6 +40,11 @@ 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)
|
||||
|
1
sources/reportabug.h
Symbolic link
1
sources/reportabug.h
Symbolic link
@ -0,0 +1 @@
|
||||
src/reportabug.h
|
@ -1,17 +1,16 @@
|
||||
# set files
|
||||
set (SOURCES main.cpp reportabug.cpp)
|
||||
set (HEADERS reportabug.h)
|
||||
set (FORMS reportabug.ui)
|
||||
set (SOURCES ${SUBPROJECT_SOURCE_DIR}/main.cpp ${SUBPROJECT_SOURCE_DIR}/reportabug.cpp)
|
||||
set (HEADERS ${SUBPROJECT_SOURCE_DIR}/reportabug.h ${SUBPROJECT_SOURCE_DIR}/config.h)
|
||||
set (FORMS ${SUBPROJECT_SOURCE_DIR}/reportabug.ui)
|
||||
if (ENABLE_GITHUB OR USE_OWN_TOKEN)
|
||||
set (SOURCES ${SOURCES} githubmodule.cpp)
|
||||
set (HEADERS ${HEADERS} githubmodule.h)
|
||||
set (SOURCES ${SOURCES} ${SUBPROJECT_SOURCE_DIR}/githubmodule.cpp)
|
||||
set (HEADERS ${HEADERS} ${SUBPROJECT_SOURCE_DIR}/githubmodule.h)
|
||||
endif ()
|
||||
if (ENABLE_GITREPORT)
|
||||
set (SOURCES ${SOURCES} gitreportmodule.cpp)
|
||||
set (HEADERS ${HEADERS} gitreportmodule.h)
|
||||
set (SOURCES ${SOURCES} ${SUBPROJECT_SOURCE_DIR}/gitreportmodule.cpp)
|
||||
set (HEADERS ${HEADERS} ${SUBPROJECT_SOURCE_DIR}/gitreportmodule.h)
|
||||
endif ()
|
||||
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
configure_file (${CMAKE_CURRENT_SOURCE_DIR}/inconfig.h.in ${CMAKE_CURRENT_BINARY_DIR}/inconfig.h)
|
||||
|
||||
# include_path
|
||||
@ -22,16 +21,12 @@ include_directories (${CMAKE_CURRENT_BINARY_DIR}/../
|
||||
if (USE_QT5)
|
||||
find_package (Qt5Core REQUIRED)
|
||||
find_package (Qt5Widgets REQUIRED)
|
||||
find_package (Qt5Network REQUIRED)
|
||||
add_definitions (${Qt5Core_DEFINITIONS})
|
||||
add_definitions (${Qt5Widgets_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS})
|
||||
set (QT_USED_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES})
|
||||
if (ENABLE_GITHUB OR USE_OWN_TOKEN)
|
||||
find_package (Qt5Network REQUIRED)
|
||||
add_definitions (${Qt5Network_DEFINITIONS})
|
||||
include_directories (${Qt5Network_INCLUDE_DIRS})
|
||||
set (QT_USED_LIBRARIES ${QT_USED_LIBRARIES} ${Qt5Network_LIBRARIES})
|
||||
endif ()
|
||||
add_definitions (${Qt5Network_DEFINITIONS})
|
||||
include_directories (${Qt5Core_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Network_INCLUDE_DIRS})
|
||||
set (QT_USED_LIBRARIES ${Qt5Core_LIBRARIES} ${Qt5Widgets_LIBRARIES} ${Qt5Network_LIBRARIES})
|
||||
if (ENABLE_GITREPORT)
|
||||
find_package (Qt5WebKit REQUIRED)
|
||||
find_package (Qt5WebKitWidgets REQUIRED)
|
||||
@ -42,25 +37,14 @@ if (USE_QT5)
|
||||
endif ()
|
||||
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
|
||||
qt5_wrap_ui (UI_HEADERS ${FORMS})
|
||||
|
||||
source_group ("Header Files" FILES ${HEADERS})
|
||||
source_group ("Source Files" FILES ${SOURCES})
|
||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||
|
||||
else ()
|
||||
set (QT_USED_COMPONENTS QtCore QtGui)
|
||||
if (ENABLE_GITHUB OR USE_OWN_TOKEN)
|
||||
set (QT_USED_COMPONENTS ${QT_USED_COMPONENTS} QtNetwork)
|
||||
endif ()
|
||||
set (QT_USED_COMPONENTS QtCore QtGui QtNetwork)
|
||||
if (ENABLE_GITREPORT)
|
||||
set (QT_USED_COMPONENTS ${QT_USED_COMPONENTS} QtWebKit)
|
||||
endif ()
|
||||
find_package(Qt4 COMPONENTS ${QT_USED_COMPONENTS} REQUIRED)
|
||||
include (${QT_USE_FILE})
|
||||
set (QT_USED_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY})
|
||||
if (ENABLE_GITHUB OR USE_OWN_TOKEN)
|
||||
set (QT_USED_LIBRARIES ${QT_USED_LIBRARIES} ${QT_QTNETWORK_LIBRARY})
|
||||
endif ()
|
||||
set (QT_USED_LIBRARIES ${QT_QTCORE_LIBRARY} ${QT_QTGUI_LIBRARY} ${QT_QTNETWORK_LIBRARY})
|
||||
if (ENABLE_GITREPORT)
|
||||
set (QT_USED_LIBRARIES ${QT_USED_LIBRARIES} ${QT_QTWEBKIT_LIBRARY})
|
||||
endif ()
|
||||
@ -68,19 +52,17 @@ else ()
|
||||
qt4_wrap_ui (UI_HEADERS ${FORMS})
|
||||
endif()
|
||||
|
||||
source_group ("Header Files" FILES ${HEADERS})
|
||||
source_group ("Source Files" FILES ${SOURCES})
|
||||
source_group ("Generated Files" FILES ${MOC_SOURCES})
|
||||
|
||||
if (BUILD_AS_LIBRARY)
|
||||
add_library (${SUBPROJECT} SHARED ${SOURCES} ${HEADERS} ${MOC_SOURCES})
|
||||
add_library (${SUBPROJECT} ${LIBPROP} ${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)
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION lib)
|
||||
if (BUILD_SHARED_LIBRARY)
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION lib)
|
||||
endif ()
|
||||
else ()
|
||||
install (TARGETS ${SUBPROJECT} DESTINATION bin)
|
||||
endif ()
|
||||
|
@ -69,10 +69,8 @@
|
||||
// public link; in the most cases do not touch it
|
||||
// available tags are $PROJECT, $OWNER
|
||||
#define PUBLIC_URL "https://gitreports.com/issue/$OWNER/$PROJECT"
|
||||
// captcha
|
||||
#define CAPTCHA_KEY "7f6ef90bce7389088a52c5c9101aad206b21b56d"
|
||||
#define CAPTCHA_TEXT "QJNZXY"
|
||||
#define CAPTCHA_TIME "1406531273"
|
||||
// captcha url; in the most cases do not touch it
|
||||
#define CAPTCHA_URL "https://gitreports.com/simple_captcha?code="
|
||||
|
||||
|
||||
#endif /* CONFIG_H */
|
@ -35,8 +35,6 @@
|
||||
#include <QNetworkRequest>
|
||||
#include <QUrl>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
/**
|
||||
* @class GithubModule
|
||||
@ -44,9 +42,10 @@
|
||||
/**
|
||||
* @fn GithubModule
|
||||
*/
|
||||
GithubModule::GithubModule(QWidget *parent, bool debugCmd)
|
||||
GithubModule::GithubModule(QWidget *parent, bool debugCmd, QMap<QString, QString> 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("<br>"));
|
||||
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<labels.count(); i++)
|
||||
labels[i] = QString("\"") + labels[i] + QString("\"");
|
||||
requestList.append(QString("\"labels\":[") + labels.join(QChar(',')) + QString("]"));
|
||||
@ -105,11 +104,11 @@ QString GithubModule::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;
|
||||
@ -136,7 +135,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(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");
|
||||
@ -159,7 +158,7 @@ void GithubModule::githubFinished(QNetworkReply *reply)
|
||||
if (debug) qDebug() << "[GithubModule]" << "[githubFinished]" << ":" << "Error state" << reply->error();
|
||||
if (debug) qDebug() << "[GithubModule]" << "[githubFinished]" << ":" << "Reply size" << reply->readBufferSize();
|
||||
|
||||
int state = true;
|
||||
bool state = true;
|
||||
QString answer = reply->readAll();
|
||||
if (debug) qDebug() << "[GithubModule]" << "[replyFinished]" << ":" << answer;
|
||||
QString messageBody, messageTitle;
|
||||
@ -189,6 +188,7 @@ void GithubModule::githubFinished(QNetworkReply *reply)
|
||||
icon = QMessageBox::Critical;
|
||||
state = false;
|
||||
}
|
||||
reply->deleteLater();
|
||||
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(messageTitle);
|
||||
|
@ -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<QString, QString> params = QMap<QString, QString>());
|
||||
/**
|
||||
* @brief GithubModule class destructor
|
||||
*/
|
||||
@ -91,6 +93,10 @@ private:
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug;
|
||||
/**
|
||||
* @brief dynamic parametrs
|
||||
*/
|
||||
QMap<QString, QString> dynamic;
|
||||
/**
|
||||
* @brief Reportabug class
|
||||
*/
|
||||
|
@ -29,13 +29,14 @@
|
||||
#include <QDebug>
|
||||
#include <QGridLayout>
|
||||
#include <QMessageBox>
|
||||
#include <QNetworkAccessManager>
|
||||
#include <QNetworkReply>
|
||||
#include <QNetworkRequest>
|
||||
#include <QPushButton>
|
||||
#include <QUrl>
|
||||
#include <QWebElement>
|
||||
#include <QWebFrame>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
|
||||
/**
|
||||
* @class GitreportModule
|
||||
@ -43,9 +44,10 @@
|
||||
/**
|
||||
* @fn GitreportModule
|
||||
*/
|
||||
GitreportModule::GitreportModule(QWidget *parent, bool debugCmd)
|
||||
GitreportModule::GitreportModule(QWidget *parent, bool debugCmd, QMap<QString, QString> params)
|
||||
: QObject(parent),
|
||||
debug(debugCmd),
|
||||
dynamic(params),
|
||||
mainWindow((Reportabug *)parent)
|
||||
{
|
||||
webView = new QWebView();
|
||||
@ -71,9 +73,7 @@ void GitreportModule::sendReportUsingGitreport(const QMap<QString, QString> info
|
||||
if (debug) qDebug() << "[GitreportModule]" << "[sendReportUsingGitreport]";
|
||||
|
||||
QWebElement document = webView->page()->mainFrame()->documentElement();
|
||||
QWebElement captcha = document.findFirst(QString("input#captcha"));
|
||||
QWebElement captchaImg = document.findFirst(QString("img#[alt=captcha]"));
|
||||
QWebElement captchaKey = document.findFirst(QString("input#captcha_key"));
|
||||
QWebElement captchaKey = document.findFirst(QString("input#captcha"));
|
||||
QWebElement emailInput = document.findFirst(QString("input#email"));
|
||||
QWebElement textArea = document.findFirst(QString("textarea#details"));
|
||||
QWebElement usernameInput = document.findFirst(QString("input#name"));
|
||||
@ -82,12 +82,7 @@ void GitreportModule::sendReportUsingGitreport(const QMap<QString, QString> info
|
||||
usernameInput.setAttribute(QString("value"), info[QString("username")]);
|
||||
emailInput.setAttribute(QString("value"), info[QString("password")]);
|
||||
textArea.setPlainText(info[QString("body")]);
|
||||
// captcha
|
||||
captchaImg.setAttribute(QString("src"), QString("/simple_captcha?code=%1&time=%2")
|
||||
.arg(QString(CAPTCHA_KEY))
|
||||
.arg(QString(CAPTCHA_TIME)));
|
||||
captchaKey.setAttribute(QString("value"), QString(CAPTCHA_KEY));
|
||||
captcha.setAttribute(QString("value"), QString(CAPTCHA_TEXT));
|
||||
captchaKey.setAttribute(QString("value"), info[QString("captcha")]);
|
||||
|
||||
// send request
|
||||
document.findFirst(QString("input[name=commit]")).evaluateJavaScript("this.click()");
|
||||
@ -105,8 +100,17 @@ void GitreportModule::gitreportLoaded(const bool state)
|
||||
if (debug) qDebug() << "[GitreportModule]" << "[gitreportLoaded]";
|
||||
if (debug) qDebug() << "[GitreportModule]" << "[gitreportLoaded]" << ":" << "State" << state;
|
||||
|
||||
if (state)
|
||||
if (state) {
|
||||
webView->setHidden(!debug);
|
||||
// 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"));
|
||||
QNetworkRequest request(captchaUrl);
|
||||
manager.get(request);
|
||||
disconnect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(setCaptcha(QNetworkReply *)));
|
||||
connect(&manager, SIGNAL(finished(QNetworkReply *)), this, SLOT(setCaptcha(QNetworkReply *)));
|
||||
}
|
||||
else {
|
||||
QMessageBox messageBox;
|
||||
messageBox.setText(QApplication::translate("Reportabug", "Error!"));
|
||||
@ -165,3 +169,20 @@ void GitreportModule::gitreportFinished(const bool state)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn setCaptcha
|
||||
*/
|
||||
void GitreportModule::setCaptcha(QNetworkReply *reply)
|
||||
{
|
||||
if (debug) qDebug() << "[setCaptcha]" << "[setCaptcha]";
|
||||
if (debug) qDebug() << "[setCaptcha]" << "[setCaptcha]" << ":" << "Error state" << reply->error();
|
||||
if (debug) qDebug() << "[setCaptcha]" << "[setCaptcha]" << ":" << "Reply size" << reply->readBufferSize();
|
||||
|
||||
QByteArray answer = reply->readAll();
|
||||
QPixmap captcha;
|
||||
captcha.loadFromData(answer);
|
||||
mainWindow->setCaptchaImage(captcha);
|
||||
reply->deleteLater();
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
#include <QObject>
|
||||
#include <QWebView>
|
||||
|
||||
class QNetworkAccessManager;
|
||||
class Reportabug;
|
||||
|
||||
/**
|
||||
@ -37,7 +38,7 @@ class Reportabug;
|
||||
* creating an issue. Please visit [this page](https://gitreports.com/)
|
||||
* and set up it for your repository.
|
||||
*
|
||||
* This module depends on QtWebKit module.
|
||||
* This module depends on QtWebKit and QtNetwork modules.
|
||||
*/
|
||||
class GitreportModule : public QObject
|
||||
{
|
||||
@ -48,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<QString, QString> params = QMap<QString, QString>());
|
||||
/**
|
||||
* @brief GitreportModule class destructor
|
||||
*/
|
||||
@ -81,16 +84,29 @@ private slots:
|
||||
* @param bool state of web page loading
|
||||
*/
|
||||
void gitreportLoaded(const bool state);
|
||||
/**
|
||||
* @brief method which will be called after loading captcha image
|
||||
* @param reply reply of the request
|
||||
*/
|
||||
void setCaptcha(QNetworkReply *reply);
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug;
|
||||
/**
|
||||
* @brief dynamic parametrs
|
||||
*/
|
||||
QMap<QString, QString> dynamic;
|
||||
/**
|
||||
* @brief Reportabug class
|
||||
*/
|
||||
Reportabug *mainWindow;;
|
||||
Reportabug *mainWindow;
|
||||
/**
|
||||
* @brief manager for getting captcha
|
||||
*/
|
||||
QNetworkAccessManager manager;
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,11 +44,41 @@
|
||||
/**
|
||||
* @fn Reportabug
|
||||
*/
|
||||
Reportabug::Reportabug(QWidget *parent, bool debugCmd)
|
||||
Reportabug::Reportabug(QWidget *parent, bool debugCmd, QMap<QString, QString> 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();
|
||||
@ -84,6 +114,17 @@ void Reportabug::externalUpdateTab()
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn setCaptchaImage
|
||||
*/
|
||||
void Reportabug::setCaptchaImage(QPixmap captcha)
|
||||
{
|
||||
if (debug) qDebug() << "[Reportabug]" << "[setCaptchaImage]";
|
||||
|
||||
ui->label_captcha->setPixmap(captcha);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @fn createActions
|
||||
*/
|
||||
@ -106,9 +147,9 @@ void Reportabug::createComboBox()
|
||||
|
||||
ui->comboBox->clear();
|
||||
if (modules[0])
|
||||
ui->comboBox->addItem(QApplication::translate("Reportabug", GITHUB_COMBOBOX));
|
||||
ui->comboBox->addItem(dynamic[QString("GITHUB_COMBOBOX")]);
|
||||
if (modules[1] || modules[2])
|
||||
ui->comboBox->addItem(QApplication::translate("Reportabug", GITREPORT_COMBOBOX));
|
||||
ui->comboBox->addItem(dynamic[QString("GITREPORT_COMBOBOX")]);
|
||||
}
|
||||
|
||||
|
||||
@ -167,7 +208,7 @@ void Reportabug::initModules()
|
||||
modules[1] = true;
|
||||
gitreport = new GitreportModule(this, debug);
|
||||
// 4 is a magic number. Seriously
|
||||
ui->verticalLayout->insertWidget(4, gitreport->webView);
|
||||
ui->verticalLayout->insertWidget(5, gitreport->webView);
|
||||
#endif /* ENABLE_GITREPORT */
|
||||
#ifdef OWN_GITHUB_TOKEN
|
||||
modules[2] = true;
|
||||
@ -197,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;
|
||||
@ -218,6 +259,7 @@ void Reportabug::sendReport()
|
||||
int number = getNumberByIndex(ui->comboBox->currentIndex());
|
||||
QMap<QString, QString> info;
|
||||
info[QString("body")] = ui->textEdit->toPlainText();
|
||||
info[QString("captcha")] = ui->lineEdit_captcha->text();
|
||||
info[QString("password")] = ui->lineEdit_password->text();
|
||||
info[QString("title")] = ui->lineEdit_title->text();
|
||||
info[QString("username")] = ui->lineEdit_username->text();
|
||||
@ -262,8 +304,9 @@ 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
|
||||
#ifdef ENABLE_GITREPORT
|
||||
@ -273,12 +316,14 @@ void Reportabug::updateTabs(const int index)
|
||||
ui->widget_auth->setHidden(true);
|
||||
ui->widget_title->setHidden(true);
|
||||
ui->textEdit->setHidden(true);
|
||||
ui->widget_captcha->setHidden(true);
|
||||
}
|
||||
#ifdef ENABLE_GITHUB
|
||||
else if (number == 0) {
|
||||
ui->widget_auth->setHidden(false);
|
||||
ui->widget_title->setHidden(false);
|
||||
ui->textEdit->setHidden(false);
|
||||
ui->widget_captcha->setHidden(true);
|
||||
ui->label_password->setText(QApplication::translate("Reportabug", "Password"));
|
||||
ui->label_password->setToolTip(QApplication::translate("Reportabug", "GitHub account password"));
|
||||
ui->lineEdit_password->setPlaceholderText(QApplication::translate("Reportabug", "password"));
|
||||
@ -290,12 +335,13 @@ void Reportabug::updateTabs(const int index)
|
||||
ui->widget_auth->setHidden(false);
|
||||
ui->widget_title->setHidden(true);
|
||||
ui->textEdit->setHidden(false);
|
||||
ui->widget_captcha->setHidden(false);
|
||||
ui->label_password->setText(QApplication::translate("Reportabug", "Email"));
|
||||
ui->label_password->setToolTip(QApplication::translate("Reportabug", "Your email"));
|
||||
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)));
|
||||
|
@ -48,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<QString, QString> params = QMap<QString, QString>());
|
||||
/**
|
||||
* @brief Reportabug class destructor
|
||||
*/
|
||||
@ -59,6 +61,11 @@ public:
|
||||
* @brief method which is used for update tabs from external classes
|
||||
*/
|
||||
void externalUpdateTab();
|
||||
/**
|
||||
* @brief method which sets captcha image
|
||||
* @param captcha captcha image
|
||||
*/
|
||||
void setCaptchaImage(QPixmap captcha);
|
||||
|
||||
public slots:
|
||||
/**
|
||||
@ -80,6 +87,10 @@ private:
|
||||
* @brief show debug messages
|
||||
*/
|
||||
bool debug;
|
||||
/**
|
||||
* @brief dynamic parametrs
|
||||
*/
|
||||
QMap<QString, QString> dynamic;
|
||||
/**
|
||||
* @brief contains information about enabled modules
|
||||
*/
|
||||
|
@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>543</width>
|
||||
<height>374</height>
|
||||
<width>541</width>
|
||||
<height>372</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@ -109,6 +109,26 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QWidget" name="widget_captcha" native="true">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_captcha">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_captcha">
|
||||
<property name="placeholderText">
|
||||
<string>captcha</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QDialogButtonBox" name="buttonBox">
|
||||
<property name="standardButtons">
|
||||
|
Loading…
Reference in New Issue
Block a user