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
|
/****************************************************************************
**
** 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$
**
****************************************************************************/
#include "StudioTutorialWidget.h"
#include "ui_StudioTutorialWidget.h"
#include "StudioUtils.h"
#include "StudioApp.h"
#include "StudioPreferences.h"
#include <QtWidgets/qdesktopwidget.h>
#include <QtGui/qpainter.h>
#include <QtGui/qbrush.h>
#include <QtCore/qtimer.h>
#include <QtGui/qdesktopservices.h>
#include <QtCore/qurl.h>
StudioTutorialWidget::StudioTutorialWidget(QWidget *parent) :
QDialog(parent, Qt::MSWindowsFixedSizeDialogHint),
m_ui(new Ui::StudioTutorialWidget)
{
m_ui->setupUi(this);
connect(m_ui->studioTutorialShowAgain, &QCheckBox::stateChanged, this,
&StudioTutorialWidget::handleDoNotShowAgainChange);
connect(m_ui->studioTutorialNew, &QPushButton::clicked, this,
&StudioTutorialWidget::handleCreateNew);
connect(m_ui->studioTutorialOpen, &QPushButton::clicked, this,
&StudioTutorialWidget::handleOpenSample);
connect(m_ui->studioTutorialQuickStart, &QPushButton::clicked, this,
&StudioTutorialWidget::handleQuickStartGuide);
QTimer::singleShot(0, this, &StudioTutorialWidget::OnInitDialog);
setWindowFlags(windowFlags() & ~Qt::WindowContextHelpButtonHint);
}
StudioTutorialWidget::~StudioTutorialWidget()
{
delete m_ui;
delete m_backgroundPalette;
}
void StudioTutorialWidget::OnInitDialog()
{
QSize backgroundSize = size();
QRect screenRect = QApplication::desktop()->availableGeometry(
QApplication::desktop()->screenNumber(this));
QSize windowSize = screenRect.size();
move(screenRect.x() + (windowSize.width() - backgroundSize.width()) / 2,
screenRect.y() + (windowSize.height() - backgroundSize.height()) / 2);
setFixedSize(backgroundSize);
QSettings settings;
m_ui->studioTutorialShowAgain->setChecked(!settings.value("showWelcomeScreen").toBool());
m_backgroundPalette = new QPalette(palette());
QPixmap background(size());
QPainter backgroundPainter(&background);
QLinearGradient gradient = CStudioPreferences::welcomeBackgroundGradient();
gradient.setFinalStop(background.width(), 0.0);
backgroundPainter.fillRect(background.rect(), gradient);
QPixmap laptop(":/images/welcomedialog/laptop.png");
backgroundPainter.drawPixmap(0, 100, laptop.width(), laptop.height(), laptop);
backgroundPainter.end();
m_backgroundPalette->setBrush(backgroundRole(), QBrush(background));
setAutoFillBackground(true);
setPalette(*m_backgroundPalette);
}
void StudioTutorialWidget::handleDoNotShowAgainChange(int state)
{
QSettings settings;
const bool show = !(state == Qt::Checked);
settings.setValue("showWelcomeScreen", show);
}
void StudioTutorialWidget::handleOpenSample()
{
this->done(StudioTutorialWidget::openSampleResult);
}
void StudioTutorialWidget::handleCreateNew()
{
this->done(StudioTutorialWidget::createNewResult);
}
void StudioTutorialWidget::handleQuickStartGuide()
{
QFile theFile(g_StudioApp.m_gettingStartedFilePath);
if (theFile.exists())
QDesktopServices::openUrl(QUrl::fromLocalFile(theFile.fileName()));
}
|