- Refactor layout code with simpler logic - Use `GridLayout` to avoid too must nesting
163 lines
5.1 KiB
Plaintext
163 lines
5.1 KiB
Plaintext
export component MainWindow inherits Window {
|
|
|
|
in property <string> city: "Unknown City";
|
|
in property <string> country: "UK";
|
|
in property <string> weather_main: "Clouds";
|
|
in property <string> weather_description: "broken clouds with heavy rain";
|
|
in property <string> weather_icon: "";
|
|
in property <string> temperature: "23.1";
|
|
in property <string> unit: "C";
|
|
in property <int> popup_width: 300;
|
|
in property <int> popup_height: 124;
|
|
in property <string> default_font: "IosevkaTermSlab Nerd Font Mono";
|
|
|
|
always-on-top: true;
|
|
no-frame: true;
|
|
width: popup_width *1px;
|
|
height: popup_height *1px;
|
|
background: transparent;
|
|
default-font-family: default_font;
|
|
|
|
Rectangle {
|
|
width: 100%;
|
|
height: 100%;
|
|
border-radius: 12px;
|
|
background: @linear-gradient(160deg, #236a8bc7, #c5edff5c);
|
|
drop-shadow-blur: 15px;
|
|
drop-shadow-color: #00000066;
|
|
|
|
GridLayout {
|
|
padding: 12px;
|
|
width: 100%;
|
|
|
|
// Top row - left: Icon
|
|
Rectangle {
|
|
//background: #b95f5f;
|
|
row: 0;
|
|
col: 0;
|
|
colspan: 1;
|
|
rowspan: 3;
|
|
height: 65px;
|
|
width: 65px;
|
|
Text {
|
|
height: 100%;
|
|
width: 100%;
|
|
vertical-alignment: center;
|
|
horizontal-alignment: center;
|
|
font-size: 65px;
|
|
text: root.weather_icon;
|
|
}
|
|
}
|
|
// Top row - right: Location
|
|
Rectangle {
|
|
//background: #5fb6b9;
|
|
row: 0;
|
|
col: 1;
|
|
colspan: 4;
|
|
rowspan: 1;
|
|
height: 20px;
|
|
//width: 211px;
|
|
min-width: 0px;
|
|
Text {
|
|
height: 100%;
|
|
width: 100%;
|
|
vertical-alignment: center;
|
|
horizontal-alignment: right;
|
|
font-size: 15px;
|
|
text: root.city + "," + root.country;
|
|
}
|
|
}
|
|
// Middle row - right - middle: Temperature value
|
|
Rectangle {
|
|
//background: #895fb9;
|
|
row: 1;
|
|
col: 1;
|
|
colspan: 3;
|
|
rowspan: 2;
|
|
height: 45px;
|
|
min-width: 0px;
|
|
Text {
|
|
height: 100%;
|
|
width: 100%;
|
|
vertical-alignment: center;
|
|
horizontal-alignment: right;
|
|
font-size: 40px;
|
|
text: root.temperature;
|
|
}
|
|
}
|
|
// Middle row - right - right - top: Degree symbol
|
|
Rectangle {
|
|
//background: #7bb95f;
|
|
row: 1;
|
|
col: 4;
|
|
colspan: 1;
|
|
rowspan: 1;
|
|
height: 22.5px;
|
|
min-width: 0px;
|
|
Text {
|
|
height: 100%;
|
|
min-width: 0px;
|
|
vertical-alignment: center;
|
|
horizontal-alignment: right;
|
|
font-size: 18px;
|
|
text: "";
|
|
}
|
|
}
|
|
// Middle row - right - right - bottom: Temperature unit
|
|
Rectangle {
|
|
//background: #b95f9e;
|
|
row: 2;
|
|
col: 4;
|
|
colspan: 1;
|
|
rowspan: 1;
|
|
height: 22.5px;
|
|
min-width: 0px;
|
|
Text {
|
|
height: 100%;
|
|
min-width: 0px;
|
|
vertical-alignment: center;
|
|
horizontal-alignment: right;
|
|
font-size: 18px;
|
|
text: root.unit;
|
|
}
|
|
}
|
|
// Bottom row - left: Weather condition
|
|
Rectangle {
|
|
//background: #5fb98f;
|
|
row: 3;
|
|
col: 0;
|
|
colspan: 3;
|
|
rowspan: 1;
|
|
height: 35px;
|
|
width: 135px;
|
|
Text {
|
|
height: 100%;
|
|
width: 100%;
|
|
vertical-alignment: center;
|
|
horizontal-alignment: left;
|
|
font-size: 21px;
|
|
text: root.weather_main;
|
|
}
|
|
}
|
|
// Bottom row - right: Weather description
|
|
Rectangle {
|
|
//background: #b7b95f;
|
|
row: 3;
|
|
col: 3;
|
|
colspan: 2;
|
|
rowspan: 1;
|
|
height: 35px;
|
|
width: 141px;
|
|
Text {
|
|
height: 100%;
|
|
width: 100%;
|
|
vertical-alignment: top;
|
|
horizontal-alignment: right;
|
|
font-size: 13.5px;
|
|
wrap: word-wrap;
|
|
text: root.weather_description;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |