All Classes Namespaces Functions Variables Enumerations Properties Pages
aboutdialog.cpp
1 /*
2 
3 Pencil2D - Traditional Animation Software
4 Copyright (C) 2012-2020 Matthew Chiawen Chang
5 
6 This program is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public License
8 as published by the Free Software Foundation; version 2 of the License.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
14 
15 */
16 
17 #include "aboutdialog.h"
18 #include "ui_aboutdialog.h"
19 
20 #include <QPushButton>
21 #include <QSysInfo>
22 #include <QClipboard>
23 
24 #include "pencildef.h"
25 
26 
27 AboutDialog::AboutDialog(QWidget* parent) :
28  QDialog(parent),
29  ui(new Ui::AboutDialog)
30 {
31  ui->setupUi(this);
32 
34 }
35 
36 AboutDialog::~AboutDialog()
37 {
38  delete ui;
39 }
40 
41 void AboutDialog::init()
42 {
43  QStringList devText;
44 
45 #if defined(PENCIL2D_RELEASE_BUILD)
46  devText << tr("Version: %1", "Version Number in About Dialog").arg(APP_VERSION);
47 #elif defined(PENCIL2D_NIGHTLY_BUILD)
48  devText << "Nightly Build " __DATE__;
49 #else
50  devText << "Development Build " __DATE__;
51 #endif
52 
53  devText << ""; // An empty line
54 
55 #if defined(GIT_EXISTS)
56  devText << "commit: " S__GIT_COMMIT_HASH
57  << "date: " S__GIT_TIMESTAMP
58  << "";
59 #endif
60 
61  devText << QString("Operating System: %1").arg(QSysInfo::prettyProductName())
62  << QString("CPU Architecture: %1").arg(QSysInfo::buildCpuArchitecture());
63  if(QString(qVersion()) == QT_VERSION_STR)
64  {
65  devText << QString("Qt Version: %1").arg(QT_VERSION_STR);
66  }
67  else
68  {
69  devText << QString("Compile-Time Qt Version: %1").arg(QT_VERSION_STR)
70  << QString("Runtime Qt Version: %1").arg(qVersion());
71  }
72  ui->devInfoText->setText(devText.join("<br>"));
73 
74  QPushButton* copyToClipboardButton = new QPushButton(tr("Copy to clipboard", "Copy system info from About Dialog"));
75  connect(copyToClipboardButton, &QPushButton::clicked, this, [devText]
76  {
77  QApplication::clipboard()->setText(devText.join("\n"));
78  });
79  ui->buttonBox->addButton(copyToClipboardButton, QDialogButtonBox::ActionRole);
80 }
void setupUi(QWidget *widget)
QString join(const QString &separator) const const
QString tr(const char *sourceText, const char *disambiguation, int n)
void clicked(bool checked)
QString buildCpuArchitecture()
QString prettyProductName()
QString arg(qlonglong a, int fieldWidth, int base, QChar fillChar) const const
void setText(const QString &text, QClipboard::Mode mode)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QClipboard * clipboard()