| 154 | } |
| 155 | |
| 156 | void WidgetSettingEnum::Resize() { |
| 157 | // resizeEvent was never call yet |
| 158 | if (this->last_resize.width() == 0 || this->last_resize.height() == 0) { |
| 159 | return; |
| 160 | } |
| 161 | |
| 162 | int width = MIN_FIELD_WIDTH; |
| 163 | |
| 164 | const QFontMetrics fm = this->field->fontMetrics(); |
| 165 | |
| 166 | if (meta.default_value == "${VP_DEFAULT}") { |
| 167 | const std::vector<std::string>& profiles = GetProfileNames(data_set); |
| 168 | for (std::size_t i = 0, n = profiles.size(); i < n; ++i) { |
| 169 | width = std::max(width, HorizontalAdvance(fm, (profiles[i] + "0000").c_str())); |
| 170 | } |
| 171 | } else if (meta.default_value == "${VP_PHYSICAL_DEVICES}") { |
| 172 | const std::vector<VulkanPhysicalDeviceInfo>& physical_device_infos = Configurator::Get().vulkan_system_info.physicalDevices; |
| 173 | for (std::size_t i = 0, n = physical_device_infos.size(); i < n; ++i) { |
| 174 | width = std::max(width, HorizontalAdvance(fm, (physical_device_infos[i].deviceName + std::string("000")).c_str())); |
| 175 | } |
| 176 | } else { |
| 177 | for (std::size_t i = 0, n = this->meta.enum_values.size(); i < n; ++i) { |
| 178 | width = std::max(width, HorizontalAdvance(fm, (this->meta.enum_values[i].label + "0000").c_str())); |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | const int prefix_width = HorizontalAdvance(fm, this->item->text(0) + "0"); |
| 183 | |
| 184 | width = std::min(width, this->last_resize.width() - prefix_width); |
| 185 | |
| 186 | const QRect button_rect(this->last_resize.width() - width, 0, width, this->last_resize.height()); |
| 187 | this->field->setGeometry(button_rect); |
| 188 | } |
| 189 | |
| 190 | void WidgetSettingEnum::resizeEvent(QResizeEvent* event) { |
| 191 | this->last_resize = event->size(); |
no test coverage detected