MCPcopy Create free account
hub / github.com/LunarG/VulkanTools / WidgetSettingFloat

Method WidgetSettingFloat

vkconfig_gui/widget_setting_float.cpp:34–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

32static const int MIN_FIELD_WIDTH = 80;
33
34WidgetSettingFloat::WidgetSettingFloat(QTreeWidget* tree, QTreeWidgetItem* item, const SettingMetaFloat& meta,
35 SettingDataSet& data_set)
36 : WidgetSettingBase(tree, item),
37 meta(meta),
38 data_set(data_set),
39 field(new QLineEdit(this)),
40 timer_error(new QTimer(this)),
41 timer_valid(new QTimer(this)) {
42 const std::string unit = meta.unit.empty() ? "" : format(" (%s)", meta.unit.c_str());
43 const std::string status = meta.status == STATUS_STABLE ? "" : std::string(" (") + GetToken(this->meta.status) + ")";
44
45 this->field->setFont(tree->font());
46 this->field->setAlignment(Qt::AlignRight);
47 this->field->show();
48 this->default_palette = this->field->palette();
49
50 this->connect(this->field, SIGNAL(textEdited(const QString&)), this, SLOT(OnTextEdited(const QString&)));
51 this->connect(this->timer_error, &QTimer::timeout, this, &WidgetSettingFloat::OnErrorValue);
52 this->connect(this->timer_valid, &QTimer::timeout, this, &WidgetSettingFloat::OnValidValue);
53
54 std::string tooltip = meta.description;
55 if (meta.HasRange()) {
56 tooltip += format(" [%f, %f]", meta.min_value, meta.max_value);
57 }
58
59 this->item->setText(0, (this->meta.label + unit + status).c_str());
60 this->item->setFont(0, this->tree->font());
61 this->item->setToolTip(0, tooltip.c_str());
62 this->item->setSizeHint(0, QSize(0, ITEM_HEIGHT));
63 this->tree->setItemWidget(this->item, 0, this);
64
65 this->Refresh(REFRESH_ENABLE_AND_STATE);
66}
67
68WidgetSettingFloat::~WidgetSettingFloat() {
69 this->timer_error->stop();

Callers

nothing calls this directly

Calls 4

RefreshMethod · 0.95
HasRangeMethod · 0.80
formatFunction · 0.50
GetTokenFunction · 0.50

Tested by

no test coverage detected