Skip to content

Commit

Permalink
Merge pull request #160 from AIIX/fix-resizing-bug-remove-autofit
Browse files Browse the repository at this point in the history
Fix text resizing issue port away from autofit label
  • Loading branch information
krisgesling committed May 12, 2021
2 parents b019412 + 96ae297 commit 2036533
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
26 changes: 16 additions & 10 deletions ui/ForecastDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,44 +14,50 @@ WeatherDelegate {
spacing: proportionalGridUnit * 10
Repeater {
id: forecastRepeater
model: sessionData.forecast.first
delegate: GridLayout {
columns: 2
rowSpacing: proportionalGridUnit * 5
columnSpacing: proportionalGridUnit * 5
Layout.fillWidth: true
Layout.fillHeight: true

LottieAnimation {
Layout.alignment: Qt.AlignCenter
Layout.preferredHeight: proportionalGridUnit * 20
Layout.preferredHeight: proportionalGridUnit * 30
Layout.preferredWidth: Layout.preferredHeight

source: Qt.resolvedUrl(getWeatherImagery(modelData.weathercode))
loops: Animation.Infinite
fillMode: Image.PreserveAspectFit
running: true
}
Mycroft.AutoFitLabel {
Label {
font.weight: Font.Bold
horizontalAlignment: Text.AlignLeft
horizontalAlignment: Text.AlignHCenter
Layout.fillWidth: true
Layout.preferredHeight: proportionalGridUnit * 15
Layout.preferredHeight: proportionalGridUnit * 30
font.pixelSize: height * 0.90
text: modelData.date
}

Mycroft.AutoFitLabel {
Label {
font.weight: Font.Bold
Layout.fillWidth: true
Layout.preferredHeight: proportionalGridUnit * 20
Layout.preferredHeight: proportionalGridUnit * 30
rightPadding: -font.pixelSize * 0.1
font.pixelSize: height * 0.90
horizontalAlignment: Text.AlignHCenter
text: modelData.max + "°"
}

Mycroft.AutoFitLabel {
Label {
font.styleName: "Thin"
Layout.fillWidth: true
Layout.preferredHeight: proportionalGridUnit * 20
Layout.preferredHeight: proportionalGridUnit * 30
rightPadding: -font.pixelSize * 0.1
text: modelData.min + "°"
font.pixelSize: height * 0.90
horizontalAlignment: Text.AlignHCenter
text: modelData.min + "°"
}
}
}
Expand Down
1 change: 1 addition & 0 deletions ui/WeatherDelegate.qml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Mycroft 1.0 as Mycroft

Mycroft.ProportionalDelegate {
id: root
skillBackgroundColorOverlay: Qt.rgba(0, 0, 0, 1)

function getWeatherImagery(weathercode) {
switch(weathercode) {
Expand Down
8 changes: 6 additions & 2 deletions ui/highlow.qml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,27 @@ import org.kde.lottie 1.0
WeatherDelegate {
id: root

Mycroft.AutoFitLabel {
Label {
id: maxTemp
font.weight: Font.Bold
Layout.fillWidth: true
Layout.preferredHeight: proportionalGridUnit * 40
font.pixelSize: parent.height * 0.50
//The off-centering to balance the ° should be proportional as well, so we use the computed pixel size
rightPadding: -font.pixelSize * 0.1
horizontalAlignment: Text.AlignHCenter
text: sessionData.max + "°"
}

Mycroft.AutoFitLabel {
Label {
id: minTemp
Layout.fillWidth: true
Layout.preferredHeight: proportionalGridUnit * 40
font.pixelSize: parent.height * 0.50
rightPadding: -font.pixelSize * 0.1
font.weight: Font.Thin
font.styleName: "Thin"
horizontalAlignment: Text.AlignHCenter
text: sessionData.min + "°"
}
}
4 changes: 3 additions & 1 deletion ui/weather.qml
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ WeatherDelegate {
}
}

Mycroft.AutoFitLabel {
Label {
id: temperature
font.weight: Font.Bold
Layout.fillWidth: true
horizontalAlignment: Text.AlignHCenter
Layout.preferredHeight: proportionalGridUnit * 40
font.pixelSize: parent.height * 0.65
rightPadding: -font.pixelSize * 0.1
text: sessionData.current + "°"
}
Expand Down

0 comments on commit 2036533

Please sign in to comment.