Skip to content

Commit

Permalink
Work around the lack of onValueModified signal in QQC 1
Browse files Browse the repository at this point in the history
SpinBox in QtQuick Controls 2 has a signal that is emitted when the
value is changed explicitly by the user. In QtQuick Controls 1, there is
no such a signal.

The most straightforward thing would be to switch to QQC2, but the
problem is that the SpinBox API in there is extremely stripped down. You
will need to re-invent the wheel to get basic functionality.

This fixes a bug where the update interval is reset to 1 unexpectedly.
  • Loading branch information
zzag committed Feb 27, 2021
1 parent 6fc3787 commit c80ef21
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/package/contents/ui/config.qml
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,20 @@ ColumnLayout {
}

QtControls.SpinBox {
property bool __initialized: false
id: updateIntervalSpinBox
Kirigami.FormData.label: i18nd("plasma_wallpaper_com.github.zzag.dynamic", "Update Every:")
maximumValue: 360
minimumValue: 1
suffix: i18ndp("plasma_wallpaper_com.github.zzag.dynamic", " minute", " minutes", value)
onValueChanged: cfg_UpdateInterval = value * 60000
Component.onCompleted: value = wallpaper.configuration.UpdateInterval / 60000
onValueChanged: {
if (__initialized)
cfg_UpdateInterval = value * 60000;
}
Component.onCompleted: {
value = cfg_UpdateInterval / 60000;
__initialized = true;
}
}
}

Expand Down

0 comments on commit c80ef21

Please sign in to comment.