Krita Source Code Documentation
Loading...
Searching...
No Matches
kbugreport.cpp
Go to the documentation of this file.
1/* This file is part of the KDE project
2 SPDX-FileCopyrightText: 1999 David Faure <faure@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6
7#include "kbugreport.h"
8
9#include <QProcess>
10#include <QCoreApplication>
11#include <QDialogButtonBox>
12#include <QPushButton>
13#include <QLayout>
14#include <QRadioButton>
15#include <QGroupBox>
16#include <QLocale>
17#include <QCloseEvent>
18#include <QLabel>
19#include <QUrl>
20#include <QUrlQuery>
21#include <QStandardPaths>
22#include <QLineEdit>
23#include <QDebug>
24#include <QTextEdit>
25#include <QDesktopServices>
26#include <QStandardPaths>
27#include <QClipboard>
28#include <QGuiApplication>
29#include <QFile>
30
31#include <kaboutdata.h>
32#include <kconfig.h>
33#include <kconfiggroup.h>
34#include <kemailsettings.h>
35#include <klocalizedstring.h>
36#include <kmessagebox.h>
37
38#include <ktitlewidget.h>
39#include <kwidgetsaddons_version.h>
40#include <kstandardguiitem.h>
41
42#include "systeminformation_p.h"
43
44#include "config-xmlgui.h"
45
46#include <kis_icon_utils.h>
47
49{
50public:
51 KisKBugReportPrivate(KisKBugReport *q): q(q), m_aboutData(KAboutData::applicationData()) {}
52
53 void _k_updateUrl();
54
55 KisKBugReport *q {nullptr};
56 QProcess *m_process {nullptr};
57 KAboutData m_aboutData;
58
59 QTextEdit *m_lineedit {nullptr};
60 QLineEdit *m_subject {nullptr};
61 QLabel *m_version {nullptr};
62 QString m_strVersion;
63 QGroupBox *m_bgSeverity {nullptr};
64
65 QLabel *lblApplicationName {nullptr};
66 QString lastError;
67 QString appname;
68 QString os;
69 QUrl url;
72 {
73 for (int i = 0; i < severityButtons.count(); i++)
74 if (severityButtons[i]->isChecked()) {
75 return i;
76 }
77 return -1;
78 }
79};
80
81KisKBugReport::KisKBugReport(const KAboutData &aboutData, QWidget *_parent)
82 : QDialog(_parent), d(new KisKBugReportPrivate(this))
83{
84 setWindowTitle(i18n("Submit Bug Report"));
85
86 QDialogButtonBox *buttonBox = new QDialogButtonBox(this);
87 buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
88 KGuiItem::assign(buttonBox->button(QDialogButtonBox::Ok), KStandardGuiItem::ok());
89 KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::cancel());
90 connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
91 connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
92
93 d->m_aboutData = aboutData;
94 d->m_process = 0;
95 KGuiItem::assign(buttonBox->button(QDialogButtonBox::Cancel), KStandardGuiItem::close());
96
97 QLabel *tmpLabel;
98 QVBoxLayout *lay = new QVBoxLayout(this);
99
100 KTitleWidget *title = new KTitleWidget(this);
101 title->setText(i18n("Submit Bug Report"));
102
103#if KWIDGETSADDONS_VERSION_MAJOR > 5 || (KWIDGETSADDONS_VERSION_MAJOR == 5 && KWIDGETSADDONS_VERSION_MINOR >= 72)
104 title->setIcon(KisIconUtils::loadIcon(QStringLiteral("tools-report-bug")));
105#else
106 title->setPixmap(KisIconUtils::loadIcon(QStringLiteral("tools-report-bug")).pixmap(32));
107#endif
108
109 lay->addWidget(title);
110
111 QGridLayout *glay = new QGridLayout();
112 lay->addLayout(glay);
113
114 int row = 0;
115
116 // Program name
117 QString qwtstr = i18n("The application for which you wish to submit a bug report - if incorrect, please use the Report Bug menu item of the correct application");
118 tmpLabel = new QLabel(i18n("Application: "), this);
119 glay->addWidget(tmpLabel, row, 0);
120 tmpLabel->setWhatsThis(qwtstr);
121 d->lblApplicationName = new QLabel(this);
122 d->lblApplicationName->setWhatsThis(qwtstr);
123
124 d->appname = d->m_aboutData.productName();
125 d->lblApplicationName->setText(d->appname);
126
127 glay->addWidget(d->lblApplicationName, row, 1);
128
129 tmpLabel->setWhatsThis(qwtstr);
130
131 // Version
132 qwtstr = i18n("The version of this application - please make sure that no newer version is available before sending a bug report");
133 tmpLabel = new QLabel(i18n("Version:"), this);
134 glay->addWidget(tmpLabel, ++row, 0);
135 tmpLabel->setWhatsThis(qwtstr);
136 d->m_strVersion = d->m_aboutData.version();
137 if (d->m_strVersion.isEmpty()) {
138 d->m_strVersion = i18n("no version set (programmer error)");
139 }
140 d->m_version = new QLabel(d->m_strVersion, this);
141 d->m_version->setTextInteractionFlags(Qt::TextBrowserInteraction);
142 //glay->addWidget( d->m_version, row, 1 );
143 glay->addWidget(d->m_version, row, 1, 1, 2);
144 d->m_version->setWhatsThis(qwtstr);
145
146 tmpLabel = new QLabel(i18n("OS:"), this);
147 glay->addWidget(tmpLabel, ++row, 0);
149
150 tmpLabel = new QLabel(d->os, this);
151 tmpLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
152 glay->addWidget(tmpLabel, row, 1, 1, 2);
153
154 // Point to the web form
155
156 lay->addSpacing(10);
157 QString text = i18n("<qt>"
158 "<p>Please read <b><a href=\"https://docs.krita.org/en/untranslatable_pages/reporting_bugs.html\">this guide</a></b> for reporting bugs first!</p>"
159 "<p>To submit a bug report, click on the button below. This will open a web browser "
160 "window on <a href=\"https://bugs.kde.org\">https://bugs.kde.org</a> where you will find "
161 "a form to fill in. </p>"
162 "<p><b>Please paste the following information into the bug report!</b></p>"
163 "</qt>");
164 QLabel *label = new QLabel(text, this);
165 label->setOpenExternalLinks(true);
166 label->setTextInteractionFlags(Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard);
167 label->setWordWrap(true);
168 lay->addWidget(label);
169 lay->addSpacing(10);
170
171 QByteArray additionalInformation;
172 QFile sysinfo(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita-sysinfo.log");
173 if (sysinfo.exists()) {
174 sysinfo.open(QFile::ReadOnly);
175 additionalInformation += sysinfo.readAll();
176 sysinfo.close();
177 }
178
179 additionalInformation += "\n---------------------\n";
180
181 QFile log(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/krita.log");
182 if (log.exists()) {
183 log.open(QFile::ReadOnly);
184 additionalInformation += log.readAll();
185 log.close();
186 }
187
188 additionalInformation += "\n---------------------\n";
189
190 QFile crashes(QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation) + "/kritacrash.log");
191 if (crashes.exists()) {
192 crashes.open(QFile::ReadOnly);
193 additionalInformation += crashes.readAll();
194 crashes.close();
195 }
196
197 QTextEdit *buginfo = new QTextEdit(this);
198 buginfo->setText(QString::fromUtf8(additionalInformation));
199 lay->addWidget(buginfo);
200
201 QClipboard *clipboard = QGuiApplication::clipboard();
202 clipboard->setText(QString::fromUtf8(additionalInformation));
203
204 d->_k_updateUrl();
205
206 QPushButton *okButton = buttonBox->button(QDialogButtonBox::Ok);
207 okButton->setText(i18n("&Submit Bug Report"));
208 okButton->setIcon(KisIconUtils::loadIcon(QStringLiteral("tools-report-bug")));
209 lay->addWidget(buttonBox);
210 setMinimumHeight(sizeHint().height() + 20); // WORKAROUND: prevent "cropped" qcombobox
211}
212
214{
215 delete d;
216}
217
219{
220 url = QUrl(QStringLiteral("https://bugs.kde.org/enter_bug.cgi"));
221 QUrlQuery query;
222 query.addQueryItem(QStringLiteral("format"), QLatin1String("guided")); // use the guided form
223
224 // the string format is product/component, where component is optional
225 QStringList list = QStringList() << appname;
226 query.addQueryItem(QStringLiteral("product"), list[0]);
227 if (list.size() == 2) {
228 query.addQueryItem(QStringLiteral("component"), list[1]);
229 }
230
231 query.addQueryItem(QStringLiteral("version"), m_strVersion);
232
233 // TODO: guess and fill OS(sys_os) and Platform(rep_platform) fields
234#ifdef Q_OS_WIN
235 query.addQueryItem(QStringLiteral("op_sys"), QStringLiteral("MS Windows"));
236 query.addQueryItem(QStringLiteral("rep_platform"), QStringLiteral("MS Windows"));
237#endif
238
239 url.setQuery(query);
240}
241
243{
244 QDesktopServices::openUrl(d->url);
245}
246
247
248#include "moc_kbugreport.cpp"
QList< QString > QStringList
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
QLineEdit * m_subject
QLabel * lblApplicationName
QGroupBox * m_bgSeverity
QTextEdit * m_lineedit
KisKBugReportPrivate(KisKBugReport *q)
KisKBugReport * q
QList< QRadioButton * > severityButtons
A dialog box for sending bug reports.
Definition kbugreport.h:29
KisKBugReport(const KAboutData &aboutData, QWidget *parent=0L)
void accept() override
~KisKBugReport() override
KisKBugReportPrivate *const d
Definition kbugreport.h:61
QIcon loadIcon(const QString &name)