Skip to content

Friday, 9 December 2022

Qt 6 introduced a new way to access platform specific objects and functionality in the QNativeInterface namespace. Starting with Qt 6.5 it will be possible to obtain handles to wayland object handles this way. Let’s look at what’s new and how it improves on the past method.

In Qt 5 there were to two options to access platform-specific API and native handles of the current platform. If you were lucky, your platform had an ‘Extras’ module like Qt Max Extras, Qt X11 Extras or Qt Android Extras. However these were removed for Qt 6 and if you ever needed something that was not exposed this way or the platform had no ‘Extras’ module (like Wayland), it was also possible to access functionality via QPlatformNativeInterface. An example usage of would look like this:

QPlatformNativeInterface *nativeInterface = QGuiApplication::platformNativeInterface();
if (!nativeInterface) {
    return;
}
auto seat = static_cast<wl_seat*>(nativeInterface->nativeResourceForIntegration("wl_seat"));
auto surface = static_cast<wl_surface*>(nativeInterface->nativeResourceForWindow("surface", window));
if (!seat || !surface) {
    return;
}
// do something with seat and surface

The snippet shows multiple problems of this API. One is that it is not type safe, the nativeResourceFor... functions return void*. I could easily have forgotten to change the type in the second cast with further implications down the line. The second problem is that it is not obvious at all what is available, no header file will tell you. One has to either already know or read the implementation. Additionally any typo in the string will break the functionality.

Qt 6 solves this with the interfaces in the QNativeInterface namespace. They provide type safe access to the platform specific parts. Using the new interfaces for Wayland in Qt 6.5 we can rewrite the above:

auto waylandApp = qGuiApp->nativeInterface<QNativeInterface::QWaylandApplication>();
auto waylandWindow = window->nativeInterface<QNativeInterface::Private::QWaylandWindow>();
if (!waylandApp || !waylandWindow) {
    return;
}
auto seat = waylandApp->seat();
auto surface = waylandWindow->surface();
if (!seat || !surface) {
    return;
}
// do something with seat and surface

Much nicer. The nativeInterface functions check that the interface is available on the object and from there on usage is straightforward. It’s obvious what’s available by looking at the header or the documentation. For example through QWaylandApplication it’s possible to access the wayland objects that Qt is using internally as well as the input serial of the last user action which is sometimes required to pass in other wayland protocols.

The astute reader might have noticed that in the snippet QWaylandWindow is in the nested QNativeInterface::Private namespace for now. The interface chosen here is being evaluated and a bit experimental (due to the need of signalling surface creation and destruction, it’s the first native interface inheriting from QObject!) and as I wanted to get this into Qt 6.5 I followed the precedent of QWindow native interfaces of the other platforms also being private for now. QWaylandOutput also resides next to its cousins in QNativeInterface::Private. Still I hope they don’t need to stay too long there and can be made public soon.

Let’s go for my web review for the week 2022-49.


I Taught ChatGPT to Invent a Language - by Dylan Black

Tags: tech, ai, machine-learning, gpt, linguistics

Hard not to have at least some ChatGPT related news this week. Plenty of impressive experiments out there… I think this one is hands down the most impressive one. I’m biased though, I like linguistics inspired works.

https://maximumeffort.substack.com/p/i-taught-chatgpt-to-invent-a-language


ChatGPT and the viability of replacing humans with circus tricks

Tags: tech, programming, ai, machine-learning, gpt

Words of caution regarding the use of language models for producing code. This can derail fairly quickly and earlier than you’d expect… without noticing it.

https://adamshaylor.svbtle.com/chatgpt-and-the-viability-of-replacing-humans


Twitter Thrills Far-Right Trolls by Silencing Left-Wing Voices

Tags: tech, twitter, social-media, politics

This is really going down the drain. Right wings extremists basically took over the content moderation vacuum. I wonder how long before this turns into simply into an extremist echo chamber with no real user on it.

https://theintercept.com/2022/11/29/elon-musk-twitter-andy-ngo-antifascist/


Samsung’s Android app-signing key has leaked, is being used to sign malware | Ars Technica

Tags: tech, android, security

This shows really bad practices… and lack of transparency, worrying for users.

https://arstechnica.com/gadgets/2022/12/samsungs-android-app-signing-key-has-leaked-is-being-used-to-sign-malware/


The architecture of Mastodon

Tags: tech, fediverse, architecture

Nice explanation of the Mastodon architecture, how it propagates messages and interactions or how it scales.

https://softwaremill.com/the-architecture-of-mastodon/


Blockbench

Tags: tech, 3d

That looks like a nice even though a bit niche 3D model editor. I like this kind of style.

https://www.blockbench.net/


GitHub - datafold/data-diff: Efficiently diff data in or across relational databases

Tags: tech, tests, databases

Looks like an interesting tool when you need to diff databases. Definitely something I’d see myself using for large pin tests.

https://github.com/datafold/data-diff


Structured concurrency in Java with Loom

Tags: tech, java, multithreading

Interesting new concurrency model in Java. Probably a good inspiration in other situations.

https://www.davidvlijmincx.com/posts/loom/java_structured_concurrency/


The Git Parable

Tags: tech, git

An old piece, I sometimes like to revisit the basics so here it goes. A nice explanation of how Git is built and how it works internally. It’s of course a simplification in some way but close enough to have a good mental model of what goes on behind the commands we use.

https://tom.preston-werner.com/2009/05/19/the-git-parable.html


A debugging manifesto

Tags: tech, debugging

Excellent piece about the right attitude to have around debugging.

https://jvns.ca/blog/2022/12/08/a-debugging-manifesto/


What I learned from pairing by default

Tags: tech, pairing, programming

Good balanced view about pair programming. I’d definitely like to practice it more, although whole days might be a bit too much and too exhausting.

https://blog.testdouble.com/posts/2022-12-07-what-i-learned-from-pairing/


37 Years Ago, Steve Jobs Said the Best Managers Never Actually Want to Be Managers. Science Says He Was Right | Inc.com

Tags: tech, management

I’m not a huge fan of the “Steve Jobs said…” to justify thing, a clear rhetoric trick. Still, I think this short piece nails it down, it’s just better when managers actually know the job. It’s better to promote someone who knows it and coach that person into the job. There’s only one challenge then (which is glanced over in the paper): how to keep this manager technically relevant over time. It’s not that easy in our field.

https://www.inc.com/jeff-haden/37-years-ago-steve-jobs-said-best-managers-never-want-to-be-a-manager-science-says-he-was-right.html


The Most Brutal Ant: The Slaver Ant Polyergus - YouTube

Tags: science, ants, surprising

No really… ants are scary!

https://www.youtube.com/watch?app=desktop&v=Qsbe1pD8ocE



Bye for now!

As you may know KDE consists of many different subprojects, where some projects depend on other projects. Most KDE projects depend on some KDE Frameworks, but other dependencies are also possible, e.g. plasma-desktop depends on plasma-workspace. To be able to automate building projects (for the CI system or tools like kdesrc-build) you need a machine-readable source of dependency information.

For a long time this information has been available in a set of files in repo-metadata. To declare for example plasma-desktop’s dependency on plasma-workspace one would write the line

kde/workspace/plasma-desktop: kde/workspace/plasma-workspace

to the relevant file.

Since most projects depend on a lot of KDE Frameworks, and specifying each of the frameworks manually is somewhat cumbersome, a virtual frameworks/kf5umbrella project that depends on all frameworks was introduced. By default all projects depend on this helper project. This metadata was used both by the Jenkins-based build.kde.org CI and kdesrc-build.

The approach worked well enough, but had some drawbacks. First of all most projects don’t actually depend on all frameworks, so kdesrc-build would build projects that you don’t actually need, which is wasteful. Second, the format had no way for platform-specific adjustments, like defining that X depends on Y on Linux but not Windows. This was especially problematic for our Android builds, where it would try to build projects that don’t actually support Android or weren’t needed but increasing the size of the final APK. This problem was solved by moving our Android builds to use Craft, which maintains its own dependency metadata.

Because of these shortcomings when we replaced our Jenkins-based CI with Gitlab CI sysadmins came up with a new way of defining dependencies for each project. Instead of a single, global file with all information each project now has a .kde-ci.yml file in its repository that defines the dependencies. There is no equivalent of the kf5umbrella any more, which forces projects to explicitly list all of their frameworks dependencies. The new format also allows to define platform-specific dependency information. For example Neochat’s .kde-ci.yml looks like this:

Dependencies:
- 'on': ['@all']
  'require':
    'frameworks/extra-cmake-modules': '@stable'
    'frameworks/kcoreaddons': '@stable'
    'frameworks/kirigami': '@stable'
    'frameworks/ki18n': '@stable'
    'frameworks/kconfig': '@stable'
    'frameworks/syntax-highlighting': '@stable'
    'frameworks/kitemmodels': '@stable'
    'frameworks/knotifications': '@stable'
    'libraries/kquickimageeditor': '@stable'
    'frameworks/sonnet': '@stable'
    'libraries/kirigami-addons': '@latest'
    'third-party/libquotient': '@latest'
    'third-party/qtkeychain': '@latest'
    'third-party/cmark': '@latest'

- 'on': ['Windows', 'Linux', 'FreeBSD']
  'require':
    'frameworks/qqc2-desktop-style': '@stable'
    'frameworks/kio': '@stable'
    'frameworks/kwindowsystem': '@stable'
    'frameworks/kconfigwidgets': '@stable'

- 'on': ['Linux', 'FreeBSD']
  'require':
    'frameworks/kdbusaddons': '@stable'

However, kdesrc-build still uses the old dependency infomation. As it is natural for two instances of the same information, they eventually got out of sync and the metadata used by kdesrc-build got more and more incorrect. Something had to be done. Due to its architecture it isn’t really feasible for kdesrc-build to directly read the .kde-ci.yml files since that would require cloning the repos to read the data. Instead we opted to generate the old-style dependency data from the .kde-ci.yml files. In an attempt to learn Rust I wrote a tool that does this and committed the initial result. In the spirit of the recently announced Automation Goal this ought to be automated fully, but that’s for another day.

Any missing information in the generated data should be fixed by adding it to the relevant .kde-ci.yml file. If you find any other issues with the generated data please let me know.

To support more KDE-wide building-block initiatives like this KDE is hiring a Software Platform Engineer. Hiring people is enabled through your donations to KDE. Check out our End of Year Fundraiser that will enable more of this work to happen.

Happy kdesrc-building!

I am happy to share that this year we were able to host the KDE booth at the 19th annual Southern California Linux Expo-SCaLE 19X  that took place on July 28-31, 2022 at the Hilton Los Angeles Airport in LA, California.

SCaLE covers visitors from all over the United States and around the world. It is the largest, community-run, open-source, and free software conference in North America.

We collaborated with OpenSUSE, LOPSA and NextCloud with the vision to promote cross community growth and to provide outreach and knowledge regarding our communities. 

Our booth was appreciated for a lot of things but the main attraction was the banner, attendees loved finding the logos of their favorite KDE tools. Our setup consisted of one big screen showcasing a promotional video of KDE, interactive laptops, Plasma Mobile, and lots of Katie and Konqui stickers.

I was pleasantly surprised to see the excitement attendees had seeing us participate; they were willing to know more about our products, and what was going on with the KDE community. People love experimenting on Plasma Desktop and had fun trying out our applications. Plasma Mobile was also a hot topic of discussion and attendees were very eager to know the updates regarding it. Amongst our attendees, we had a lot of college students interested in joining our community and contributing to open source projects in general. 

Attendees of all ages showed a keen interest towards our GCompris Application, with lots of kids enjoying playing educational games. One of the attendees was part of the education administration of a local school district and even expressed some interest in integrating the application as a beta at a few schools.

This was the first time we offered swag at our booth and the Katie and Konqui Stickers were a big hit in attracting attendees to our booth. 

We went into this conference with a specific goal of outreach and spreading the word about KDE and I believe we succeeded quite a bit as we got a chance to work at a grass-roots level and find the next generation of open source contributors who are excited about the future of KDE.

This entire conference would not have been possible without Drew Adams and the entire OpenSuse community who played a huge role in helping us get a foothold at this conference. On behalf of all of KDE we want to thank them and acknowledge all the hard work that was involved to make this event happen.

Hope to see you all at SCaLE 20X next year in March. 

Till then Happy coding.

Monday, 5 December 2022

Dear digiKam fans and users,

After four months of active maintenance and another bug triage, the digiKam team is proud to present version 7.9.0 of its open source digital photo manager. See below the list of most important features coming with this release.

Bundles Internal Component Updates

As with the previous releases, we take care about upgrading the internal components from the Bundles. Microsoft Windows Installer, Apple macOs Package, and Linux AppImage binaries now hosts:

Saturday, 3 December 2022

Dolphin 22.12 is going to be released in a few days so it is high time that I report on its big new feature which I have implemented: the selection mode. In this light-hearted video I will present it next to problems, whose solutions have not been implemented yet.

The video has English subtitles.

At the end of the video I am mentioning that supporting KDE through a donation is definitely a good idea. Wait … There is actually a KDE fundraiser going on right now? Here is the link: https://kde.org/fundraisers/yearend2022/

Friday, 2 December 2022

Let’s go for my web review for the week 2022-48.


osquery | Easily ask questions about your Linux, Windows, and macOS infrastructure

Tags: tech, monitoring

This looks like an interesting OS level monitoring solution.

https://osquery.io/


WebAssembly: Go vs Rust vs AssemblyScript :: Ecostack — a developer blog

Tags: tech, webassembly, performance

Little simple benchmark of WebAssembly performances for the most common languages found there. Careful to the payload size though.

https://ecostack.dev/posts/wasm-tinygo-vs-rust-vs-assemblyscript/


Using Rust at a startup: A cautionary tale | by Matt Welsh | Nov, 2022 | Medium

Tags: tech, programming, rust, architecture

Don’t believe claims about Rust (or any other options in fact) being a language for universal use. It has a few spaces where it shines and others where it’ll be a drag. Picking the right language and stack is a multi-factor decision process where the technical advantages of the language itself say less than half of the story.

https://mdwdotla.medium.com/using-rust-at-a-startup-a-cautionary-tale-42ab823d9454


I am disappointed by dynamic typing • Buttondown

Tags: tech, type-systems, metaprogramming

Interesting take about what could make dynamic typing truly shine if it got all the way to runtime manipulation in a consistent manner. We’re far from it though.

https://buttondown.email/hillelwayne/archive/i-am-disappointed-by-dynamic-typing/


Git Notes: git’s coolest, most unloved­ feature - Tyler Cipriani

Tags: tech, git

Obscure feature definitely but we’re happy it’s there… maybe one day it’ll indeed allow to have much more independence from the code forges.

https://tylercipriani.com/blog/2022/11/19/git-notes-gits-coolest-most-unloved-feature/


I/O is no longer the bottleneck

Tags: tech, performance

Definitely this, we have to stop pointing disk I/O so much for performance issues. This is just not really slow anymore. Obviously network is a different story.

https://benhoyt.com/writings/io-is-no-longer-the-bottleneck/


Falsehoods programmers believe about undefined behavior

Tags: tech, compiler, c, c++, rust

Undefined behavior do exist and well… they’re really undefined, don’t make any assumption about them.

https://predr.ag/blog/falsehoods-programmers-believe-about-undefined-behavior/


Cache invalidation really is one of the hardest problems in computer science – Surfing Complexity

Tags: tech, performance, multithreading

Nice summary on the false sharing problem with caches and how it can impact your performances in multithreaded contexts.

https://surfingcomplexity.blog/2022/11/25/cache-invalidation-really-is-one-of-the-hardest-things-in-computer-science/


Recognizing patterns in memory // TimDbg

Tags: tech, debugging, memory

Interesting set of memory patterns. Didn’t know all of them, some are definitely useful and I already use, I’ll try to look for the others next time I need to.

https://www.timdbg.com/posts/recognizing-patterns/


Massively increase your productivity on personal projects with comprehensive documentation and automated tests

Tags: tech, git, project-management, maintenance

Nice list of things to keep in mind when working on projects, even small personal ones. This greatly improve maintainability in the long run.

https://simonwillison.net/2022/Nov/26/productivity/


Why writing by hand is still the best way to retain information - Stack Overflow Blog

Tags: tech, low-tech, note-taking, book

There’s definitely a tension between something which you can organize and search easily (by typing) and something you can remember better (by hand writing). That’s why I can’t get rid of hand written notes completely, I practice a mix of both depending on the use.

https://stackoverflow.blog/2022/11/23/why-writing-by-hand-is-still-the-best-way-to-retain-information/



Bye for now!

Friday, 25 November 2022

Let’s go for my web review for the week 2022-47.


Open letter for the right to install any software on any device - FSFE

Tags: tech, vendor-lockin, foss

Definitely something to sign, let’s get back some freedom on the device we got in our pocket.

https://fsfe.org/activities/upcyclingandroid/openletter.html


Digital environmental impact evaluation accross organizations

Tags: tech, ecology

I often find tools regarding environmental impacts on the client side. This group seems to focus more on the server side, definitely something to look into.

https://boavizta.org/en


The Fediverse Could Be Awesome (if we don’t screw it up)

Tags: tech, fediverse, social-media

This sudden rise of the Fediverse is indeed a chance. Let’s hope it’s not wasted. Good list of things to pay attention to in this article.

https://www.eff.org/deeplinks/2022/11/fediverse-could-be-awesome-if-we-dont-screw-it


ooh.directory

Tags: tech, blog, rss

Woa, that’s definitely welcome. A strong list of blogs to use in your feed aggregator. Time to explore.

https://ooh.directory/


Tree views in CSS

Tags: tech, web, frontend, css

Nice CSS trick to make collapsable trees without too much fuss.

https://iamkate.com/code/tree-views/


An Interactive Guide to Flexbox in CSS

Tags: tech, frontend, browser, css

Nice guide, the interactive parts definitely help. Good way to improve CSS use.

https://www.joshwcomeau.com/css/interactive-guide-to-flexbox/


Internals of sets and dicts | Fluent Python, the lizard book

Tags: tech, python, performance, optimization

Interesting deep dive on how sets and dicts are implemented in CPython. There are a couple of interesting tricks in there.

https://www.fluentpython.com/extra/internals-of-sets-and-dicts/#_footnoteref_6


Always use [closed, open) intervals. A programmer’s perspective

Tags: tech, programming, mathematics

Good reasons to use [closed, open) intervals. If you didn’t know where it was coming from, here it is.

https://fhur.me/posts/always-use-closed-open-intervals


D2 Tour | D2 Documentation

Tags: tech, diagrams

That looks like a nice declarative language to make diagrams. Missing sequence diagrams but otherwise seems fairly useful and readable.

https://d2lang.com/tour/intro/


Ignore RuboCop changes in Git Blame

Tags: tech, git

Now this is a very interesting trick for git. This way large reformatting commits are less of a concern when exploring commit history.

https://blog.testdouble.com/posts/2022-11-21-rubocop-git-blame/


Inhumanity of Root Cause Analysis – Verica

Tags: tech, complexity, project-management, failure, postmortem

A bit heavy handed in the way it tries to paint Root Cause Analysis as evil. Still it has good points about its shortcomings. In particular I appreciate the emphasis on complexity which indeed points to have contributing factors and unexpected outcomes. Definitely things to keep in mind for any postmortem efforts.

https://www.verica.io/blog/inhumanity-of-root-cause-analysis/


The Ancient Japanese Technique That Produces Lumber Without Cutting Trees

Tags: history, japan, ecology

Very interesting technique. Clearly some more work but prevents deforesting like mad for lumber. It’s amazing to see those… clearly a bit like giant bonsais.

https://dsfantiquejewelry.com/blogs/interesting-facts/the-ancient-japanese-technique-that-produces-lumber-without-cutting-trees



Bye for now!

Thursday, 24 November 2022

Since the last post about AudioTube, a lot has happened! So in this blog post, you can find a summary of the important changes.

Notable new features

Library

AudioTube now has a library, in which you can see your favourite, most often and recently played songs. library with rounded covers

Filtering through previous searches

This allows searching through locally known songs and previous search terms, without even sending a request to youtube. search dialogue which displays songs from your history

Lyrics

While playing a song, you can now see the lyrics of the song in a separate tab. lyrics shown in the player

User Interface improvements

Finally, AudioTube displays album covers everywhere. Devin Lin has redesigned and improved the actual audio player. Mathis Brüchert has done several design improvements across the board, like rounded album covers, improved spacing.

The support for wider screens has also been improved, and the queue list will now only expand up too 900 virtual pixels. player

Fixes

Fetching thumbnails is now much faster, since in most cases the thumbnail ID can be reliably predicted, without querying yt-dlp. In the few remaining cases, querying yt-dlp is still the fallback

Install

If you want to try AudioTube, you can get the latest stable version from flathub. If you want the latest improvements, which are usually already reasonably stable, you can grab a nightly build from the KDE Nightly flatpak repository.

Code improvements

While developing the library feature, a small new library was developed. I called it FutureSQL, after the QFuture type it uses for most parts of its API. FutureSQL provides an asynchronous API for QtSql, by running the database queries on a separate thread. It also provides convinient template functions for passing parameters to SQL queries.

Possibly the most interesting feature is automatically deserialize the resulting data from an SQL query into a struct. This works thanks to C++ templates.

In the simplest cases, nothing but

struct Song {
	using ColumnTypes = std::tuple<QString, QString, QString, QString>;

	QString videoId;
	QString title;
	QString album;
	QString artist
}

is required.

The library version of this code does not yet have a stable release, however you can already try the API if you build the library from the repository.

Sunday, 20 November 2022

The major new feature in this release is initial QML support, contributed by Jonah Brüchert. Jonah also contributed QObject::connect helper and a coroutine version of QQuickImageProvider. As always, this release includes some smaller enhancements and bugfixes, you can find a full list of them on the Github release page.

As always, big thank you to everyone who report issues and contributed to QCoro. Your help is much appreciated!

Initial QML Support

Jonah Brüchert has contributed initial support for QML. Unfortunately, we cannot extend the QML engine to support the async and await keywords from ES8, but we can make it possible to set a callback from QML that should be called when the coroutine finishes.

The problem with QCoro::Task is that it is a template class so it cannot be registered into the QML type system and used from inside QML. The solution that Jonach has come up with is to introduce QCoro::QmlTask class, which can wrap any awaitable (be it QCoro::Task or any generic awaitable type) and provides a then() method that can be called from QML and that takes a JavaScript function as its only argument. The function will be invoked by QCoro::QmlTask when the wrapped awaitable has finished.

The disadvantage of this approach is that in order to expose a class that uses QCoro::Task<T> as return types of its member functions into QML, we need to create a wrapper class that converts those return types to QCoro::QmlTask.

Luckily, we should be able to provide a smoother user experience when using QCoro in QML for Qt6 in a future QCoro release.

class QmlCoroTimer: public QObject {
 Q_OBJECT
public:
 explicit QmlCoroTimer(QObject *parent = nullptr)
 : QObject(parent)
 {}

 Q_INVOCABLE QCoro::QmlTask start(int milliseconds) {
 // Implicitly wraps QCoro::Task<> into QCoro::QmlTask
 return waitFor(milliseconds);
 }

private:
 // A simple coroutine that co_awaits a timer timeout
 QCoro::Task<> waitFor(int milliseconds) {
 QTimer timer;
 timer.start(milliseconds);
 co_await timer;
 }
};

...
QCoro::Qml::registerTypes();
qmlRegisterType<QmlCoroTimer>("cz.dvratil.qcoro.example", 0, 1);
import cz.dvratil.qcoro.example 1.0

Item {

 QmlCoroTimer {
 id: timer
 }

 Component.onCompleted: () {
 // Attaches a callback to be called when the QmlCoroTimer::waitFor()
 // coroutine finishes.
 timer.start(1000).then(() => {
 console.log("1 second elapsed!");
 });
 }
}

Read the documentation for QCoro::QmlTask for more details.

QCoro::connect Helper

The QCoro::connect() helper is similar to QObject::connect() - except you you pass in a QCoro::Task<T> instead of a sender and signal pointers. While using the .then() continuation can achieve similar results, the main difference is that QCoro::connect() takes a pointer to a context (receiver) QObject. If the receiver is destroyed before the connected QCoro::Task<T> finishes, the slot is not invoked.

void MyClass::buttonClicked() {
 QCoro::Task<QByteArray> task = sendNetworkRequest();
 // If this object is deleted before the `task` completes,
 // the slot is not invoked.
 QCoro::connect(std::move(task), this, &handleNetworkReply);
}

See the QCoro documentation for more details.

Full changelog

See changelog on Github