| 267 | } |
| 268 | |
| 269 | void Preview::init() { |
| 270 | const auto background = Window::Theme::Background(); |
| 271 | const auto &paper = background->paper(); |
| 272 | _theme.setBackground({ |
| 273 | .prepared = background->prepared(), |
| 274 | .preparedForTiled = background->preparedForTiled(), |
| 275 | .gradientForFill = background->gradientForFill(), |
| 276 | .colorForFill = background->colorForFill(), |
| 277 | .colors = paper.backgroundColors(), |
| 278 | .patternOpacity = paper.patternOpacity(), |
| 279 | .gradientRotation = paper.gradientRotation(), |
| 280 | .isPattern = paper.isPattern(), |
| 281 | .tile = background->tile(), |
| 282 | }); |
| 283 | |
| 284 | _widget.paintRequest( |
| 285 | ) | rpl::on_next([=](QRect clip) { |
| 286 | auto p = Painter(&_widget); |
| 287 | paint(p, clip); |
| 288 | }, _widget.lifetime()); |
| 289 | |
| 290 | style::PaletteChanged( |
| 291 | ) | rpl::on_next([=] { |
| 292 | _bubbleCorners = {}; |
| 293 | _bubbleTail = {}; |
| 294 | _bubbleShadowBottomRight = {}; |
| 295 | update(); |
| 296 | }, _widget.lifetime()); |
| 297 | |
| 298 | if (_window) { |
| 299 | initAsWindow(); |
| 300 | updateToScale(style::kScaleMin); |
| 301 | _minOuterSize = _outer.size(); |
| 302 | updateToScale(style::MaxScaleForRatio(_ratio)); |
| 303 | _maxOuterSize = _outer.size(); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | int Preview::scaled(int value) const { |
| 308 | return style::ConvertScale(value, _scale); |
no test coverage detected