init files

This commit is contained in:
arcan1s 2014-07-27 18:50:28 +04:00
parent d7e08d4fd6
commit 04f998554d
6 changed files with 408 additions and 7 deletions

View File

@ -14,7 +14,6 @@ if (USE_QT5)
find_package (Qt5Widgets REQUIRED)
add_definitions (${Qt5Core_DEFINITIONS})
add_definitions (${Qt5Widgets_DEFINITIONS})
add_definitions(${Qt5LinguistTools_DEFINITIONS})
qt5_wrap_cpp (MOC_SOURCES ${HEADERS})
qt5_wrap_ui (UI_HEADERS ${FORMS})

61
sources/src/config.h Normal file
View File

@ -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 */

View File

@ -18,7 +18,7 @@
#include <QApplication>
#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();
}

148
sources/src/reportabug.cpp Normal file
View File

@ -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 <QDebug>
#include <QPushButton>
#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()
{
}

60
sources/src/reportabug.h Normal file
View File

@ -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 <QKeyEvent>
#include <QMainWindow>
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 */

133
sources/src/reportabug.ui Normal file
View File

@ -0,0 +1,133 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>Reportabug</class>
<widget class="QMainWindow" name="Reportabug">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>547</width>
<height>378</height>
</rect>
</property>
<property name="windowTitle">
<string>Report a bug</string>
</property>
<widget class="QWidget" name="centralwidget">
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QComboBox" name="comboBox"/>
</item>
<item>
<widget class="QStackedWidget" name="stackedWidget">
<widget class="QWidget" name="page_null"/>
<widget class="QWidget" name="page_github">
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<layout class="QHBoxLayout" name="layout_auth">
<item>
<widget class="QLabel" name="label_username">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Username</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_username">
<property name="toolTip">
<string>Your GitHub account</string>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_password">
<property name="minimumSize">
<size>
<width>100</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Password</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_password">
<property name="toolTip">
<string>GitHub account password</string>
</property>
<property name="echoMode">
<enum>QLineEdit::Password</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="layout_title">
<item>
<widget class="QLabel" name="label_title">
<property name="minimumSize">
<size>
<width>150</width>
<height>0</height>
</size>
</property>
<property name="text">
<string>Title</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEdit_title">
<property name="toolTip">
<string>Title of the report</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<widget class="QPlainTextEdit" name="plainTextEdit">
<property name="toolTip">
<string>Text of the report</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="page_gitreport">
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<widget class="QLineEdit" name="lineEdit"/>
</item>
</layout>
</widget>
</widget>
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="standardButtons">
<set>QDialogButtonBox::Close|QDialogButtonBox::Ok</set>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QStatusBar" name="statusbar"/>
<action name="actionClose">
<property name="text">
<string>Close</string>
</property>
</action>
</widget>
<resources/>
<connections/>
</ui>