Changeset View
Changeset View
Standalone View
Standalone View
applets/weather/package/contents/ui/main.qml
Context not available. | |||||
25 | Item { | 25 | Item { | ||
---|---|---|---|---|---|
26 | id: root | 26 | id: root | ||
27 | 27 | | |||
28 | readonly property string weatherSource: plasmoid.nativeInterface.source | 28 | // readonly property string weatherSource: 'bbcukmet|weather|City of London, Greater London|2643741' | ||
29 | readonly property int updateInterval: plasmoid.nativeInterface.updateInterval | 29 | // readonly property string weatherSource: 'envcan|weather|Toronto, ON' | ||
30 | readonly property int displayTemperatureUnit: plasmoid.nativeInterface.displayTemperatureUnit | 30 | // readonly property string weatherSource: 'noaa|weather|New York City, Central Park, NY' | ||
31 | readonly property int displaySpeedUnit: plasmoid.nativeInterface.displaySpeedUnit | 31 | // readonly property string weatherSource: 'wettercom|weather|London, London, GB|GB0KI0101;London' | ||
32 | readonly property int displayPressureUnit: plasmoid.nativeInterface.displayPressureUnit | 32 | | ||
33 | readonly property int displayVisibilityUnit: plasmoid.nativeInterface.displayVisibilityUnit | 33 | readonly property string weatherSource: plasmoid.configuration.source | ||
34 | readonly property int updateInterval: plasmoid.configuration.updateInterval | ||||
35 | DisplayUnits { id: displayUnits } | ||||
36 | readonly property alias displayTemperatureUnit: displayUnits.temperatureUnitId | ||||
37 | readonly property alias displaySpeedUnit: displayUnits.speedUnitId | ||||
38 | readonly property alias displayPressureUnit: displayUnits.pressureUnitId | ||||
39 | readonly property alias displayVisibilityUnit: displayUnits.visibilityUnitId | ||||
34 | 40 | | |||
35 | property bool connectingToSource: false | 41 | property bool connectingToSource: false | ||
36 | readonly property bool needsConfiguration: !generalModel.location && !connectingToSource | 42 | readonly property bool needsConfiguration: !generalModel.location && !connectingToSource | ||
Context not available. | |||||
393 | return ""; | 399 | return ""; | ||
394 | } | 400 | } | ||
395 | var tooltips = []; | 401 | var tooltips = []; | ||
396 | var temperature = plasmoid.nativeInterface.temperatureShownInTooltip ? observationModel.temperature : null; | 402 | var temperature = plasmoid.configuration.temperatureShownInTooltip ? observationModel.temperature : null; | ||
397 | if (observationModel.conditions && temperature) { | 403 | if (observationModel.conditions && temperature) { | ||
398 | tooltips.push(i18nc("weather condition + temperature", | 404 | tooltips.push(i18nc("weather condition + temperature", | ||
399 | "%1 %2", observationModel.conditions, temperature)); | 405 | "%1 %2", observationModel.conditions, temperature)); | ||
400 | } else if (observationModel.conditions || temperature) { | 406 | } else if (observationModel.conditions || temperature) { | ||
401 | tooltips.push(observationModel.conditions || temperature); | 407 | tooltips.push(observationModel.conditions || temperature); | ||
402 | } | 408 | } | ||
403 | if (plasmoid.nativeInterface.windShownInTooltip && observationModel.windSpeed) { | 409 | if (plasmoid.configuration.windShownInTooltip && observationModel.windSpeed) { | ||
404 | if (observationModel.windDirection) { | 410 | if (observationModel.windDirection) { | ||
405 | if (observationModel.windGust) { | 411 | if (observationModel.windGust) { | ||
406 | tooltips.push(i18nc("winddirection windspeed (windgust)", "%1 %2 (%3)", | 412 | tooltips.push(i18nc("winddirection windspeed (windgust)", "%1 %2 (%3)", | ||
Context not available. | |||||
413 | tooltips.push(observationModel.windSpeed); | 419 | tooltips.push(observationModel.windSpeed); | ||
414 | } | 420 | } | ||
415 | } | 421 | } | ||
416 | if (plasmoid.nativeInterface.pressureShownInTooltip && observationModel.pressure) { | 422 | if (plasmoid.configuration.pressureShownInTooltip && observationModel.pressure) { | ||
417 | if (observationModel.pressureTendency) { | 423 | if (observationModel.pressureTendency) { | ||
418 | tooltips.push(i18nc("pressure (tendency)", "%1 (%2)", | 424 | tooltips.push(i18nc("pressure (tendency)", "%1 (%2)", | ||
419 | observationModel.pressure, observationModel.pressureTendency)); | 425 | observationModel.pressure, observationModel.pressureTendency)); | ||
Context not available. | |||||
421 | tooltips.push(observationModel.pressure); | 427 | tooltips.push(observationModel.pressure); | ||
422 | } | 428 | } | ||
423 | } | 429 | } | ||
424 | if (plasmoid.nativeInterface.humidityShownInTooltip && observationModel.humidity) { | 430 | if (plasmoid.configuration.humidityShownInTooltip && observationModel.humidity) { | ||
425 | tooltips.push(i18n("Humidity: %1", observationModel.humidity)); | 431 | tooltips.push(i18n("Humidity: %1", observationModel.humidity)); | ||
426 | } | 432 | } | ||
427 | 433 | | |||
Context not available. | |||||
439 | observationModel: root.observationModel | 445 | observationModel: root.observationModel | ||
440 | } | 446 | } | ||
441 | 447 | | |||
448 | function migrateKey(nativeKey, configKey) { | ||||
449 | plasmoid.configuration[configKey] = plasmoid.nativeInterface[nativeKey] | ||||
450 | console.log('[weather] migrated', configKey, plasmoid.configuration[configKey], '(nativeInterface: ', plasmoid.nativeInterface[nativeKey], ')'); | ||||
451 | } | ||||
452 | function migrateFromNativeInterface() { | ||||
453 | migrateKey('source', 'source') | ||||
454 | migrateKey('updateInterval', 'updateInterval') | ||||
455 | migrateKey('displayTemperatureUnit', 'temperatureUnitId') | ||||
456 | migrateKey('displaySpeedUnit', 'speedUnitId') | ||||
457 | migrateKey('displayPressureUnit', 'pressureUnitId') | ||||
458 | migrateKey('displayVisibilityUnit', 'visibilityUnitId') | ||||
459 | migrateKey('temperatureShownInTooltip', 'showTemperatureInTooltip') | ||||
460 | migrateKey('windShownInTooltip', 'showWindInTooltip') | ||||
461 | migrateKey('pressureShownInTooltip', 'showPressureInTooltip') | ||||
462 | migrateKey('humidityShownInTooltip', 'showHumidityInTooltip') | ||||
463 | migrateKey('temperatureShownInCompactMode', 'showTemperatureInCompactMode') | ||||
464 | | ||||
465 | var config = plasmoid.nativeInterface.configValues(); | ||||
466 | plasmoid.configuration.services = config.services; | ||||
467 | console.log('[weather] migrated', 'services', plasmoid.configuration.services, '(nativeInterface: ', config.services, ')'); | ||||
468 | | ||||
469 | // Migration finished | ||||
470 | plasmoid.nativeInterface.source = "" | ||||
471 | } | ||||
472 | | ||||
442 | Component.onCompleted: { | 473 | Component.onCompleted: { | ||
474 | // Migrate 5.15 and below => 5.16 and above | ||||
475 | // TODO: Remove migration code after Plasma 5.19 (version after next Plasma LTS) | ||||
476 | if (plasmoid.nativeInterface && plasmoid.nativeInterface.source) { | ||||
477 | migrateFromNativeInterface() | ||||
478 | } | ||||
479 | | ||||
443 | // workaround for missing note about being in systray or similar (kde bug #388995) | 480 | // workaround for missing note about being in systray or similar (kde bug #388995) | ||
444 | // guess from cointainer structure data and make available to config page | 481 | // guess from cointainer structure data and make available to config page | ||
445 | plasmoid.nativeInterface.needsToBeSquare = | 482 | plasmoid.configuration.needsToBeSquare = | ||
446 | (plasmoid.parent !== null && | 483 | (plasmoid.parent !== null && | ||
447 | ((plasmoid.parent.pluginName === 'org.kde.plasma.private.systemtray' || | 484 | ((plasmoid.parent.pluginName === 'org.kde.plasma.private.systemtray' || | ||
448 | plasmoid.parent.objectName === 'taskItemContainer'))); | 485 | plasmoid.parent.objectName === 'taskItemContainer'))); | ||
Context not available. |