Unsplash POTD: filter out banner image and pick random photo from latest
ClosedPublic

Authored by guoyunhe on Jul 14 2019, 8:04 AM.

Details

Summary

Have been using this Unsplash POTD for several days and found the wallpaper doesn't change by day.

Then I found two problem in the code:

  1. The HTML page contains a banner image, which almost never change. It is fetched first with previous regular expression.
  2. The photos on the page doesn't update everyday. Sometimes they update a bunch of photos at one time.

So I changed it to global match and pick a random one from latest photos. Looks more like picture of the day.

Diff Detail

Repository
R114 Plasma Addons
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
guoyunhe created this revision.Jul 14 2019, 8:04 AM
Restricted Application added a project: Plasma. · View Herald TranscriptJul 14 2019, 8:04 AM
Restricted Application added a subscriber: plasma-devel. · View Herald Transcript
guoyunhe requested review of this revision.Jul 14 2019, 8:04 AM
guoyunhe edited the summary of this revision. (Show Details)Jul 14 2019, 8:08 AM
guoyunhe added a reviewer: Plasma.
guoyunhe updated this revision to Diff 61727.EditedJul 14 2019, 8:14 AM

Enable smoothing for POTD wallpaper

Since most of POTD are photos, enable smooth can improve the render quality.

Instead of smooth: true doing this may achieve the same result with less memory usage:

sourceSize.width: parent.width
sourceSize.height: parent.height

Instead of smooth: true doing this may achieve the same result with less memory usage:

sourceSize.width: parent.width
sourceSize.height: parent.height

I tried it but got black screen...

QImageItem {
    anchors.fill: parent
    image: engine.data[provider]["Image"]
    fillMode: wallpaper.configuration.FillMode
    // Render image smoothly
    sourceSize.width: parent.width
    sourceSize.height: parent.height
}

Ah right, that's a property of Image, not QImageItem.

https://doc.qt.io/qt-5/qml-qtquick-image.html#sourceSize-prop

Can you use Image instead?

Ah right, that's a property of Image, not QImageItem.

https://doc.qt.io/qt-5/qml-qtquick-image.html#sourceSize-prop

Can you use Image instead?

I got a blocker: engine.data[provider]["Image"] is QImage not string. So I cannot assign it as source of Image. I don't know if it is possible.

ngraham accepted this revision.Jul 14 2019, 12:40 PM

All right, let's not poke the bear too much then. :)

This revision is now accepted and ready to land.Jul 14 2019, 12:40 PM
This revision was automatically updated to reflect the committed changes.