Skip to content

Commit 37ab451

Browse files
committed
GUI: Add help link to the manual and report problem button
1 parent 687cddf commit 37ab451

File tree

3 files changed

+54
-1
lines changed

3 files changed

+54
-1
lines changed

src/gui/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,8 @@ target_compile_definitions(gui
147147
APP_GIT=\"${MAIN_PROJECT_HOMEPAGE_URL}\"
148148
APP_NAME=\"${MAIN_PROJECT_NAME}\"
149149
APP_VERSION=\"${MAIN_PROJECT_VERSION}\"
150+
APP_USER_MANUAL_URL=\"https://comparch.edu.cvut.cz/qtrvsim/manual\"
151+
APP_REPORT_PROBLEM_URL=\"https://github.com/cvut/qtrvsim/issues/new\"
150152
ENV_CONFIG_FILE_NAME=\"${MAIN_PROJECT_NAME_UPPER}_CONFIG_FILE\")
151153
set_target_properties(gui PROPERTIES
152154
OUTPUT_NAME "${MAIN_PROJECT_NAME_LOWER}_${PROJECT_NAME}")
@@ -181,4 +183,3 @@ install(TARGETS gui
181183
RUNTIME DESTINATION bin
182184
BUNDLE DESTINATION ${EXECUTABLE_OUTPUT_PATH}
183185
)
184-

src/gui/mainwindow/MainWindow.ui

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@
126126
<property name="title">
127127
<string>&amp;Help</string>
128128
</property>
129+
<addaction name="actionUserManual"/>
130+
<addaction name="actionReportProblem"/>
131+
<addaction name="separator"/>
129132
<addaction name="actionAbout"/>
130133
<addaction name="actionAboutQt"/>
131134
</widget>
@@ -567,6 +570,16 @@
567570
<string>About &amp;Qt</string>
568571
</property>
569572
</action>
573+
<action name="actionUserManual">
574+
<property name="text">
575+
<string>&amp;User Manual</string>
576+
</property>
577+
</action>
578+
<action name="actionReportProblem">
579+
<property name="text">
580+
<string>&amp;Report a Problem...</string>
581+
</property>
582+
</action>
570583
<action name="actionPeripherals">
571584
<property name="text">
572585
<string>P&amp;eripherals</string>

src/gui/mainwindow/mainwindow.cpp

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,21 @@
1212
#include "windows/editor/editordock.h"
1313
#include "windows/editor/editortab.h"
1414

15+
#include <QDesktopServices>
1516
#include <QFileInfo>
1617
#include <QMessageBox>
1718
#include <QMetaObject>
1819
#include <QProcessEnvironment>
20+
#include <QSysInfo>
1921
#include <QTextDocument>
22+
#include <QUrl>
23+
#include <QUrlQuery>
2024
#include <QtWidgets>
2125
#include <qactiongroup.h>
2226
#include <qwidget.h>
2327

28+
29+
2430
LOG_CATEGORY("gui.mainwindow");
2531

2632
#ifdef __EMSCRIPTEN__
@@ -183,6 +189,39 @@ MainWindow::MainWindow(QSettings *settings, QWidget *parent)
183189
connect(ui->actionCore_View_show, &QAction::triggered, this, &MainWindow::show_hide_coreview);
184190
connect(ui->actionMessages, &QAction::triggered, this, &MainWindow::show_messages);
185191
connect(ui->actionResetWindows, &QAction::triggered, this, &MainWindow::reset_windows);
192+
connect(ui->actionUserManual, &QAction::triggered, this, [] {
193+
QDesktopServices::openUrl(QUrl(APP_USER_MANUAL_URL));
194+
});
195+
connect(ui->actionReportProblem, &QAction::triggered, this, [] {
196+
const QString version = QString::fromUtf8(APP_VERSION);
197+
const QString qtVersion = QString::fromUtf8(qVersion());
198+
const QString os = QSysInfo::prettyProductName();
199+
const QString arch = QSysInfo::currentCpuArchitecture();
200+
201+
QString body;
202+
body += "## Describe the problem\n";
203+
body += "\n";
204+
body += "## Steps to reproduce\n";
205+
body += "1.\n";
206+
body += "\n";
207+
body += "## Expected behavior\n";
208+
body += "\n";
209+
body += "## Actual behavior\n";
210+
body += "\n";
211+
body += "## Environment\n";
212+
body += "- QtRVSim version: " + version + "\n";
213+
body += "- OS: " + os + "\n";
214+
body += "- Arch: " + arch + "\n";
215+
body += "- Qt: " + qtVersion + "\n";
216+
217+
QUrl url(QString::fromUtf8(APP_REPORT_PROBLEM_URL));
218+
QUrlQuery query;
219+
query.addQueryItem("title", "Bug report");
220+
query.addQueryItem("body", body);
221+
url.setQuery(query);
222+
223+
QDesktopServices::openUrl(url);
224+
});
186225
connect(ui->actionAbout, &QAction::triggered, this, &MainWindow::about_program);
187226
connect(ui->actionAboutQt, &QAction::triggered, this, &MainWindow::about_qt);
188227
connect(ui->ips1, &QAction::toggled, this, &MainWindow::set_speed);

0 commit comments

Comments
 (0)