summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/_Win/Application/AboutDlg.cpp
blob: 4b313ee4ad611ab05042e4ad10cc2ca1bbfefcae (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
/****************************************************************************
**
** Copyright (C) 2002 NVIDIA Corporation.
** Copyright (C) 2017 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt 3D Studio.
**
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

//==============================================================================
//	Prefix
//==============================================================================
#include "StudioDefs.h"
#include "Strings.h"
#include "StringLoader.h"
#include "qtAuthoring-config.h"

//==============================================================================
//	Includes
//==============================================================================
#include "AboutDlg.h"
#include "ui_AboutDlg.h"
#include "StudioPreferences.h"

#include <QtGui/qpalette.h>

#ifdef QT3DSTUDIO_REVISION
#define STRINGIFY_INTERNAL(x) #x
#define STRINGIFY(x) STRINGIFY_INTERNAL(x)
const char *const QT3DSTUDIO_REVISION_STR = STRINGIFY(QT3DSTUDIO_REVISION);
#endif

//==============================================================================
/**
 * Constructor: Initializes the object.
 */
CAboutDlg::CAboutDlg(QWidget* parent)
    : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint)
    , m_ui(new Ui::AboutDlg)
    , m_palette(nullptr)
{
    m_ui->setupUi(this);
    OnInitDialog();
}

//==============================================================================
/**
 * Destructor: Releases the object.
 */
CAboutDlg::~CAboutDlg()
{
    delete m_palette;
}

void CAboutDlg::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event)
    if (m_palette)
        return;

    m_palette = new QPalette;
    QPixmap pic = QPixmap(":/startup/open_dialog.png");
    pic.setDevicePixelRatio(devicePixelRatio());
    m_palette->setBrush(QPalette::Window, pic);
    setPalette(*m_palette);
    resize(pic.size());
    setFixedSize(size());
}

static QString compilerString()
{
#if defined(Q_CC_CLANG) // must be before GNU, because clang claims to be GNU too
    QString isAppleString;
#if defined(__apple_build_version__) // Apple clang has other version numbers
    isAppleString = QStringLiteral(" (Apple)");
#endif
    return QStringLiteral("Clang " ) + QString::number(__clang_major__) + QStringLiteral(".")
            + QString::number(__clang_minor__) + isAppleString;
#elif defined(Q_CC_GNU)
    return QStringLiteral("GCC " ) + QStringLiteral(__VERSION__);
#elif defined(Q_CC_MSVC)
    if (_MSC_VER > 1999)
        return QStringLiteral("MSVC <unknown>");
    if (_MSC_VER >= 1910)
        return QStringLiteral("MSVC 2017");
    if (_MSC_VER >= 1900)
        return QStringLiteral("MSVC 2015");
#endif
    return QStringLiteral("<unknown compiler>");
}

void CAboutDlg::OnInitDialog()
{
    // Set the Studio version
    m_ProductVersionStr.Format(
        ::LoadResourceString(IDS_UIC_STUDIO_VERSION),
        static_cast<const wchar_t *>(CStudioPreferences::GetVersionString()));

    // Set the copyright string
    m_CopyrightStr.Format(::LoadResourceString(IDS_ABOUT_COPYRIGHT),
                          static_cast<const wchar_t *>(Q3DStudio::CString(STUDIO_COPYRIGHT_YEAR)));

    // Set the credit strings
#ifdef QT_3DSTUDIO_FBX
    m_Credit1Str.Format(::LoadResourceString(IDS_ABOUT_FBX_CREDIT));
#endif

    // Add link to Web site
    Q3DStudio::CString theURL(::LoadResourceString(IDS_HELP_VISIT_QT));

    m_ui->m_WebSite->setText(QString("<a href=\"%1\"><font color=\"#%2\">%3</font></a>").arg(
                                 theURL.toQString(),
                                 CStudioPreferences::GetMasterColor().GetString().toQString(),
                                 theURL.toQString()));
    m_ui->m_WebSite->setToolTip(::LoadResourceString(IDS_WEBSITELINK).toQString());
    m_ui->m_WebSite->setOpenExternalLinks(true);

    // Add link to support address
    Q3DStudio::CString theSupport;

    theSupport = ::LoadResourceString(IDS_SUPPORTEMAIL);

    m_ui->m_Email->setText(QString("<a href=\"%1\"><font color=\"#%2\">%3</font></a>").arg(
                               theSupport.toQString(),
                               CStudioPreferences::GetMasterColor().GetString().toQString(),
                               theSupport.toQString()));
    m_ui->m_Email->setToolTip(::LoadResourceString(IDS_SUPPORTEMAIL_TEXT).toQString());
    m_ui->m_Email->setOpenExternalLinks(true);

    // Make the font bold for version number
    m_ui->m_ProductVersion->setStyleSheet("font-weight: bold;");

    m_ui->m_ProductVersion->setText(m_ProductVersionStr.toQString());
    m_ui->m_Copyright->setText(m_CopyrightStr.toQString());
    m_ui->m_Credit1->setText(m_Credit1Str.toQString());

    // Information about build
    m_ui->m_buildTimestamp->setText(
                tr("Built on %1 %2").arg(QStringLiteral(__DATE__), QStringLiteral(__TIME__)));
    m_ui->m_qtVersion->setText(
                tr("Based on Qt %1 (%2, %3 bit)").arg(
                    QString::fromLatin1(qVersion()),
                    compilerString(),
                    QString::number(QSysInfo::WordSize)));
#ifdef QT3DSTUDIO_REVISION
    m_ui->m_revisionSHA->setText(
                tr("From revision %1").arg(
                    QString::fromLatin1(QT3DSTUDIO_REVISION_STR).left(10)));
#else
    m_ui->m_revisionSHA->setText(QString());
    m_ui->m_revisionSHA->setMaximumHeight(0);
#endif
}