FreeCAD

Форк
0
/
FirstStartWidget.cpp 
102 строки · 4.3 Кб
1
// SPDX-License-Identifier: LGPL-2.1-or-later
2
/****************************************************************************
3
 *                                                                          *
4
 *   Copyright (c) 2024 The FreeCAD Project Association AISBL               *
5
 *                                                                          *
6
 *   This file is part of FreeCAD.                                          *
7
 *                                                                          *
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.                        *
12
 *                                                                          *
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.                        *
17
 *                                                                          *
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/>.                                       *
21
 *                                                                          *
22
 ***************************************************************************/
23

24
#include "PreCompiled.h"
25

26
#ifndef _PreComp_
27
#include <QGuiApplication>
28
#include <QHBoxLayout>
29
#include <QLabel>
30
#include <QPushButton>
31
#include <QResizeEvent>
32
#include <QVBoxLayout>
33
#include <QWidget>
34
#endif
35

36
#include "FirstStartWidget.h"
37
#include "ThemeSelectorWidget.h"
38
#include "GeneralSettingsWidget.h"
39

40
#include <App/Application.h>
41
#include <gsl/pointers>
42

43
using namespace StartGui;
44

45
FirstStartWidget::FirstStartWidget(QWidget* parent)
46
    : QGroupBox(parent)
47
    , _themeSelectorWidget {nullptr}
48
    , _generalSettingsWidget {nullptr}
49
    , _welcomeLabel {nullptr}
50
    , _descriptionLabel {nullptr}
51
    , _doneButton {nullptr}
52
{
53
    setObjectName(QLatin1String("FirstStartWidget"));
54
    setupUi();
55
    qApp->installEventFilter(this);
56
}
57

58
void FirstStartWidget::setupUi()
59
{
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);
67

68
    _themeSelectorWidget = gsl::owner<ThemeSelectorWidget*>(new ThemeSelectorWidget(this));
69
    _generalSettingsWidget = gsl::owner<GeneralSettingsWidget*>(new GeneralSettingsWidget(this));
70

71
    outerLayout->addWidget(_generalSettingsWidget);
72
    outerLayout->addWidget(_themeSelectorWidget);
73

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();
81

82
    retranslateUi();
83
}
84

85
bool FirstStartWidget::eventFilter(QObject* object, QEvent* event)
86
{
87
    if (object == this && event->type() == QEvent::LanguageChange) {
88
        this->retranslateUi();
89
    }
90
    return QWidget::eventFilter(object, event);
91
}
92

93
void FirstStartWidget::retranslateUi()
94
{
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."));
102
}
103

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.