2016-08-29 15:41:11 +02:00
|
|
|
#include "./aboutdialog.h"
|
|
|
|
#include "../misc/dialogutils.h"
|
|
|
|
|
|
|
|
#include "ui_aboutdialog.h"
|
|
|
|
|
2018-03-18 18:21:40 +01:00
|
|
|
#include <c++utilities/application/argumentparser.h>
|
|
|
|
|
2016-08-29 15:41:11 +02:00
|
|
|
#include <QApplication>
|
|
|
|
#include <QDesktopWidget>
|
2017-05-01 03:16:25 +02:00
|
|
|
#include <QGraphicsPixmapItem>
|
2018-03-18 18:21:40 +01:00
|
|
|
#include <QStringBuilder>
|
2016-08-29 15:41:11 +02:00
|
|
|
#include <QStyle>
|
|
|
|
|
|
|
|
/*!
|
2019-06-10 21:57:46 +02:00
|
|
|
* \brief The QtUtilities namespace contains all utilities provided by the qtutilities library.
|
|
|
|
*/
|
|
|
|
namespace QtUtilities {
|
2016-08-29 15:41:11 +02:00
|
|
|
|
|
|
|
/*!
|
2019-06-10 21:57:46 +02:00
|
|
|
* \class AboutDialog
|
2016-08-29 15:41:11 +02:00
|
|
|
* \brief The AboutDialog class provides a simple about dialog.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Constructs an about dialog with the provided information.
|
|
|
|
* \param parent Specifies the parent widget.
|
2017-05-04 22:46:37 +02:00
|
|
|
* \param applicationName Specifies the name of the application. If empty,
|
|
|
|
* QApplication::applicationName() will be used.
|
|
|
|
* \param creator Specifies the creator of the application. If empty,
|
|
|
|
* QApplication::organizationName() will be used.
|
|
|
|
* \param version Specifies the version of the application. If empty,
|
|
|
|
* QApplication::applicationVersion() will be used.
|
2018-03-18 18:21:40 +01:00
|
|
|
* \param dependencyVersions Specifies the dependency versions which were present at link-time. If empty,
|
2019-09-04 18:46:02 +02:00
|
|
|
* the application info from c++utilities is used.
|
2016-08-29 15:41:11 +02:00
|
|
|
* \param description Specifies a short description about the application.
|
2019-07-20 20:15:40 +02:00
|
|
|
* \param website Specifies the URL to the website of the application.
|
2017-05-04 22:46:37 +02:00
|
|
|
* \param image Specifies the application icon. If the image is null, the
|
|
|
|
* standard information icon will be used.
|
2016-08-29 15:41:11 +02:00
|
|
|
*/
|
2018-03-18 18:21:40 +01:00
|
|
|
AboutDialog::AboutDialog(QWidget *parent, const QString &applicationName, const QString &creator, const QString &version,
|
2018-05-08 00:37:14 +02:00
|
|
|
const std::vector<const char *> &dependencyVersions, const QString &website, const QString &description, const QImage &image)
|
2017-05-01 03:16:25 +02:00
|
|
|
: QDialog(parent)
|
|
|
|
, m_ui(new Ui::AboutDialog)
|
2016-08-29 15:41:11 +02:00
|
|
|
{
|
|
|
|
m_ui->setupUi(this);
|
|
|
|
makeHeading(m_ui->productNameLabel);
|
|
|
|
setStyleSheet(dialogStyle());
|
|
|
|
setWindowFlags(Qt::Tool);
|
2017-05-01 03:16:25 +02:00
|
|
|
if (!applicationName.isEmpty()) {
|
2016-08-29 15:41:11 +02:00
|
|
|
m_ui->productNameLabel->setText(applicationName);
|
2017-05-01 03:16:25 +02:00
|
|
|
} else if (!QApplication::applicationDisplayName().isEmpty()) {
|
2016-08-29 15:41:11 +02:00
|
|
|
m_ui->productNameLabel->setText(QApplication::applicationDisplayName());
|
|
|
|
} else {
|
|
|
|
m_ui->productNameLabel->setText(QApplication::applicationName());
|
|
|
|
}
|
2019-02-17 23:37:46 +01:00
|
|
|
if (creator.startsWith(QLatin1Char('<'))) {
|
|
|
|
// assing rich text as-is
|
|
|
|
m_ui->creatorLabel->setText(creator);
|
|
|
|
} else {
|
|
|
|
// add "developed by " before creator name
|
|
|
|
m_ui->creatorLabel->setText(tr("developed by %1").arg(creator.isEmpty() ? QApplication::organizationName() : creator));
|
|
|
|
}
|
2016-08-29 15:41:11 +02:00
|
|
|
m_ui->versionLabel->setText(version.isEmpty() ? QApplication::applicationVersion() : version);
|
2019-06-10 21:57:46 +02:00
|
|
|
const auto &deps(dependencyVersions.size() ? dependencyVersions : CppUtilities::applicationInfo.dependencyVersions);
|
2019-05-04 22:16:46 +02:00
|
|
|
if (!deps.empty()) {
|
2018-03-18 18:21:40 +01:00
|
|
|
QStringList linkedAgainst;
|
2019-05-04 22:16:46 +02:00
|
|
|
linkedAgainst.reserve(static_cast<int>(deps.size()));
|
2018-05-08 00:37:14 +02:00
|
|
|
for (const auto &dependencyVersion : deps) {
|
2018-03-18 18:21:40 +01:00
|
|
|
linkedAgainst << QString::fromUtf8(dependencyVersion);
|
|
|
|
}
|
|
|
|
m_ui->versionLabel->setToolTip(QStringLiteral("<p>") % tr("Linked against:") % QStringLiteral("</p><ul><li>")
|
|
|
|
% linkedAgainst.join(QStringLiteral("</li><li>")) % QStringLiteral("</li></ul>"));
|
|
|
|
}
|
2019-07-20 20:31:39 +02:00
|
|
|
if (!website.isEmpty() || CppUtilities::applicationInfo.url) {
|
2019-07-20 20:15:40 +02:00
|
|
|
m_ui->websiteLabel->setText(tr("For updates and bug reports visit the <a href=\"%1\" "
|
|
|
|
"style=\"text-decoration: underline; color: palette(link);\">project "
|
|
|
|
"website</a>.")
|
2019-07-20 20:31:39 +02:00
|
|
|
.arg(!website.isEmpty() ? website : QString::fromUtf8(CppUtilities::applicationInfo.url)));
|
2019-07-20 20:15:40 +02:00
|
|
|
} else {
|
|
|
|
m_ui->websiteLabel->hide();
|
|
|
|
}
|
2019-06-10 21:57:46 +02:00
|
|
|
m_ui->descLabel->setText(description.isEmpty() && CppUtilities::applicationInfo.description
|
|
|
|
? QString::fromUtf8(CppUtilities::applicationInfo.description)
|
2019-05-05 18:40:34 +02:00
|
|
|
: description);
|
2016-08-29 15:41:11 +02:00
|
|
|
m_iconScene = new QGraphicsScene(this);
|
|
|
|
auto *item = image.isNull()
|
2017-05-01 03:16:25 +02:00
|
|
|
? new QGraphicsPixmapItem(QApplication::style()->standardIcon(QStyle::SP_MessageBoxInformation, nullptr, this).pixmap(128))
|
|
|
|
: new QGraphicsPixmapItem(QPixmap::fromImage(image));
|
2016-08-29 15:41:11 +02:00
|
|
|
m_iconScene->addItem(item);
|
|
|
|
m_ui->graphicsView->setScene(m_iconScene);
|
2019-05-04 22:16:46 +02:00
|
|
|
centerWidget(this, parentWidget());
|
2016-08-29 15:41:11 +02:00
|
|
|
}
|
|
|
|
|
2019-05-05 18:40:34 +02:00
|
|
|
/*!
|
|
|
|
* \brief Constructs an about dialog with the specified information.
|
|
|
|
*/
|
2018-03-18 18:21:40 +01:00
|
|
|
AboutDialog::AboutDialog(QWidget *parent, const QString &applicationName, const QString &creator, const QString &version, const QString &website,
|
|
|
|
const QString &description, const QImage &image)
|
|
|
|
: AboutDialog(parent, applicationName, creator, version, {}, website, description, image)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-08-29 15:41:11 +02:00
|
|
|
/*!
|
2017-05-04 22:46:37 +02:00
|
|
|
* \brief Constructs an about dialog with the specified \a parent, \a
|
|
|
|
* description and \a image.
|
2016-08-29 15:41:11 +02:00
|
|
|
*/
|
2019-07-20 20:15:40 +02:00
|
|
|
AboutDialog::AboutDialog(QWidget *parent, const QString &website, const QString &description, const QImage &image)
|
|
|
|
: AboutDialog(parent, QString(), QString(), QString(), website, description, image)
|
2017-05-01 03:16:25 +02:00
|
|
|
{
|
|
|
|
}
|
2016-08-29 15:41:11 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Destroys the about dialog.
|
|
|
|
*/
|
|
|
|
AboutDialog::~AboutDialog()
|
2017-05-01 03:16:25 +02:00
|
|
|
{
|
|
|
|
}
|
2019-06-10 21:57:46 +02:00
|
|
|
} // namespace QtUtilities
|