mirror of
https://github.com/arcan1s/awesome-widgets.git
synced 2025-04-24 23:47:20 +00:00
finally implement bug reporting (#104)
This commit is contained in:
parent
5b9984d950
commit
80d926290c
@ -31,8 +31,8 @@ QtDialogs.Dialog {
|
|||||||
id: awBugReporter
|
id: awBugReporter
|
||||||
}
|
}
|
||||||
|
|
||||||
width: 640
|
width: 480
|
||||||
height: 480
|
height: 640
|
||||||
property bool debug: awActions.isDebugEnabled()
|
property bool debug: awActions.isDebugEnabled()
|
||||||
|
|
||||||
|
|
||||||
@ -52,7 +52,7 @@ QtDialogs.Dialog {
|
|||||||
|
|
||||||
QtControls.GroupBox {
|
QtControls.GroupBox {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height / 3
|
height: parent.height / 5
|
||||||
title: i18n("Description")
|
title: i18n("Description")
|
||||||
QtControls.TextArea {
|
QtControls.TextArea {
|
||||||
id: description
|
id: description
|
||||||
@ -63,7 +63,7 @@ QtDialogs.Dialog {
|
|||||||
}
|
}
|
||||||
QtControls.GroupBox {
|
QtControls.GroupBox {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height / 3
|
height: parent.height / 5
|
||||||
title: i18n("Steps to reproduce")
|
title: i18n("Steps to reproduce")
|
||||||
QtControls.TextArea {
|
QtControls.TextArea {
|
||||||
id: reproduce
|
id: reproduce
|
||||||
@ -74,7 +74,7 @@ QtDialogs.Dialog {
|
|||||||
}
|
}
|
||||||
QtControls.GroupBox {
|
QtControls.GroupBox {
|
||||||
width: parent.width
|
width: parent.width
|
||||||
height: parent.height / 3
|
height: parent.height / 5
|
||||||
title: i18n("Expected result")
|
title: i18n("Expected result")
|
||||||
QtControls.TextArea {
|
QtControls.TextArea {
|
||||||
id: expected
|
id: expected
|
||||||
@ -83,13 +83,56 @@ QtDialogs.Dialog {
|
|||||||
textFormat: TextEdit.PlainText
|
textFormat: TextEdit.PlainText
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
QtControls.GroupBox {
|
||||||
|
width: parent.width
|
||||||
|
height: parent.height * 2 / 5
|
||||||
|
title: i18n("Logs")
|
||||||
|
Row {
|
||||||
|
id: debugCmdLabel
|
||||||
|
width: parent.width
|
||||||
|
QtControls.Label {
|
||||||
|
width: parent.width * 2 / 5
|
||||||
|
horizontalAlignment: Text.AlignJustify
|
||||||
|
verticalAlignment: Text.AlignVCenter
|
||||||
|
wrapMode: Text.WordWrap
|
||||||
|
text: i18n("Use command")
|
||||||
|
}
|
||||||
|
QtControls.TextField {
|
||||||
|
id: customTime
|
||||||
|
width: parent.width * 3 / 5
|
||||||
|
readOnly: true
|
||||||
|
text: "QT_LOGGING_RULES=*=true plasmawindowed org.kde.plasma.awesomewidget"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
QtControls.Button {
|
||||||
|
id: logButton
|
||||||
|
anchors.top: debugCmdLabel.bottom
|
||||||
|
width: parent.width
|
||||||
|
text: i18n("Load log file")
|
||||||
|
onClicked: logPath.open()
|
||||||
|
}
|
||||||
|
QtControls.TextArea {
|
||||||
|
anchors.top: logButton.bottom
|
||||||
|
anchors.bottom: parent.bottom
|
||||||
|
id: logBody
|
||||||
|
width: parent.width
|
||||||
|
textFormat: TextEdit.PlainText
|
||||||
|
}
|
||||||
|
|
||||||
|
QtDialogs.FileDialog {
|
||||||
|
id: logPath
|
||||||
|
title: i18n("Open log file")
|
||||||
|
onAccepted:
|
||||||
|
logBody.text = awActions.getFileContent(logPath.fileUrl.toString().replace("file://", ""))
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onAccepted: {
|
onAccepted: {
|
||||||
if (debug) console.debug()
|
if (debug) console.debug()
|
||||||
|
|
||||||
var text = awBugReporter.generateText(description.text, reproduce.text,
|
var text = awBugReporter.generateText(description.text, reproduce.text,
|
||||||
expected.text)
|
expected.text, logBody.text)
|
||||||
awBugReporter.sendBugReport(title.text, text)
|
awBugReporter.sendBugReport(title.text, text)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +147,8 @@ QtDialogs.Dialog {
|
|||||||
|
|
||||||
Component.onCompleted: {
|
Component.onCompleted: {
|
||||||
if (debug) console.debug()
|
if (debug) console.debug()
|
||||||
|
|
||||||
|
awBugReporter.doConnect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <KNotifications/KNotification>
|
#include <KNotifications/KNotification>
|
||||||
|
|
||||||
#include <QDesktopServices>
|
#include <QDesktopServices>
|
||||||
|
#include <QFile>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include <QUrl>
|
#include <QUrl>
|
||||||
|
|
||||||
@ -56,6 +57,23 @@ void AWActions::checkUpdates(const bool showAnyway)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QString AWActions::getFileContent(const QString path) const
|
||||||
|
{
|
||||||
|
qCDebug(LOG_AW) << "Get content from file" << path;
|
||||||
|
|
||||||
|
QFile inputFile(path);
|
||||||
|
if (!inputFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
qCWarning(LOG_AW) << "Could not open file as text"
|
||||||
|
<< inputFile.fileName();
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
|
|
||||||
|
QString output = inputFile.readAll();
|
||||||
|
inputFile.close();
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// HACK: since QML could not use QLoggingCategory I need this hack
|
// HACK: since QML could not use QLoggingCategory I need this hack
|
||||||
bool AWActions::isDebugEnabled() const
|
bool AWActions::isDebugEnabled() const
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,7 @@ public:
|
|||||||
explicit AWActions(QObject *parent = nullptr);
|
explicit AWActions(QObject *parent = nullptr);
|
||||||
virtual ~AWActions();
|
virtual ~AWActions();
|
||||||
Q_INVOKABLE void checkUpdates(const bool showAnyway = false);
|
Q_INVOKABLE void checkUpdates(const bool showAnyway = false);
|
||||||
|
Q_INVOKABLE QString getFileContent(const QString path) const;
|
||||||
Q_INVOKABLE bool isDebugEnabled() const;
|
Q_INVOKABLE bool isDebugEnabled() const;
|
||||||
Q_INVOKABLE bool runCmd(const QString cmd = QString("/usr/bin/true")) const;
|
Q_INVOKABLE bool runCmd(const QString cmd = QString("/usr/bin/true")) const;
|
||||||
Q_INVOKABLE void showReadme() const;
|
Q_INVOKABLE void showReadme() const;
|
||||||
|
@ -34,9 +34,6 @@ AWBugReporter::AWBugReporter(QObject *parent)
|
|||||||
: QObject(parent)
|
: QObject(parent)
|
||||||
{
|
{
|
||||||
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
qCDebug(LOG_AW) << __PRETTY_FUNCTION__;
|
||||||
|
|
||||||
connect(this, SIGNAL(replyReceived(const int, const QString)), this,
|
|
||||||
SLOT(showInformation(const int, const QString)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -46,20 +43,32 @@ AWBugReporter::~AWBugReporter()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void AWBugReporter::doConnect()
|
||||||
|
{
|
||||||
|
// additional method for testing needs
|
||||||
|
connect(this, SIGNAL(replyReceived(const int, const QString)), this,
|
||||||
|
SLOT(showInformation(const int, const QString)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QString AWBugReporter::generateText(const QString description,
|
QString AWBugReporter::generateText(const QString description,
|
||||||
const QString reproduce,
|
const QString reproduce,
|
||||||
const QString expected)
|
const QString expected,
|
||||||
|
const QString logs) const
|
||||||
{
|
{
|
||||||
|
// do not log logs here, it may have quite large size
|
||||||
qCDebug(LOG_AW) << "Generate text with description" << description
|
qCDebug(LOG_AW) << "Generate text with description" << description
|
||||||
<< "steps" << reproduce << "and expected result"
|
<< "steps" << reproduce << "and expected result"
|
||||||
<< expected;
|
<< expected;
|
||||||
|
|
||||||
QString output;
|
QString output;
|
||||||
output += QString("**Description**\n\n%1\n").arg(description);
|
output += QString("**Description**\n\n%1\n\n").arg(description);
|
||||||
output += QString("**Step to reproduce**\n\n%1\n").arg(reproduce);
|
output += QString("**Step to reproduce**\n\n%1\n\n").arg(reproduce);
|
||||||
output += QString("**Expected result**\n\n%1\n").arg(expected);
|
output += QString("**Expected result**\n\n%1\n\n").arg(expected);
|
||||||
output
|
output += QString("**Version**\n\n%1\n\n")
|
||||||
+= QString("**Version**\n\n%1").arg(getBuildData().join(QString("\n")));
|
.arg(getBuildData().join(QString("\n")));
|
||||||
|
// append logs
|
||||||
|
output += QString("**Logs**\n\n%1").arg(logs);
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
@ -122,16 +131,33 @@ void AWBugReporter::showInformation(const int number, const QString url)
|
|||||||
qCDebug(LOG_AW) << "Created issue with number" << number << "and url"
|
qCDebug(LOG_AW) << "Created issue with number" << number << "and url"
|
||||||
<< url;
|
<< url;
|
||||||
|
|
||||||
|
// cache url first
|
||||||
|
m_lastBugUrl = url;
|
||||||
|
|
||||||
QMessageBox *msgBox = new QMessageBox(nullptr);
|
QMessageBox *msgBox = new QMessageBox(nullptr);
|
||||||
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
msgBox->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
msgBox->setModal(false);
|
msgBox->setModal(false);
|
||||||
msgBox->setWindowTitle(i18n("Issue created"));
|
msgBox->setWindowTitle(i18n("Issue created"));
|
||||||
msgBox->setText(i18n("Issue %1 has been created"));
|
msgBox->setText(i18n("Issue %1 has been created", number));
|
||||||
msgBox->setStandardButtons(QMessageBox::Open | QMessageBox::Close);
|
msgBox->setStandardButtons(QMessageBox::Open | QMessageBox::Close);
|
||||||
msgBox->setIcon(QMessageBox::Information);
|
msgBox->setIcon(QMessageBox::Information);
|
||||||
|
|
||||||
connect(msgBox, &QMessageBox::accepted,
|
msgBox->open(this, SLOT(userReplyOnBugReport(QAbstractButton *)));
|
||||||
[this, url]() { return QDesktopServices::openUrl(url); });
|
}
|
||||||
|
|
||||||
return msgBox->open();
|
|
||||||
|
void AWBugReporter::userReplyOnBugReport(QAbstractButton *button)
|
||||||
|
{
|
||||||
|
QMessageBox::ButtonRole ret
|
||||||
|
= static_cast<QMessageBox *>(sender())->buttonRole(button);
|
||||||
|
qCInfo(LOG_AW) << "User select" << ret;
|
||||||
|
|
||||||
|
switch (ret) {
|
||||||
|
case QMessageBox::AcceptRole:
|
||||||
|
QDesktopServices::openUrl(m_lastBugUrl);
|
||||||
|
break;
|
||||||
|
case QMessageBox::RejectRole:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
|
|
||||||
|
class QAbstractButton;
|
||||||
class QNetworkReply;
|
class QNetworkReply;
|
||||||
|
|
||||||
class AWBugReporter : public QObject
|
class AWBugReporter : public QObject
|
||||||
@ -31,9 +32,11 @@ class AWBugReporter : public QObject
|
|||||||
public:
|
public:
|
||||||
explicit AWBugReporter(QObject *parent = nullptr);
|
explicit AWBugReporter(QObject *parent = nullptr);
|
||||||
virtual ~AWBugReporter();
|
virtual ~AWBugReporter();
|
||||||
|
Q_INVOKABLE void doConnect();
|
||||||
Q_INVOKABLE QString generateText(const QString description,
|
Q_INVOKABLE QString generateText(const QString description,
|
||||||
const QString reproduce,
|
const QString reproduce,
|
||||||
const QString expected);
|
const QString expected,
|
||||||
|
const QString logs) const;
|
||||||
Q_INVOKABLE void sendBugReport(const QString title, const QString body);
|
Q_INVOKABLE void sendBugReport(const QString title, const QString body);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
@ -42,8 +45,10 @@ signals:
|
|||||||
private slots:
|
private slots:
|
||||||
void issueReplyRecieved(QNetworkReply *reply);
|
void issueReplyRecieved(QNetworkReply *reply);
|
||||||
void showInformation(const int number, const QString url);
|
void showInformation(const int number, const QString url);
|
||||||
|
void userReplyOnBugReport(QAbstractButton *button);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
QString m_lastBugUrl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void BatterySource::run()
|
|||||||
{
|
{
|
||||||
// adaptor
|
// adaptor
|
||||||
QFile acFile(QString("%1/AC/online").arg(m_acpiPath));
|
QFile acFile(QString("%1/AC/online").arg(m_acpiPath));
|
||||||
if (acFile.open(QIODevice::ReadOnly))
|
if (acFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
m_values[QString("battery/ac")]
|
m_values[QString("battery/ac")]
|
||||||
= (QString(acFile.readLine()).trimmed().toInt() == 1);
|
= (QString(acFile.readLine()).trimmed().toInt() == 1);
|
||||||
acFile.close();
|
acFile.close();
|
||||||
@ -116,8 +116,8 @@ void BatterySource::run()
|
|||||||
QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i));
|
QString("%1/BAT%2/energy_now").arg(m_acpiPath).arg(i));
|
||||||
QFile fullLevelFile(
|
QFile fullLevelFile(
|
||||||
QString("%1/BAT%2/energy_full").arg(m_acpiPath).arg(i));
|
QString("%1/BAT%2/energy_full").arg(m_acpiPath).arg(i));
|
||||||
if ((currentLevelFile.open(QIODevice::ReadOnly))
|
if ((currentLevelFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
&& (fullLevelFile.open(QIODevice::ReadOnly))) {
|
&& (fullLevelFile.open(QIODevice::ReadOnly | QIODevice::Text))) {
|
||||||
float batCurrent
|
float batCurrent
|
||||||
= QString(currentLevelFile.readLine()).trimmed().toFloat();
|
= QString(currentLevelFile.readLine()).trimmed().toFloat();
|
||||||
float batFull
|
float batFull
|
||||||
|
@ -56,10 +56,14 @@ QString GPULoadSource::autoGpu()
|
|||||||
{
|
{
|
||||||
QString gpu = QString("disable");
|
QString gpu = QString("disable");
|
||||||
QFile moduleFile(QString("/proc/modules"));
|
QFile moduleFile(QString("/proc/modules"));
|
||||||
if (!moduleFile.open(QIODevice::ReadOnly))
|
if (!moduleFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
qCWarning(LOG_AW) << "Could not open file as text"
|
||||||
|
<< moduleFile.fileName();
|
||||||
return gpu;
|
return gpu;
|
||||||
|
}
|
||||||
|
|
||||||
QString output = moduleFile.readAll();
|
QString output = moduleFile.readAll();
|
||||||
|
moduleFile.close();
|
||||||
if (output.contains(QString("fglrx")))
|
if (output.contains(QString("fglrx")))
|
||||||
gpu = QString("ati");
|
gpu = QString("ati");
|
||||||
else if (output.contains(QString("nvidia")))
|
else if (output.contains(QString("nvidia")))
|
||||||
|
@ -57,10 +57,14 @@ QString GPUTemperatureSource::autoGpu()
|
|||||||
{
|
{
|
||||||
QString gpu = QString("disable");
|
QString gpu = QString("disable");
|
||||||
QFile moduleFile(QString("/proc/modules"));
|
QFile moduleFile(QString("/proc/modules"));
|
||||||
if (!moduleFile.open(QIODevice::ReadOnly))
|
if (!moduleFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
|
||||||
|
qCWarning(LOG_AW) << "Could not open file as text"
|
||||||
|
<< moduleFile.fileName();
|
||||||
return gpu;
|
return gpu;
|
||||||
|
}
|
||||||
|
|
||||||
QString output = moduleFile.readAll();
|
QString output = moduleFile.readAll();
|
||||||
|
moduleFile.close();
|
||||||
if (output.contains(QString("fglrx")))
|
if (output.contains(QString("fglrx")))
|
||||||
gpu = QString("ati");
|
gpu = QString("ati");
|
||||||
else if (output.contains(QString("nvidia")))
|
else if (output.contains(QString("nvidia")))
|
||||||
|
@ -87,15 +87,17 @@ void ProcessesSource::run()
|
|||||||
|
|
||||||
for (auto dir : directories) {
|
for (auto dir : directories) {
|
||||||
QFile statusFile(QString("/proc/%1/status").arg(dir));
|
QFile statusFile(QString("/proc/%1/status").arg(dir));
|
||||||
if (!statusFile.open(QIODevice::ReadOnly))
|
if (!statusFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
continue;
|
continue;
|
||||||
QFile cmdFile(QString("/proc/%1/cmdline").arg(dir));
|
QFile cmdFile(QString("/proc/%1/cmdline").arg(dir));
|
||||||
if (!cmdFile.open(QIODevice::ReadOnly))
|
if (!cmdFile.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
QString output = statusFile.readAll();
|
QString output = statusFile.readAll();
|
||||||
if (output.contains(QString("running")))
|
if (output.contains(QString("running")))
|
||||||
running.append(cmdFile.readAll());
|
running.append(cmdFile.readAll());
|
||||||
|
statusFile.close();
|
||||||
|
cmdFile.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
m_values[QString("ps/running/count")] = running.count();
|
m_values[QString("ps/running/count")] = running.count();
|
||||||
|
@ -38,8 +38,9 @@ void TestAWBugReporter::cleanupTestCase()
|
|||||||
|
|
||||||
void TestAWBugReporter::test_generateText()
|
void TestAWBugReporter::test_generateText()
|
||||||
{
|
{
|
||||||
data = AWTestLibrary::randomStringList(3);
|
data = AWTestLibrary::randomStringList(4);
|
||||||
QString output = plugin->generateText(data.at(0), data.at(1), data.at(2));
|
QString output
|
||||||
|
= plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3));
|
||||||
|
|
||||||
for (auto string : data)
|
for (auto string : data)
|
||||||
QVERIFY(output.contains(string));
|
QVERIFY(output.contains(string));
|
||||||
@ -51,7 +52,7 @@ void TestAWBugReporter::test_sendBugReport()
|
|||||||
QSignalSpy spy(plugin, SIGNAL(replyReceived(bool, QString)));
|
QSignalSpy spy(plugin, SIGNAL(replyReceived(bool, QString)));
|
||||||
plugin->sendBugReport(
|
plugin->sendBugReport(
|
||||||
AWTestLibrary::randomString(),
|
AWTestLibrary::randomString(),
|
||||||
plugin->generateText(data.at(0), data.at(1), data.at(2)));
|
plugin->generateText(data.at(0), data.at(1), data.at(2), data.at(3)));
|
||||||
|
|
||||||
QVERIFY(spy.wait(5000));
|
QVERIFY(spy.wait(5000));
|
||||||
QVariantList arguments = spy.takeFirst();
|
QVariantList arguments = spy.takeFirst();
|
||||||
|
Loading…
Reference in New Issue
Block a user