File indexing completed on 2024-05-12 04:52:52
0001 /* 0002 SPDX-FileCopyrightText: 2016 Nicolas Carion 0003 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL 0004 */ 0005 0006 #include "fontparamwidget.hpp" 0007 #include "assets/model/assetparametermodel.hpp" 0008 0009 FontParamWidget::FontParamWidget(std::shared_ptr<AssetParameterModel> model, QModelIndex index, QWidget *parent) 0010 : AbstractParamWidget(std::move(model), index, parent) 0011 { 0012 setupUi(this); 0013 0014 // setup the comment 0015 QString comment = m_model->data(m_index, AssetParameterModel::CommentRole).toString(); 0016 setToolTip(comment); 0017 0018 // setup the name 0019 labelName->setText(m_model->data(m_index, Qt::DisplayRole).toString()); 0020 0021 // set check state 0022 slotRefresh(); 0023 setMinimumHeight(fontfamilywidget->sizeHint().height()); 0024 // Q_EMIT the signal of the base class when appropriate 0025 connect(this->fontfamilywidget, &QFontComboBox::currentFontChanged, this, [this](const QFont &font) { Q_EMIT valueChanged(m_index, font.family(), true); }); 0026 } 0027 0028 void FontParamWidget::slotShowComment(bool show) 0029 { 0030 Q_UNUSED(show); 0031 } 0032 0033 void FontParamWidget::slotRefresh() 0034 { 0035 QSignalBlocker bk(fontfamilywidget); 0036 const QString family = m_model->data(m_index, AssetParameterModel::ValueRole).toString(); 0037 fontfamilywidget->setCurrentFont(QFont(family)); 0038 }