1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/****************************************************************************
4
* Copyright (c) 2024 The FreeCAD Project Association AISBL *
6
* This file is part of FreeCAD. *
8
* FreeCAD is free software: you can redistribute it and/or modify it *
9
* under the terms of the GNU Lesser General Public License as *
10
* published by the Free Software Foundation, either version 2.1 of the *
11
* License, or (at your option) any later version. *
13
* FreeCAD is distributed in the hope that it will be useful, but *
14
* WITHOUT ANY WARRANTY; without even the implied warranty of *
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
16
* Lesser General Public License for more details. *
18
* You should have received a copy of the GNU Lesser General Public *
19
* License along with FreeCAD. If not, see *
20
* <https://www.gnu.org/licenses/>. *
22
***************************************************************************/
24
#include "PreCompiled.h"
27
#include <QGuiApplication>
31
#include <QResizeEvent>
36
#include "FirstStartWidget.h"
37
#include "ThemeSelectorWidget.h"
38
#include "GeneralSettingsWidget.h"
40
#include <App/Application.h>
41
#include <gsl/pointers>
43
using namespace StartGui;
45
FirstStartWidget::FirstStartWidget(QWidget* parent)
47
, _themeSelectorWidget {nullptr}
48
, _generalSettingsWidget {nullptr}
49
, _welcomeLabel {nullptr}
50
, _descriptionLabel {nullptr}
51
, _doneButton {nullptr}
53
setObjectName(QLatin1String("FirstStartWidget"));
55
qApp->installEventFilter(this);
58
void FirstStartWidget::setupUi()
60
auto outerLayout = gsl::owner<QVBoxLayout*>(new QVBoxLayout(this));
61
outerLayout->addStretch();
62
QString application = QString::fromUtf8(App::Application::Config()["ExeName"].c_str());
63
_welcomeLabel = gsl::owner<QLabel*>(new QLabel);
64
outerLayout->addWidget(_welcomeLabel);
65
_descriptionLabel = gsl::owner<QLabel*>(new QLabel);
66
outerLayout->addWidget(_descriptionLabel);
68
_themeSelectorWidget = gsl::owner<ThemeSelectorWidget*>(new ThemeSelectorWidget(this));
69
_generalSettingsWidget = gsl::owner<GeneralSettingsWidget*>(new GeneralSettingsWidget(this));
71
outerLayout->addWidget(_generalSettingsWidget);
72
outerLayout->addWidget(_themeSelectorWidget);
74
_doneButton = gsl::owner<QPushButton*>(new QPushButton);
75
connect(_doneButton, &QPushButton::clicked, this, &FirstStartWidget::dismissed);
76
auto buttonBar = gsl::owner<QHBoxLayout*>(new QHBoxLayout);
77
buttonBar->addStretch();
78
buttonBar->addWidget(_doneButton);
79
outerLayout->addLayout(buttonBar);
80
outerLayout->addStretch();
85
bool FirstStartWidget::eventFilter(QObject* object, QEvent* event)
87
if (object == this && event->type() == QEvent::LanguageChange) {
88
this->retranslateUi();
90
return QWidget::eventFilter(object, event);
93
void FirstStartWidget::retranslateUi()
95
_doneButton->setText(tr("Done"));
96
QString application = QString::fromUtf8(App::Application::Config()["ExeName"].c_str());
97
_welcomeLabel->setText(QLatin1String("<h1>") + tr("Welcome to %1").arg(application)
98
+ QLatin1String("</h1>"));
99
_descriptionLabel->setText(
100
tr("To get started, set your basic configuration options below.") + QLatin1String(" ")
101
+ tr("These options (and many more) can be changed later in Preferences."));