Skip to content

Welcome to Planet KDE

This is a feed aggregator that collects what the contributors to the KDE community are writing on their respective blogs, in different languages

Saturday, 8 October 2022

The Planck Keyboard

Over the past two years I tried out a few different keyboards for fun.

I started with common form factors like TKL boards, went over 75% boards like the Q1 and then to a 60% HHKB.

For typing feel, the HHKB is really amazing, but unfortunately the programmable features of a stock HHKB board are very limited.

Now that I went down to 60%, I will give a more extreme keyboard a chance, the 40% Planck ortholinear keyboard.

This one is fully open-source, you can even produce your own PCBs and Co. You find more or less all stuff freely at GitHub.

Given that the Plank designer funded QMK, too, naturally you can fully customize the Planck boards.

Unlike for my tries with the Q1, this time I just went the plain QMK route, without any UI like the closed VIA or the open VIAL.

The Planck board offers a nice platform for experiments, given the plain grid layer that allows really to freely shuffle all your keys and experiment with extreme layouts.

Building the Planck keyboard

Install QMK on NixOS

As I use at the moment NixOS at home, here the needed steps to get going with QMK on that distribution.

Install the qmk package. This will install the needed cross compile tool chains, too.

Ensure the udev rules are setup, e.g. add to your configuration.nix

1
services.udev.packages = [ pkgs.qmk-udev-rules ];

Run qmk setup, here with some own firmware location

1
qmk setup -H ~/install/qmk/firmware

Configure QMK to use the Planck as default

1
qmk config user.keyboard=planck/rev6_drop

Use my github name as keymap name

1
qmk config user.keymap=christoph-cullmann

Create own keymap based on default

1
qmk new-keymap

Compile the firmware

1
qmk compile

Put the keyboard in boot loader mode (e.g. trigger RESET)

Flash the firmware

1
qmk flash

Now the keyboard should auto-restart with the new firmware.

Have fun :)

Below the state of a finalized Planck board with some more or less standard first layer layout.

It even plays a nice startup sound on powering up.

Finalized Planck keyboard

My current keymap can be found on GitHub.

As the history of this repository shows, I already experimented if some different layouts.

Warning ^^

Yes, the paper on the left of the keyboard is a printout of the lower & raise keyboard layers.

My typing speed is still abysmal on that new layout and I guess I need to build as second one for at work, otherwise I will never get used to the layout if I swap daily between this and a HHKB.

Therefore, if you like to try such a board and are not a lot more experienced with switching between different layouts: you will need some time to get used to this.

Even just the removed row staggering is confusing the first few days.

I just returned from this year’s KDE Akademy in Barcelona. After two years of only virtual sprints it has been great to finally meet up with many fellow KDE friends, most of which I haven’t seen since 2019, and also get to know some of the faces of people that have joined in-between.

Picture from the peak of a mountain: rocky mountain top with bushes occupying the lower right quadrant of the image, a radio tower on the right, east-Ibrian landscape as far as the eye can see, with blue haze covering mountains far in the distance to the horizon, blue skies, clouds in the distance.
On top of the world at Montserrat

Whenever I’m using the public WiFi somewhere, I feel like there should be a hint in the network Plasmoid about logging into the captive portal. There is a persistent notification when connecting but once you close it, you can’t get it back. For implementing this, I wanted to use the NetworkConnectivity enum from our networkmanager-qt Framework. In the early days of QtQuick, however, we typically created a wrapper class for exposing enums to QML, which meant having to sync up two separate implementations.

Qt’s tooling has evolved a lot since and nowadays it’s possible to register namespaces, too. To do so, you need to add the Q_NAMESPACE macro and annotate the enums using Q_ENUM_NS. In the networkmanager-qt case, there was a catch, though: the namespace’s meta object had to be exported since plasma-nm is a separate project. That’s what the Q_NAMESPACE_EXPORT macro is for: once added, I could just register the enum to the QML engine and use it directly from the Plasmoid UI.

Plasma’s network Plasmoid with a new hint “You need to log in to this network”.
Captive Portal hint in Network Plasmoid

When attending Akademy, you get a badge with your name on it, so that building security doesn’t kick you out. You can fold it open like a leaflet and quickly look up the event schedule including important organizer contact information. This year, there was also a QR code for connecting to the venue’s WiFi network. While our QRCA application can set up a connection just fine, it would be much more convenient to have a scanner in the network Plasmoid itself.

Thanks to Volker’s work on KDE Itinerary, which deals a lot with ticket barcodes, there’s now a reusable scanner component in our Prison framework that you pretty much just plug into a Camera source from QtMultimedia to start detecting things. You might have spotted the QR code button in the screenshot above but I still need to iron out a few quirks before I’ll submit a merge request to add it.

A table with a nut-cream cake with the KDE Eco logo on it, the KDE Eco logo and Blue angel logo on a display behind it
Celebrating Okular’s eco certification with a delicious cake

Saturday and Sunday were packed with talks, and my personal highlights were David’s talk “Full Steam Ahead” about Valve’s Steam Deck (which runs KDE Plasma!) and Volker’s talk on Push Notifications in Plasma where he let the audience spam him live during his presentation – that was quite a bold move. Harald also did an interesting session on a new tool KDE is evaluating for automated crash reporting, called Sentry.

Monday traditionally started with the KDE e.V. General Assembly where, among other things, two new board members were elected. After lunch there was a two our workshop on KDE Frameworks 6. Sadly, the microphone setup we had in the meeting rooms wasn’t really up to the challenge of having dozens of people scattered across the room, and thus we had a hard time incorporating remote attendees into the discussion, including Virtual D4™, whom we already got to know from the first KDE Frameworks 6 sprint three years ago. Nevertheless, we decided on a timeline when to branch off KDE Frameworks 6, with a feature freeze on KF5 at the end of December this year and Plasma 5.27 being the final feature release in the Plasma 5 series.

KDE’s painting application Kolourpaint showing a group photo of the Akademy daytripe hike with its version dialog in the front reading “Components: KDE Frameworks Version 5.99.0, Qt Version 6.4.1 (built against 6.4.1)”
Kolourpaint built against Qt 6 (Screenshot courtesy of Volker Krause)

Qt 6 and Fameworks 6 was a big topic at this Akademy for me, too, and I spent quite some time porting stuff away from deprecated API and adding Qt 6 CI afterwards. Nico’s iskdeusingqt6.org website gives you an up-to-date view on how our porting is progressing. I started by porting the most important KDE application, Kolourpaint, to Qt 6. I also ensured that we can still have Akademy group photos in the future by making sure KImageMapEditor worked well with it. I then also had a look at Ark, Dolphin-Plugins, and Print-Manager. Most parts of Plasma were still blocked by KWin not building against Qt 6 but there has been great progress on fixing that, and I believe the last remaining changes should be merged any day now.

Tuesday was packed with BoFs: it started off at early in the morning at 9 with a session on KDE’s Yocto layers, which you should definitely check out if you’re building an embedded device. On the subject of embedded devices, I then hosted a discussion around using KWin in such an environment. In the afternoon or newly crowned Dolphin maintainer held a meeting on the biggest areas of improvement needed to KDE’s file manager. Wednesday we all went on a bus trip to the Montserrat Abbey an hour Northwest of Barcelona, took the funicular up the mountain, and hiked up the rest to one of its peaks. Overall it was a good conference and I can’t wait to see all of you again next year in Thessaloniki!

Over the past two weeks, the KDE community has largely been preparing for and attending Akademy, the big annual in-person conference. It’s a great time to bond socially and discuss important topics face-to-face, and more on that later! Meanwhile we’ve also been getting Plasma 5.26 ready, which has benefited from a major focus on stability. Expect that to ramp up now that Akademy is finished. More on that later as well!

New Features

KDE Welcomes a new app to the fold: Ghostwriter is now a KDE app!

Ark now supports ARJ archives (Ilya Pominov, Ark 22.12. Link)

Kate and KWrite now have a welcome window when launched without any files open. (Eric Armbruster and Christoph Cullmann, Kate & KWrite 22.12. Link):

This is what KWrite shows, and Kate is currently being adapted to show a much more advanced version!

User Interface Improvements

In Dolphin, dragging-and-dropping a folder onto an empty area of the tab bar now opens it in a new tab (Kai Uwe Broulik, Dolphin 22.12. Link)

The animation for the Slide Desktops effect has been made a bit faster, due to popular demand (Vlad Zahorodnii, Plasma 5.26. Link)

In the “new screen plugged in” chooser OSD, choosing “Extend Left” now actually makes the new screen extend left, and it extends from the current primary screen (Allan Sandfield Jensen, Plasma 5.26. Link 1 and link 2)

On System Settings’ Colors page, clicking the “From Accent Color” option now updates the preview view immediately to show the accent color that will be used (Tanbir Jishan, Plasma 5.26. Link)

When transferring files using Bluetooth, the progress notification now shows more detailed and useful information (Kai Uwe Broulik, Plasma 5.26. Link)

Uninstalling an app now removes its icon from the Kickoff Application Launcher’s favorites list/grid immediately (Alexander Lohnau, Plasma 5.27. Link)

Picture of the Day wallpapers how have a nice cross-fade transition animation when switching from one picture to another, or to a different type of Picture of the Day picture (Fushan Wen, Plasma 5.27. Link)

The Breeze Window Decoration theme setting to continue displaying window borders for maximized and tiled windows has now been re-worded for clarity (Natalie Clarius, Plasma 5.27. Link)

The Media Frame widget’s “Show/hide background” setting now uses the standard user interface for this, with a button on its Edit Mode toolbar (Fushan Wen, Plasma 5.27. Link)

When replying to a text message using the KDE Connect plasmoid, the text field is now inline rather than in a separate dialog window (Bharadwaj Raju, KDE Connect 22.12. Link)

When you unmount a removable device in Dolphin, its Eject button now transforms into a busy indicator so you know when it’s safe to physically unplug it (Kai Uwe Broulik, Frameworks 5.100. Link):

Significant Bugfixes

(This is a curated list of e.g. HI and VHI priority bugs, Wayland showstoppers, major regressions, etc.)

Switching between Global Themes that include their own desktop layouts no longer sometimes causes Plasma to crash and lose your panels (Nicolas Fella, Plasma 5.24.7. Link)

System Settings no longer sometimes crashes when navigating away from the Thunderbolt page (David Edmundson, Plasma 5.24.7. Link)

On System Settings’ Users page, It is once again possible to change your user password and nothing else when using a recent version of the AccountsService library (Marco Martin, Plasma 5.24.7. Link)

In the Plasma X11 session, when repeated graphical crashes cause KWin to disable compositing, it will now periodically check to see if it’s better, and if it is, it will re-renable compositing so you don’t have to do it manually or lose compositing forever if you don’t know that this has to be done (Arjen Hiemstra, Plasma 5.26. Link)

Application Dashboard grid items now have two lines of text, so you can actually read longer labels (Tomáš Hnyk, Plasma 5.26. Link)

In the Plasma X11 session, when KWin crashes and auto-restarts–or is manually restarted–it no longer loses its mapping of windows to Activities (David Edmundson, Plasma 5.26. Link)

Fixed an issue that could occasionally cause apps like VLC and Firefox to stop refreshing after being used for a while (Vlad Zahorodnii, Plasma 5.26. Link)

In the Networks plasmoid, networks no longer jump around and re-arrange themselves while you’re trying to connect to one or enter your password (Ivan Tkachenko, Plasma 5.26. Link)

Discover and other apps that can display animated images can no longer freeze when displaying certain PCX images (Aleix Pol Gonzalez, Frameworks 5.99. Link)

Various System Monitor graphs no longer blink, stutter, and freeze when using an NVIDIA GPU (Łukasz Wojniłowicz, Frameworks 5.100. Link)

Other bug-related information of interest:

…And everything else

This blog only covers the tip of the iceberg! If you’re hungry for more, check out https://planet.kde.org, where you can find more news from other KDE contributors.

How You Can Help

If you’re a developer, check out our 15-Minute Bug Initiative. Working on these issues makes a big difference quickly! Otherwise, have a look at https://community.kde.org/Get_Involved to discover ways to be part of a project that really matters. Each contributor makes a huge difference in KDE; you are not a number or a cog in a machine! You don’t have to already be a programmer, either. I wasn’t when I got started. Try it, you’ll like it! We don’t bite!

Finally, consider making a tax-deductible donation to the KDE e.V. foundation.

Friday, 7 October 2022

As many readers of this blog are aware, openSUSE has been offering packages of git snapshots from KDE since quite a while. They are quite useful for those wiling to test, report bugs, and / or hack on the code, but also for those who want to see what’s brewing in KDE land (without touching their existing systems). However, a major drawback for non English speakers was the lack of translations.

What’s the problem with translations?

KDE translations are not hosted on the community’s git repositories, but are instead stored in KDE’s SVN server. The main reason they were not moved to git was to preserve the existing workflows of the translation teams (who might not be as technical as the actual hackers). Translations are then placed in tarballs at the times of betas / RCs / releases.

This unfortunately means that having a git checkout, like what the OBS does when building the unstable packages, will not carry any translations whatsoever. Worse, existing -lang packages for stable versions will raise dependency problems if present (because they require the exact same version of their corresponding binary paclage).

Also, since the KDE team tries to keep the same set of package defintions (spec files) between the stable and unstable OBS projects, this meant some extra complexity to take into account the fact that translations might or might not be there.

As far as I remember, since some time there was some tooling in KDE infrastructure to download translations at build time, but it was a big no-no for the OBS, as there is no network access during building for security reasons.

Two sides of a solution

This proved to be a problem also for KDE’s own release management. On September 2nd, KDE hacker Albert Astals Cid outlined a proposal to have an automated way to copy translations from SVN into their corresponding repository, with a series of scripts that would do so periodically.

After some discussion and once at Akademy, the switch was turned on October 2nd. This means that our git checkouts were getting translations!

Of course, some adjustments were needed: spec files in the KDE Unstable projects were not taking the presence of translations into account, and thus quite a number of builds were failing. krop, KDE team member extraordinaire, stepped in and fixed all the spec files. This in turn made him realize that some upstream KDE projects were not actually handling translations correctly in their CMake code, so he fixed them too.

Within a couple days, all KDE Unstable repositories (Frameworks, Applications and Extra) had translations enabled, where applicable. After many years, it became possible to test the latest KDE software and have it in your own language.

Do I need to do anything?

If you don’t have the language packages installed and you have installation of recommended packages enabled (the default), they should be installed automatically. If you have, like myself, forcibly installed the language packages from the stable repositories, you can force install the new ones (for example with zypper install -f <packagename>), or if you’re on Tumbleweed, accept to swap them when prompted (this occurs when a new stable version of KDE software is published in a snapshot). Or you can install them manually should you prefer to do so.

Should any issues with the packaging arise (e.g., missing dependencies, conflicts), please file a ticket on bugzilla.opensuse.org.

And as always, have a lot of fun!

I’m back from Akademy, it was a blast I was glad to be there and meet people in person again. Now let’s go for my web review for the week 2022-40.


TikTok Tracks You Across the Web, Even If You Don’t Use App - Consumer Reports

Tags: tech, social-media, surveillance, attention-economy

The most addictive and also tracking you everywhere it can (unsurprisingly). Toxicity at its highest.

https://www.consumerreports.org/electronics-computers/privacy/tiktok-tracks-you-across-the-web-even-if-you-dont-use-app-a4383537813/


A multi-language bindings generator for rust

Tags: tech, rust, bindings

This should hopefully ease the pain of mixing Rust with other languages.

https://github.com/mozilla/uniffi-rs


Pull Rust introductory support from Kees Cook

Tags: tech, linux, kernel, rust

This is definitely a big deal both for the kernel and for Rust.

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=8aebac82933ff1a7c8eede18cab11e1115e2062b


A curated collection of diagramming tools used by software engineering teams

Tags: tech, architecture, diagrams

A good list of tools for making diagrams in various situations.

https://github.com/shubhamgrg04/awesome-diagramming


Laurence Tratt: UML: My Part in its Downfall

Tags: tech, architecture, design, uml, history

Very interesting post about the history of UML and the MDA approach. Clearly MDA and UML v2 was the beginning of the end for UML. That’s too bad, I find UML still useful for sketching and communication between humans.

https://tratt.net/laurie/blog/2022/uml_my_part_in_its_downfall.html


Monday’s Engineering - Personal Development Plan

Tags: tech, hr, management, career

Interesting career ladder example. I especially like the various dimensions they focus on.

https://growth.monday.com/homepage/rd/engineering/?p=mr0-mr1-mr2-mr3-tr0-tr1-tr2-&f;=no


Staff engineer archetypes. | Irrational Exuberance

Tags: tech, management, tech-lead, team

Interesting little taxonomy of staff engineer roles. This can help to know from where you’re talking in your organization.

https://lethain.com/staff-engineer-archetypes/


First make the change easy, then make the easy change

Tags: tech, life, xp, refactoring

Good point, this little wisdom from Kent Beck goes further than just code and refactoring.

https://www.adamtal.me/2019/05/first-make-the-change-easy-then-make-the-easy-change


An end to doomerism - Big Think

Tags: life, philosophy

Although I disagree with some of the examples she summons, I think she indeed has a point.

https://bigthink.com/progress/pessimism-is-a-barrier-to-progress/



Bye for now!

For a long time I have been fixing issues behind the scenes to support Autocrypt and fixing bugs around encryption.

But the best crypto support does not help if it is too complicated for users to use the system. PGP is complex and a lot of things can go wrong, so the UI should support the user to find solutions, if things are going the wrong way. For me it was obvious that I cannot do this on my own and found Eileen Wagner a UX designer who is experienced in crypto UX. It was a lot fun to work together with Eileen to improve the UX in Kontact ;)

It soon became obvious that the part that needs an overhaul is mostly sending. There is a lot that happens AFTER you press send. You may be faced with information that the keys are not good enough, or that a used key is near expiry. So we tried to improve the UX so that these issues will bubble up earlier so you can fix the issues before pressing send.

At least for me, it is often that I concentrate in order to finish a message before I need to go, and then press send in a hurry. So all dialogs and warnings are facing me while I'm in a hurry and I just want them to disappear. If instead, I know of those things in advance, I will have time to ask for a new key or search for the correct key for a particular recipient.

Here you see a sample of creating a message to several recipients after our improvments.

Eileen created a blog post about the thoughts behind the UX decisions made for Kontact. After several months of working together with Eileen, I realized that for outsiders, it is still hard to distinguish Kontact and KMail. Kontact is a bundle of several applications that are presented together. You are free to start and use every of those applications directly and will see no difference. You only will miss the small left-column to switch between the applications. KMail is the application that Kontact is using for the mail tab.

This work is possible because Eileen and I were funded by nlnet to improve Email Encryption in Kontact.

Near key expiry

I really like the feature that Kontact informs you about keys that will soon expire. Doing this makes it clear that I need to care about a key update and I can trigger it in advance. I know there is a lot of discussion about automatic key updates and several attempts to do this.

I am still using parcimonie for this task. But unfortunately not everyone is using a key server to communicate key updates, and nowadays there are several sources for keys update keyserver, WKD, PKA, DANE, ... Sure it would be easy to try an update in background, but starting a network connection without users consent is a no-go. So the first step is now to show the user that keys are near to expiry. In the second step, we will make it possible for the user to directly trigger an update. This will also be true if no suitable key was found for a recipient.

As I was inside the near-expiry feature code, I also added a fourth category for your own keys. I want to get informed about my own key expiry long before the key expires, to create and upload the key update, so when others are searching for the keys they already find the updated key.

Key cache usage

Until now Kontact always talked to gnupg directly using gpgme. In itself this is not an issue, but this connection is slow. This is why libkleo started to implement a key cache a while ago to cache all keys. Before, we had to wait for gnupg to answer all our requests. In my experience, that means sometimes I wait a minute or longer.

Now Kontact is also using this cache and we now can instantly show that we found PGP keys for all recipients, while typing the mail address. Do you see how fast the "green check mark" toggles while writing in the video? This "green check mark" indicates, that we found keys for all recipients. That's possible because of the key cache.

Trust levels

Gnupg now has the TOFU (trust on first use) feature that creates statistics about key usage and when we seen keys in our messages. When a key is used for a long time, the key is trusted more, and now you can detect a key with no history. This makes it harder for someone to present you with a new fake key. Of course, you get the best security by checking fingerprints and signing the recipient keys. But let’s be honest, who can do this for every key that one is using in our busy lives. For those who do not check every key, TOFU is actually a great improvement, as you build trust while using the keys.

In Kontact we are now display the trust levels instead of just validity, as the trust levels are taking the TOFU history into account. I personally cannot see any disadvantage to enabling trust-model 'tofu+pgp' in gnupg via (~/.gnupg/gpg.conf) and would highly suggest that everyone enable that in gnupg. It gives you the best of two worlds: You will be able to build trust on the keys by just using the keys (tofu part) and still can also check fingerprints (pgp part).

After enabling it I actually found out that until now the tofu data is not updated when I sent an encrypted message. However, it is done, if I use gnupg from the command line. I created a upstream bugreport for this. Until this is fixed tofu is a little bit useless, because no statistics are created. Key cache and key resolver also need to learn trust levels, as they are in charge to select the most trusted key to send messages to.

Settings

The settings in Kontact are in some corners a big list of checkboxes and it is not obvious where to find what. For Encryption we decided to merge several tabs together to present one page and name it Encryption.

There is also the signature feature, that is not connected with Cryptography but just about the mail signatures.

The critical point is the defaults for new users and we ended up having default encryption settings that can be overridden for each identity.

As all the work was done with Autocrypt in mind, I also mark Autocrypt support as stable. Now the user can enable Autocrypt within the settings page of the identity.

Identity settings Security Encryption settings

In the end I think these improvements take Kontact a big step forward and lets us use encryption more easily. I'm proud about the current state, but my To-Do list is still full until we have looked into all the corner cases.

Thursday, 6 October 2022

As one of the three winners of the KDE Akademy Awards in 2021 (Alexander Semke for Best Application; Paul Brown for Best Non-Application; me for Jury Award), it fell to me and the other winners to decide upon winners for this year’s Akademy. Alexander couldn’t make it to the event, so Paul and I got up on stage. Congratulations Jasem, Harald and Aniqa!

I have put the slides up on my website. Not because the slides are so special (and they really do need the presentation to go along with them; the broken icon is broken because that’s what the award is about). But they do provide a convenient example of how to put together a KDE-themed presentation with just HTML, Javascript and some Markdown. They use remark.js, and I’ve come to the conclusion that having web-accessible simple slides is really useful for those times when you have to put together a presentation while at a conference and don’t want to mess with presentation tooling (or even LaTeX).

Qt for MCUs 2.2.2 has been released and is available for download. As a patch release, Qt for MCUs 2.2.2 provides bug fixes and other improvements, and maintains source compatibility with Qt for MCUs 2.2.x. It does not add any new functionality.

Geeks on a mountain

After two days of talks we have moved to a week of BoF sessions. (I’m not a fan of the term BoF but I’ve never managed to think of anything better.) Here’s some notes I made incase anyone is interested.

The big news is the Frameworks 6 session had some Plasma people there too and voila we have a plan for 6. Most Frameworks and even most Plasma is already working with Qt 6. So the last Frameworks 5 release is due in December and then work will happen to finalise the porting to Frameworks 6 and once that’s solid releases will start again using Qt 6. And for Plasma we’ll make a final Plasma 5 release at the start of next year versioned 5.27. That will be LTS so we’ll stop the 5.24 LTS releases and make further 5.27 releases as long as they are useful. The finalising of the porting to Qt 6 will start in January and we’ll schedule a release whenever that becomes practicle which should be not too far into 2023.

Our BoF sessions are Covid secure

We had a session with App Stores looking at what are the most popular products and what methods are there to make money. My notes say we discussed charging some money on the Windows store for say Okular and monitor how well that goes down. There’s also ideas of bundling games together. Monitoring could be implemented with KUserFeedback. KStars could be worth asking money for but that’s already on the MS store for free. Automatic testing would be very useful for app deployment, possibly with OpenQA or other tech. I asked for help with packaging Kontact and Akonadi in Snaps (Flatpaks need it too).

Chillaxing between sessions

The translations, which have always been kept separate in KDE codebase, are now copied nightly into master by the Scripty script. This should make it easier to make tars although releaseme will continue to copy over the latest translations when run. Some apps need CMake updated for this change. Most importantly this means KTuberling can compile in KDE neon for the first time years.

Speaking of KDE neon, we had a KDE neon session. Nate suggested the idea of making a specification that could be applies to brand any distro spin which would require it to ship up to date KDE software, apply recommended patches prompty, use KDE’s Qt branches, use recommended software suite, not change wallpapers etc. We decided that using the neon branch for this was not the way to go but it could be e.g. a Plasma Distro Experience certified brand. Needs someone to make the spec and the test suite.

Back to neon proper we discussed the rebase on ubuntu 22.04 which is almost nearly ready and David Redondo was good enough to do a live upgrade in the BoF but it broke in various ways so I guess some more fixes needed here. The problems of invent gitlab rejecting our server for Git requests was dicussed, it’s the main thing that drags neon releases when we are slow, more debugging is needed. We pondered added RiscV and concluded “do it”. Moving our infrastructure into invent is still blocking on a service which orders the builds. kdeedu-data builds are still broken (because translations are funny here) and Albert has said he’ll write the code for this.

On Wednesday we had a nice hike up the mountain of Montserrat and then an even longer hike downwards.

KDE went up a mountain

On Thursday David Faure gave us a training on debugging and profiling as sponsored by KDAB. He took us through using strace. rr is for record and replay which lets gdb do a reverse run which is useful for non-deterministic tests that randomly fail. And for gdb he recommends using cgdb the ncurses frontend for it. He took us through gammaway which lets you see lots of interesting Qt goings on such as which signals and slots get run, which settings are set in widgets etc etc. radardoc is a good debugging tool for graphics calls. And he took us through compiler sanitizers which get more debug tooling into gcc and clang and works similar to Valgrid but with some different properties.

Later on we went for pizza on the beach.

My Photo Album

I will be talking about text in this post, specifically about cases where you have to handle a lot of it. We are not talking about a general solution, but a specific case that we encountered during a customer project.

The Problem

The project involved showing a chat room for internal communication. We developed a functioning chat room and, eventually, as it grew, we also added support for limited chat history. This was all fine until we heard from the customer that users might need to browse through the whole history, which, in some cases, can span hundreds of thousands of lines of rich text. “How hard can it be?,” we thought. This was a QML application and we soon realized that it’s not as easy as we thought. To see why, consider this demo app:

It’s a very small, simple app which doesn’t even look like anything when you start it. Then, I hit a button to load the chat history and everything just gets stuck. It takes a while but, eventually, it loads.

Although it takes a few seconds to load and this is around 5000 files of HTML, our problems have only just begun. Even though it might feel smooth to scroll, sometimes it’s not. Then, you resize it and what happens? The whole thing gets stuck, starts responding for a while but not quite in the resize behavior we want.

The problem is that TextArea just can’t handle displaying so much text at once. Obviously, this was not ideal. We went back to the customer to ask if they really want to look at this big load of text and, of course, they said yes! Given that all this works fine in the widgets world, it’s not impossible.

Solutions

At this point, we started to try a few approaches. The first thing we tried was, obviously, profiling to see what’s going on. It turned out that resizing a text document is a lot of work. Imagine that you’re looking at a specific line in the text area. Now, every time you try to resize, it needs to figure out which line you should be at now. For that it needs to take into account formatting, word wrapping, and a couple of other things. All of that really takes a long time and everything just goes bonkers.

To remedy this, we tried a custom painted item and painting the document ourselves with some optimizations. We actually got it working and everything seemed fine at first. But then, we ran into other problems similar to the performance issues from the original TextArea.

The second thing we tried (which started as a joke, to be honest) was using WebEngineView since browsers are really good at handling text. So, why not? We just slammed a WebEngineView in there and loaded all the text. It loaded instantly because HTML browsers can just take it in a jiffy with no problem at all. That’s fine until you realize that the customer’s application actually shows 20 of these chat rooms, for example. So, you won’t just have one, you will have 20 WebEngineView instances, which would not really go kindly on the RAM and your users will hate you.

Eureka!

Then, we ended up doing what I’m going to demonstrate next. We essentially created a ListView, did some magic in the background, and everything seemed to work…

 

…well, sort of (maybe you can already tell what the problem might be?). Let’s peek under the hood to see how this is implemented:

ListView {
    model: chatLogModel
    delegate: TextArea {
        padding: 0
        width: ListView.view.width
        textFormat: TextEdit.RichText
        wrapMode: Text.Wrap
        selectByKeyboard: true
        selectByMouse: true
        text: display
    }
}

Instead of the whole thing being one fat TextArea, every delegate is one. This is very efficient at showing practically unlimited lines of text because ListView will only instantiate delegates for the lines that are visible. However, this means that selection no longer works properly; you cannot select across lines. Fear not! With a little bit of patience, it is possible to manually implement the selection behavior. If you are curious about the code, take a look here. We essentially figure out where the user is scrolling the mouse through a MouseArea on top of the ListView and then, in essentially all the delegates, find out what needs to be selected. This works surprisingly well.

(Tip: The demo handles selection, etc., in QML for ease of demonstration; in real world code, you’d be better doing this with a proper selection model in C++.)

Conclusion

As I stated at the beginning of this post, this is not a general solution. But for cases where just viewing the text is enough, the moral of the story is: ListView rocks!

About KDAB

If you like this article and want to read similar material, consider subscribing via our RSS feed.

Subscribe to KDAB TV for similar informative short video content.

KDAB provides market leading software consulting and development services and training in Qt, C++ and 3D/OpenGL. Contact us.

The post Handling a Lot of Text in QML appeared first on KDAB.