blackadderkate / weather-widget-2

Updated version of Weather Widget by Kotelnik
GNU General Public License v2.0
107 stars 23 forks source link

Create a Legacy version for older QT releases #70

Open blackadderkate opened 2 years ago

blackadderkate commented 2 years ago

Create a version of the Widget that works on older QT / Plasma versions, such as Kubuntu 18.04 LTS.

Issues:

blackadderkate commented 2 years ago

Created a Branch for this issue: legacy-version-for-older-qt-releases

Please make sure you use this branch for pulling code or testing on older versions.

blackadderkate commented 2 years ago

I am struggling with finding an alternative for the onActionChosen routine. What that routine does is validate whether the user has filled in all the necessary fields when they click the OK button. If they have not, it will tell them what is wrong, and won't close the Dialog.

There doesn't seem to be any way of replicating this behaviour with earlier QML versions. There seems to be no way of preventing a dialog being closed when the Cancel or OK button is clicked. There also doesn't seem to be a way of disabling the OK button until they enter valid data in all the fields.

The only workaround I have seen suggested is to remove the Standard OK and Cancel buttons, and replace them with my own Buttons - but that means I lose all the automatic language translations, which is annoying.

jochen-01 commented 2 years ago

Tried it but have problems to install from file. What I did:

blackadderkate commented 2 years ago

Tried it but have problems to install from file. What I did:

* downloaded weather-widget-2.1.8.plasmoid

* right klick on the desktop

* selected "add widget"

* fetch new widget

* install from local file

* selected previously downloaded weather-widget-2.1.8.plasmoid

* ready
  But nothing happened. Is sure my fault but what did I wrong?

Difficult to say without more information. Please can you try the following:

1) check whether the Widget installed correctly:

2) If the folder exists, and the version number is correct (2.1.8), try the following:

3) If that works OK, check whether you can install the plasmoid on the Desktop or in the Panel.

Please let me know how you get on...

jochen-01 commented 2 years ago

Thank you for the step-by-step instructions. Manual installation of plasmoids is out of my experience (so far).

Removed org.kde.weatherWidget-2 which contained the installation of 2.2.2

Did plasmapkg2 -i weather-widget-2.1.8.plasmoid to be sure that the downloaded plasmoid has been installed. Ended with success. plasmoidviewer -a . in ~/.local/share/plasma/plasmoids/org.kde.weatherWidget-2 ended with an error window: "Fehler beim Laden der QML-Datei: file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/main.qml:24:1: Script file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js unavailable file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js:200:5: Expected token `}'"

Translated: Error loading QML file: file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/main.qml:24:1: Script file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js unavailable file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js:200:5: Expected token `}'

user name replaced with xxxx for privacy reasons. Same error message as with 2.2.2, Update (plasmapkg2 -u) has the same result. I hope the error message helps to find the problem. Btw: /home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js exists.

blackadderkate commented 2 years ago

I've had a quick look at that file, and I can't see anything obviously wrong. Unfortunately I am going out this evening, so I will have to try and fix the problem tomorrow...

jochen-01 commented 2 years ago

There's no hurry. Meanwhile, if I want to know what the weather is like, I just look out the window. ;-)

blackadderkate commented 2 years ago

OK, I've tried changing a couple of things in the code to see if I can figure out what the problem is... Please can you download this following patch, and apply it as follows:

and let me know whether that works or not.

Thanks...

jochen-01 commented 2 years ago

After applying your patch: patch icons.js /tmp/iconspatch.txt patching file icons.js

(no error message)

And: cd ../.. ...weatherWidget-2 > plasmoidviewer -a . I get the error: "Fehler beim Laden der QML-Datei: file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/main.qml:24:1: Script file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js unavailable file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js:3:9: Expected token ;'" Translated: "Error loading QML file: file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/main.qml:24:1: Script file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js unavailable file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/code/icons.js:3:9: Expected token ;'"

blackadderkate commented 2 years ago

OK, please remove the old patch as follows:

Download this patch instead and apply it.

and please let met know what happens.

jochen-01 commented 2 years ago

With this I got: "Fehler beim Laden der QML-Datei: file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/main.qml:103:28: Type FullRepresentation unavailable file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/FullRepresentation.qml:84:5: Type Meteogram unavailable file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/Meteogram.qml:18:1: module "QtQuick.Window" version 2.5 is not installed" Translation as before: "Error loading QML file..."

I have to admit that I did not have the old patch any longer. Thus it was impossible to revert the patch iconspatch.txt. To get the unpatched version I fetched icons.js from the development branch. Just to be sure that we are taking about the same file here the md5 checksums: d230b5c14dee5c8af70df8a811675c63 icons.js (unpatched from 2.1.8) 654d6c605f5f7a6d4f498ce2a230c870 icons.js (patched with iconspatch2.txt)

If the files are different please provide the patched icons.js, I know how to replace it. Sorry for the hassle.

blackadderkate commented 2 years ago

You downloaded the correct file (I got the same MD5 sum) and the fact that the error is now different proves that the patch applied successfully. So we are making progress!

To get rid of the new error, can you please open /home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/Meteogram.qml in your favourite text editor (I use KATE), and change lines 18 and 19 to:

import QtQuick.Window 2.2
import QtQml.Models 2.2

and try running the applet again?

Thanks.

jochen-01 commented 2 years ago

Not enough progress. ;-)

Error message: "Error loading QML-Datei: file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/main.qml:115:5: Type MetNo unavailable file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:203:15: Expected token ;' file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:204:15: Expected token;' file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:205:15: Expected token ;' file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:213:15: Expected token;' file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:214:15: Expected token ;' file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:215:19: Expected token;' file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:215:44: Expected token )' file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:215:49: Expected token,' "

diff Meteogram.qml Meteogram.qml-20220309
18,21c18,19
< /* import QtQuick.Window 2.5 */
< /* import QtQml.Models 2.5 */
< import QtQuick.Window 2.2
< import QtQml.Models 2.2
---
> import QtQuick.Window 2.5
> import QtQml.Models 2.5
blackadderkate commented 2 years ago

Thanks for your patience...

I have a theory that the version of KDE/Qt you are running has stricter "rules" on some things than my version does - such as needing spaces around mathematical operators (= + - * /), which is why you are getting so many errors.

Just to test my theory, can you please try the following:

Download this latest patch Then in Konsole:

And please let me know if it makes any difference. If I'm right, I will be able to find most of the bugs without needing you to test every single time I make a change.

jochen-01 commented 2 years ago

Your patch file did not fit to the unpached local file. I reworked the rejected patches by hand (from MetNo.qml.rej). I hope I did not skip a line of .rej... Errors are now:


file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:203:15: Expected token `;'
file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:204:15: Expected token `;'
file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:205:15: Expected token `;'
file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:213:15: Expected token `;'
file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:214:15: Expected token `;'
file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:215:19: Expected token `;'
file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:215:47: Expected token `)'
file:///home/xxxx/.local/share/plasma/plasmoids/org.kde.weatherWidget-2/contents/ui/providers/MetNo.qml:215:52: Expected token `,'
blackadderkate commented 2 years ago

Those errors are the same as before - so the problem wasn't what I thought it was.

I have just downloaded version 5.9.9 of Qt (which is very similar to the version of Qt used in Kubuntu 18.04LTS) and done some testing with the "qmllint" tool, and it looks as though the let command is not supported on your version of Qt.

I need to run qmllint on ALL the files in the project (in case there are other differences that will need to be fixed) - which might take me a while.

When I'm done I'll upload a new plasmoid file on here for you to test, and let you know...

jochen-01 commented 2 years ago

Thanks a lot for your effort. I'd wish that I would be able to code in java script. That might make it easier to help you. If it was COBOL, I probably may be able to help. ;-)

blackadderkate commented 2 years ago

I did COBOL at University back in the 80s - I've forgotten pretty much everything about it now though, although I seem to remember everything was written in uppercase...

As for the widget, I've done some more hacking - please try this release.

Download the plasmoid file, and install in konsole using plasmapkg2 -u /tmp/weather-widget-2.1.8.1.plasmoid Then test using plasmoidviewer as before:

jochen-01 commented 2 years ago

Release 2.1.8.1 works! Thank you. Minor issue: Manual input of geo location does not work correctly. I tried to enter location from yr.no: Lat 28.08504, Lon -17.33385, Alt 15 Seems not to accept decimal point values. Managed to get the place by manually editin URL to lat=28.08504&lon=-17.33385&altitude=15 It's really a minor issue, anyway. screenshot_20220311-095240

blackadderkate commented 2 years ago

Excellent news! Now the testing really starts!

1) If you click the Help button the widget will tell you why you those values can't be saved.

One possibility is that I set the latitude and longitude input boxes to four decimal places.

Does it work if you put in less precise numbers - for example 28.085 & - 17.334? And did you remember to put in something in the location input box?

2) If you could test the Search facility, it would also be really helpful - does it detect your country properly? Does it load the database correctly? Does the filter work? Does it transfer the data if you select a location and click OK?

3) Is everything translated properly? Is all the text displayed correctly, or is some of it clipped?

4) Can you please check all the Configuration pages and settings work? Does the widget update if you change the temperature units to Fahrenheit or Kelvin? And do the meteogram units change?

If everything works the way it is supposed to, I'll be able to release it to the KDE store over the weekend...

jochen-01 commented 2 years ago
  1. Error messages: "There are 2 errors! The Longitude is not numeric. The Place Name is empty."

Both errors are wrong. Longitude is negative, what is absolutely possible (western of Greenwich). The place name is "Valle Gran Rey, 15m"; absolutely correct and a lovely place, by the way. :-) I assume that decimal separation is dot not comma. Eg. "28.08504" not "28,08504"

  1. Country is detected properly (drop down left of the input field).
  2. Text is not clipped anywhere. Text is displayed in English while locale is German. Not a problem but I think you expect it translated to the locale?
  3. Switching temperatur unit does not work. It remains °C even if I switch to fahrenheit. Same for the other units. All units correspondents to those of locale. Unit settings are saved in preferences, i.e. it shows the settings I selected the previous time. Widget is not updated when settings are saved.

A bit work has to be done prior to release. ;-)

blackadderkate commented 2 years ago

Thanks for the prompt reply.

1) I will investigate this over the weekend. 2) Good news! 3) The database itself is English, but the GUI itself should be in German. I'll have to investigate this as well. 4) I don't think Configuration changes work properly in plasmoidviewer. Try actually adding the widget into the panel (or onto the desktop) and test it there (if you tend to Sleep or Hibernate your computer, you might need to logoff and back in again to force KDE to reload the widget).

jochen-01 commented 2 years ago
  1. Forgot to mention: I installed the plasmoid as normal prior to test it. I did the test of configuration changes from within the installed widget (installed in a contol bar "Kontrollleiste").
blackadderkate commented 2 years ago
  1. I am very stupid. I used an IntValidator - which as its name implies validates Integers. I should have used a DoubleValidator for Floating Point numbers. This is an easy fix...

3. I have installed German locale on my laptop using a "test" login, and the German translation works for me - see this screenshot: Screenshot_20220311_175907_small

I'm not entirely sure what is going on there - I shall try some Google searches and see what I can find out.

Just out of curiosity, does the following work if you try the following in Konsole:

As this works fine on my machine...

  1. The Config changes aren't working properly for me either - the Appearance page works, but not the Unit page, which is odd. I shall investigate...
blackadderkate commented 2 years ago

I have made major changes to the Latitude, Longitude, Altitude and Placename validation code:

Please download weather-widget-2.1.8.2.plasmoid and update as before using plasmapkg -u .

jochen-01 commented 2 years ago

Ok...

  1. Just an error, it happens during development.
  2. locale: That has been my error. I did not make sure that the fresh installed plasmoid got refreshed. It works now.
  3. Here I have to know what is your intention. I assume, it should be possible to enter latitude, longitude, altitude to define a location OR enter an URL from which the 3 values are filled? If I decide to enter the 3 values url shall be built from these values. Right? What happens is: Entering latitude and logitude shows these values in red as these values are wrong. They don't be wrong, I took them from yr.no, they miss validation. Altitude is shown black. The consequence is that URL is just built from Altitude. I give an example: Latitude: 28.18842 (red), Longitude: -17.19532 (red), Altitude: 198 (black). URL shows only "altitude=198".

See screen shot where I filled only the top line and location name. screenshot_20220312-011118

Changing configuration (units) works now.

blackadderkate commented 2 years ago
  1. Fixed this now...

  2. Phew - I couldn't find anything on Google, so I was getting a bit worried!

  3. It was flagging your input as invalid because you are in a German locale, so you will need to change the decimal points in the Latitude and Longitude to commas... Please download this new version and give it a try. This version will automatically convert the commas into decimal points when it builds the URL (see below): image

  4. The way QML handles configuration variables is weird - but I think I know what I did wrong, and have removed the faulty code...

Thanks again for your help - I literally couldn't have done this without you...

jochen-01 commented 2 years ago
  1. My fault. sorry for making you so much unnecessary work.
  2. Sure. I should have known that. Conversion from location fields to url works.

Thank you for your awesome work.

A suggestion for future versions: There is a button (clickable field) "next location" in the upper right corner. What about the same for "previous location" in the upper left corner? It would help people with many configured locations.

blackadderkate commented 2 years ago

Glad the widget is now working for you. Please give it a thorough test, and let me know if you find any other bugs - I will leave this bug open for a few more days for you to do this.

I have created a new issue for the Previous Location suggestion.

jochen-01 commented 2 years ago

I'll continue testing. Thank you.

jochen-01 commented 2 years ago

Do you plan to release the "previous location" enhancement also for the legacy version? I can find only 2.1.8 from about 9 days ago.

blackadderkate commented 2 years ago

Do you plan to release the "previous location" enhancement also for the legacy version? I can find only 2.1.8 from about 9 days ago.

Yes I do.

It is not easy to juggle bug-fixes and new-releases on two different releases - I got a lot of bug reports from version 2.2.4 and I only have one pair of hands! When I have got the bugs out of version 2.2.4 I will add this feature to version 2.1.8. It shouldn't be too complicated...

jochen-01 commented 2 years ago

No stress! Step by step, it works so far. The rest is elegancy. ;-)

ls-1N commented 1 year ago

Kubuntu 18.04 is now officially unsupported, so I think supporting that shouldn't be expected of you either. :slightly_smiling_face:

jochen-01 commented 1 year ago

Thank you. The time I raised this issue (Mar 4, 2022), Ubuntu 18.04 has been supported. ;-) Meanwhile I moved 2 computers to Ubuntu 22.04 and 2 computers to Debian testing. On all 4 your weather-widget-2 works.

Issue can be closed now. :-)