|
6 | 6 | #include "ui_AboutDialog.h" |
7 | 7 |
|
8 | 8 | #include <QtGui/QDesktopServices> |
| 9 | +#include <QtGui/QPixmap> |
9 | 10 | #include <QtCore/QUrl> |
| 11 | +#include <QtWidgets/QApplication> |
| 12 | +#include <QtWidgets/QDialog> |
| 13 | +#include <QtWidgets/QDialogButtonBox> |
| 14 | +#include <QtWidgets/QPlainTextEdit> |
| 15 | +#include <QtWidgets/QVBoxLayout> |
10 | 16 |
|
11 | | -#include <project.h> |
12 | | -#include <graphics/2d.h> |
| 17 | +namespace fso::fred::dialogs { |
13 | 18 |
|
14 | | -namespace fso { |
15 | | -namespace fred { |
16 | | -namespace dialogs { |
| 19 | +AboutDialog::~AboutDialog() = default; |
17 | 20 |
|
18 | | -AboutDialog::AboutDialog(QWidget* parent) : QDialog(parent), ui(new Ui::AboutDialog()) { |
| 21 | +static QString joinLines(const SCP_vector<SCP_string>& lines) |
| 22 | +{ |
| 23 | + QStringList parts; |
| 24 | + for (const auto& line : lines) |
| 25 | + parts << QString::fromStdString(line); |
| 26 | + return parts.join('\n'); |
| 27 | +} |
| 28 | + |
| 29 | +AboutDialog::AboutDialog(QWidget* parent, EditorViewport* viewport) |
| 30 | + : QDialog(parent), |
| 31 | + ui(new Ui::AboutDialog()), |
| 32 | + _model(new AboutDialogModel(this, viewport)) |
| 33 | +{ |
19 | 34 | ui->setupUi(this); |
20 | 35 |
|
21 | | - connect(ui->buttonReportBug, &QPushButton::pressed, this, &AboutDialog::onBugPressed); |
22 | | - connect(ui->buttonVisitForums, &QPushButton::pressed, this, &AboutDialog::onForumsPressed); |
23 | | - connect(ui->buttonAboutQt, &QPushButton::pressed, this, &AboutDialog::onAboutQtPressed); |
24 | | - |
25 | | - QString graphicsAPI; |
26 | | - switch(gr_screen.mode) |
27 | | - { |
28 | | - case GR_OPENGL: |
29 | | - graphicsAPI = QString::fromUtf8("OpenGL"); |
30 | | - break; |
31 | | - case GR_VULKAN: |
32 | | - graphicsAPI = QString::fromUtf8("Vulkan"); |
33 | | - break; |
34 | | - } |
35 | | - |
36 | | - ui->labelVersion->setText(tr("qtFRED - FreeSpace Editor, Version %1 %2").arg(FS_VERSION_FULL, graphicsAPI)); |
| 36 | + connect(ui->okBox, &QDialogButtonBox::rejected, this, &QDialog::reject); |
| 37 | + |
| 38 | + ui->logoLabel->setPixmap( |
| 39 | + QPixmap(":/images/fred_about.png").scaled(128, 128, Qt::KeepAspectRatio, Qt::SmoothTransformation)); |
| 40 | + |
| 41 | + ui->labelVersion->setText(QString::fromStdString(_model->getVersionString())); |
| 42 | + ui->labelCopyright->setText(QString::fromStdString(_model->getCopyrightString())); |
| 43 | + ui->labelQtFREDCredits->setText(joinLines(_model->getQtFREDCredits())); |
| 44 | + ui->labelGraphicsCredits->setText(joinLines(_model->getGraphicsCredits())); |
| 45 | + ui->labelQuote->setText(QString::fromStdString(_model->getQuoteString())); |
37 | 46 | } |
38 | | -AboutDialog::~AboutDialog() { |
| 47 | + |
| 48 | +void AboutDialog::on_scpCreditsButton_clicked() |
| 49 | +{ |
| 50 | + auto* dialog = new QDialog(this); |
| 51 | + dialog->setWindowTitle(tr("SCP Team Credits")); |
| 52 | + dialog->setAttribute(Qt::WA_DeleteOnClose); |
| 53 | + dialog->resize(500, 600); |
| 54 | + |
| 55 | + auto* layout = new QVBoxLayout(dialog); |
| 56 | + |
| 57 | + auto* textEdit = new QPlainTextEdit(dialog); |
| 58 | + textEdit->setReadOnly(true); |
| 59 | + textEdit->setPlainText(QString::fromStdString(_model->getSCPCreditsText())); |
| 60 | + layout->addWidget(textEdit); |
| 61 | + |
| 62 | + auto* buttons = new QDialogButtonBox(QDialogButtonBox::Close, dialog); |
| 63 | + connect(buttons, &QDialogButtonBox::rejected, dialog, &QDialog::reject); |
| 64 | + layout->addWidget(buttons); |
| 65 | + |
| 66 | + dialog->show(); |
39 | 67 | } |
40 | | -void AboutDialog::onBugPressed() { |
| 68 | + |
| 69 | +void AboutDialog::on_reportBugButton_clicked() // NOLINT(readability-convert-member-functions-to-static) |
| 70 | +{ |
41 | 71 | QDesktopServices::openUrl(QUrl("https://github.com/scp-fs2open/fs2open.github.com/issues", QUrl::TolerantMode)); |
42 | 72 | } |
43 | | -void AboutDialog::onForumsPressed() { |
| 73 | + |
| 74 | +void AboutDialog::on_visitForumsButton_clicked() // NOLINT(readability-convert-member-functions-to-static) |
| 75 | +{ |
44 | 76 | QDesktopServices::openUrl(QUrl("https://www.hard-light.net/forums/", QUrl::TolerantMode)); |
45 | 77 | } |
46 | | -void AboutDialog::onAboutQtPressed() { |
| 78 | + |
| 79 | +void AboutDialog::on_aboutQtButton_clicked() // NOLINT(readability-convert-member-functions-to-static) |
| 80 | +{ |
47 | 81 | QApplication::aboutQt(); |
48 | 82 | } |
49 | 83 |
|
50 | | -} |
51 | | -} |
52 | | -} |
| 84 | +} // namespace fso::fred::dialogs |
0 commit comments