// SPDX-License-Identifier: LGPL-2.1-or-later /**************************************************************************** * * * Copyright (c) 2024 The FreeCAD Project Association AISBL * * * * This file is part of FreeCAD. * * * * FreeCAD is free software: you can redistribute it and/or modify it * * under the terms of the GNU Lesser General Public License as * * published by the Free Software Foundation, either version 2.1 of the * * License, or (at your option) any later version. * * * * FreeCAD is distributed in the hope that it will be useful, but * * WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * * Lesser General Public License for more details. * * * * You should have received a copy of the GNU Lesser General Public * * License along with FreeCAD. If not, see * * . * * * ***************************************************************************/ #include #include #include #include #include "ThemeSelectorWidget.h" #include #include using namespace StartGui; ThemeSelectorWidget::ThemeSelectorWidget(QWidget* parent) : QWidget(parent) , _titleLabel {nullptr} , _descriptionLabel {nullptr} , _themeButton {nullptr} { setObjectName(QLatin1String("ThemeSelectorWidget")); applyKindredCreateTheme(); setupUi(); qApp->installEventFilter(this); } void ThemeSelectorWidget::applyKindredCreateTheme() { auto prefPackManager = Gui::Application::Instance->prefPackManager(); prefPackManager->apply("KindredCreate"); } void ThemeSelectorWidget::setupUi() { auto* outerLayout = gsl::owner(new QVBoxLayout(this)); auto* buttonLayout = gsl::owner(new QHBoxLayout); _titleLabel = gsl::owner(new QLabel); _descriptionLabel = gsl::owner(new QLabel); outerLayout->addWidget(_titleLabel); outerLayout->addLayout(buttonLayout); outerLayout->addWidget(_descriptionLabel); _themeButton = gsl::owner(new QToolButton()); _themeButton->setCheckable(true); _themeButton->setChecked(true); _themeButton->setToolButtonStyle(Qt::ToolButtonStyle::ToolButtonTextUnderIcon); _themeButton->setIcon(QIcon(QLatin1String(":/thumbnails/Theme_thumbnail_dark.png"))); _themeButton->setIconSize(_themeButton->icon().actualSize(QSize(256, 256))); buttonLayout->addWidget(_themeButton); retranslateUi(); } bool ThemeSelectorWidget::eventFilter(QObject* object, QEvent* event) { if (object == this && event->type() == QEvent::LanguageChange) { this->retranslateUi(); } return QWidget::eventFilter(object, event); } void ThemeSelectorWidget::retranslateUi() { _titleLabel->setText(QLatin1String("

") + tr("Theme") + QLatin1String("

")); _descriptionLabel->setText( tr("Kindred Create uses the Catppuccin Mocha theme.") ); _themeButton->setText(tr("Kindred Create", "Visual theme name")); }