1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
2 | // SPDX-License-Identifier: MIT |
3 | |
4 | import { LineEdit, HorizontalBox } from "std-widgets.slint" ; |
5 | |
6 | component TempConv inherits Window { |
7 | preferred-height: 64px; |
8 | layout := HorizontalBox { |
9 | c := LineEdit { |
10 | text: "0" ; |
11 | edited(text) => { |
12 | if (self.text.is-float()) { |
13 | f.text = (self.text.to-float() * 9 / 5) + 32; |
14 | } |
15 | } |
16 | } |
17 | Text { |
18 | text: "°Celsius = " ; |
19 | vertical-alignment: center; |
20 | } |
21 | f := LineEdit { |
22 | text: "32" ; |
23 | edited(text) => { |
24 | if (self.text.is-float()) { |
25 | c.text = (self.text.to-float() - 32) * (5 / 9); |
26 | } |
27 | } |
28 | } |
29 | Text { |
30 | text: "°Fahrenheit" ; |
31 | vertical-alignment: center; |
32 | } |
33 | } |
34 | } |
35 | |