summaryrefslogtreecommitdiffstats
path: root/src/Authoring/Studio/_Win/Application/AboutDlg.cpp
blob: 533a560189f86b448b50d848a8efd216e70cda6c (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
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
/****************************************************************************
**
** 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 "stdafx.h"
#include "qtAuthoring-config.h"
#include "StudioDefs.h"
#include "Strings.h"
#include "StringLoader.h"

//==============================================================================
//	Includes
//==============================================================================
#include "AboutDlg.h"
#include "ui_AboutDlg.h"
#include "ProductInfo.h"
#include "HotKeys.h"
#include "Preferences.h"
#include "StudioPreferences.h"

#include <QMouseEvent>
#include <QPainter>
#include <QTimer>

//==============================================================================
//	Constants
//==============================================================================
const int TIMER_RESIZEABOUT = 6;
const int TIMER_FADEOUT = 7;

//==============================================================================
/**
 * Constructor: Initializes the object.
 */
CAboutDlg::CAboutDlg(QWidget* parent)
    : QDialog(parent, Qt::MSWindowsFixedSizeDialogHint)
    , m_ScrollingCreditsFlag(false)
    , m_ui(new Ui::AboutDlg)
{
    m_ui->setupUi(this);
    m_IconRect = m_ui->icon->pixmap()->rect();
    setFixedSize(size());

    m_Font = QFont(CStudioPreferences::GetFontFaceName());
    m_Font.setPointSizeF(7.8);
    m_Font = QFont(CStudioPreferences::GetFontFaceName());
    m_Font.setPointSizeF(8.8);

    m_Color_Background = CStudioPreferences::GetDarkBaseColor();
    m_Color_Text = CStudioPreferences::GetNormalColor();

    OnInitDialog();
}

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

//==============================================================================
/**
 * Handles the painting of the icon in the About Box.
 * All additional painting (text, etc) occurs by default by MFC.
 */
//==============================================================================
void CAboutDlg::paintEvent(QPaintEvent* event)
{
    Q_UNUSED(event);
    if (!m_ScrollingCreditsFlag) {
        DrawFadeRect();
    }
}

//==============================================================================
/**
 * Completes the construction of the About Box.
 * Stores the product version in the member variable associated with the static
 * text box in the dialog template. This version information comes from the
 * VersionNumber.h file in $/Studio/Build.
 * @return Returns TRUE always.
 */
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
    m_Credit1Str.Format(::LoadResourceString(IDS_ABOUT_PAINTLIB_CREDIT));
#ifdef QT_3DSTUDIO_FBX
    m_Credit2Str.Format(::LoadResourceString(IDS_ABOUT_FBX_CREDIT));
#endif

#ifdef STUDIOSTORYNUM
    m_ProductVersionStr += " (Story #";
    m_ProductVersionStr += STUDIOSTORYNUM;
    m_ProductVersionStr += ")";
#endif

#ifdef BETA
    // Add "beta" to the Studio version if necessary
    m_ProductVersionStr += " BETA";
#endif

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

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

    // Add link to support email address
    Q3DStudio::CString theEmail;
    Q3DStudio::CString theEmailSansProtocol;

    theEmail = ::LoadResourceString(IDS_SUPPORTEMAIL);
    theEmailSansProtocol = "support@qt.io";

    m_ui->m_Email->setText(QString("<a href=\"%1\">%2</a>").arg(theEmail.toQString(), theEmailSansProtocol.toQString()));
    m_ui->m_Email->setToolTip(::LoadResourceString(IDS_SUPPORTEMAIL_TEXT).toQString());
    m_ui->m_Email->setOpenExternalLinks(true);

    // Set the fonts
    m_ui->m_Copyright->setFont(m_Font);
    m_ui->m_Credit1->setFont(m_Font);
    m_ui->m_Credit2->setFont(m_Font);
    m_ui->m_WebSiteLabel->setFont(m_Font);
    m_ui->m_WebSite->setFont(m_Font);
    m_ui->m_EmailLabel->setFont(m_Font);
    m_ui->m_Email->setFont(m_Font);

    // Make the font bold for version numbers
    m_ui->m_ProductVersion->setFont(m_BoldFont);

    // Create brush for background color
    m_Brush = QBrush(m_Color_Background);

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

    // Hide the email link until we have a valid one.
    m_ui->m_EmailLabel->setVisible(false);
    m_ui->m_Email->setVisible(false);
}

//==============================================================================
/**
 * Handles the WM_LBUTTONDBLCLK message
 * Check to see if the mouse is within the Qt logo and the control key is pressed.
 * If so, begin the transition to show the detailed credits.
 */
void CAboutDlg::mouseDoubleClickEvent(QMouseEvent* event)
{
    // If the mouse's left button is double-clicked in the Qt logo while the control key is
    // pressed...
    if (m_IconRect.contains(event->pos())) {
        // if ( CHotKeys::IsKeyDown( VK_CONTROL ) )
        //{
        // Start the transition to display the scrolling credits
        // Crashing...			this->BeginCreditsTransition();
        //}
    }

    QDialog::mouseDoubleClickEvent(event);
}

//==============================================================================
/**
 * BeginCreditsTransition: Begin the transition from the About box to the scrolling credits.
 */
void CAboutDlg::BeginCreditsTransition()
{
    m_ScrollingCreditsFlag = TRUE;

    // Hide all controls
    for (QWidget* w : findChildren<QWidget*>())
        w->setVisible(false);

    // Invalidate the window
    update();

    // Set the resizing timer
    QTimer::singleShot(50, this, &CAboutDlg::ResizeAbout);
}

//==============================================================================
/**
 * Resize the about box height until the Client area is square.
 */
void CAboutDlg::ResizeAbout()
{
    bool retriggerResizeAbout = true;

    QRect theClientRect = rect();
    bool theRightSize = false;

    // this is just a sizing stuff to show some transition on size
    if (theClientRect.height() < theClientRect.width()) {
        theClientRect.setBottom(theClientRect.bottom() + 5);
        if (theClientRect.bottom() >= theClientRect.width()) {
            theRightSize = true;
            theClientRect.setBottom(theClientRect.width());
            retriggerResizeAbout = false;
        }
    } else {
        theClientRect.setRight(theClientRect.right() + 5);
        if (theClientRect.right() >= theClientRect.height()) {
            theRightSize = true;
            theClientRect.setRight(theClientRect.height());
            retriggerResizeAbout = false;
        }
    }

    if (parentWidget())
        theClientRect.moveCenter(parentWidget()->geometry().center());
    else
        theClientRect.moveTopLeft(geometry().topLeft());

    setGeometry(theClientRect);

    if (theRightSize) {
        QColor the3DColor;
        short theColorValue;

        m_CreditsRect = rect().adjusted(3, 3, -3, -3);

        the3DColor = palette().color(QPalette::Base);
        theColorValue =
            (short)((the3DColor.red() + the3DColor.green() + the3DColor.blue()) / 3);

        m_ColorFade = RGB(theColorValue, theColorValue, theColorValue);

        QTimer::singleShot(50, this, &CAboutDlg::FadeOut);
    }

    if (retriggerResizeAbout) {
        QTimer::singleShot(50, this, &CAboutDlg::ResizeAbout);
    }
}

//==============================================================================
/**
 * Fade out a rectangle in the client area, from the background 3D color to black.
 */
void CAboutDlg::FadeOut()
{
    update();

    // Continue fading to black
    if (m_ColorFade != Qt::black) {
        short theColorValue;

        theColorValue = (short)(m_ColorFade.red() - 10);

        if (theColorValue < 0)
            theColorValue = 0;

        m_ColorFade = qRgb(theColorValue, theColorValue, theColorValue);
        QTimer::singleShot(50, this, &CAboutDlg::FadeOut);
    }
}

//==============================================================================
/**
 *	DrawFadeRect: Draw the faded rectangle as we transition to the scrolling credits.
 */
void CAboutDlg::DrawFadeRect()
{
    QPainter painter(this);
    painter.fillRect(m_CreditsRect, m_ColorFade);
}

void CAboutDlg::OnStnClickedAboutboxProdver()
{
    // TODO: Add your control notification handler code here
}