Skip to content

Friday, 12 April 2024

KEcoLab, a tool for measuring software energy consumption, needs robust testing to ensure its functionality after every code change. This blog post presents the work I did in Season of KDE 2024 implementing dedicated test builds using Kate test scripts to achieve this goal. By implementing a dedicated "test-build" and "integration" stage within the CI/CD pipeline, we can enhance KEcoLab's reliability and maintain confidence in its results.

Setting up CI test (image from Sarthak Negi published under a <a href="https://spdx.org/licenses/CC-BY-4.0.html">CC-BY-4.0</a> license).
Figure : Setting up CI test (image from Sarthak Negi published under a CC-BY-4.0 license).

Background

KEcoLab simplifies the process of analyzing KDE software's energy consumption through the CI/CD pipeline in Invent. This automation streamlines the measurement process, offering crucial insights for developers and helping projects seeking eco-certification. However, ensuring KEcoLab's continued effectiveness requires thorough testing after each code modification.

The Challenge

KEcoLab retrieves the package name from the merge request for testing purposes. However, this approach doesn't guarantee stability after code changes unrelated to specific packages. To address this, we propose a dedicated "test-build" stage within the CI/CD pipeline.

The Solution: Dedicated Test Builds

The proposed "test-build" stage leverages Kate test scripts located in the KEcoLab repository. These scripts will be instrumental in mimicking CI tests and validating KEcoLab's functionality.

Here's a breakdown of the proposed stages within the test build:

Stage: test-build

  • Tag: test-build

  • Function: This stage functions similarly to how the existing KEcoLab pipeline operates. However, instead of dynamically retrieving the package name, it will be hardcoded to org.kde.kate (as this is the specific package we're focusing on for testing).

  • Key Difference: This stage won't rely on files from the merge request. Instead, it will clone the KEcoLab repository to access the necessary Kate usage scenario files. This ensures we're testing against the latest codebase in the repository, regardless of specific merge requests.

  • Implementation: To improve code organization and maintainability, we've adopted a modular approach to CI/CD pipelines. We now have two dedicated YAML files:

    • .test-energy_measurement.yml: This file defines the stages for the CI test pipeline.
    • .energy_measurement.yml: This file contains the stages previously defined in .gitlab-ci.yml. All the code related to energy measurement testing has been shifted to this new file.

    Both YAML files reside within the same directory for easy management. The main .gitlab-ci.yml file utilizes the include keyword to incorporate the stages from these dedicated files. This promotes modularity, improves readability, and reduces redundancy in the main pipeline configuration.

# Test-build stage
test-build:
 stage: test-build
 image: alpine
 tags:
 - EcoLabWorker
 before_script:
 # Hardcode the package name to org.kde.kate
 - PACKAGE_NAME="org.kde.kate"
 script:
 # Add flathub remote if not exists
 - flatpak remote-add --user --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
 # Install the specified package (org.kde.kate) from flathub
 - flatpak install --user $PACKAGE_NAME -y
 # Clone the KEcolab repository to access usage scenario files
 - git clone https://invent.kde.org/teams/eco/remote-eco-lab.git
 # Copy the kate usage scenario files from the cloned repository to the required location
 - cp remote-eco-lab/scripts/test_scripts/org.kde.kate/* scripts/test_scripts/org.kde.kate/
 rules:
 - if: $CI_PIPELINE_SOURCE == 'merge_request_event'

Stage: test-energy-measurement

  • This stage operates identically to the existing KEcoLab pipeline stage for energy measurement.

Stage: test-report

  • This stage also functions identically to the existing KEcoLab pipeline stage responsible for generating reports.

Future OutLook

Stage: integration test

We introduce a novel integration test

  • This stage aims to compare reports generated during the test build with previous reports. By utilizing the diff command, we can identify significant discrepancies between the reports. This helps us detect potential regressions or unintended changes in how KEcoLab measures energy consumption.
# This stage is for integration tests
stage: Integration test

# Jobs to be executed in this stage
jobs:
 - run:
 # Replace with your actual script to run integration tests
 name: Run integration tests
 script: your_test_script.sh

 # Diff reports job (assuming reports are stored in artifacts)
 - diff_reports:
 # Retrieve artifacts from previous job
 stage: Integration test
 artifacts:
 paths:
 - reports/
 script: |
 # Install diff tools
 apk add diffutils

 # Get the latest reports from artifacts
 report1=$(ls reports/*.html | sort -r | head -n 1)
 report2=$(ls reports/*.html | sort -r | head -n 2)

Why it matters

  • Enhanced Stability: By focusing on a specific package (org.kde.kate) and utilizing the latest codebase from the KEcoLab repository, we ensure comprehensive testing across code changes, not just those within a particular merge request.

  • Catch Bugs Early: The integration test utilizing diff allows for the early detection of regressions or deviations in energy measurement behavior. This proactive approach helps maintain consistent and reliable results from KEcoLab.

  • Confidence in Every Change: Whenever someone contributes code, passing tests ensure those changes don't disrupt existing features. This builds trust and keeps development smooth.

  • Save Time, Be Awesome: Automating tests frees up valuable time for developers to focus on innovation. We can spend less time debugging and more time making KEcoLab even better!

CI testing (image from Sarthak Negi published under a <a href="https://spdx.org/licenses/CC-BY-4.0.html">CC-BY-4.0</a> license).
Figure : CI testing (image from Sarthak Negi published under a CC-BY-4.0 license).

So, How Will It Work?

We have existing test scripts used for Kate, KDE's text editor. We'll first see if these can be adapted for KEcoLab. If needed, we'll create new tests specifically designed for KEcoLab's functionalities.

Here's the coolest part: these tests will become part of our CI/CD pipeline. Whenever someone submits code changes (a merge request), the pipeline will automatically run the tests. If everything passes, the changes are merged with manual approval by the maintainers. But if a test fails, it'll be like a flashing red light, prompting us to fix the issue before merging.

The proposed dedicated test build approach using Kate test scripts is a valuable addition to the KEcoLab CI/CD pipeline. This enhanced testing strategy helps ensure that KEcoLab continues to deliver accurate and reliable software energy consumption measurements, ultimately leading to more efficient and eco-friendly code.

Interested in Contributing?

By implementing dedicated CI-tests leveraging Kate's existing test scripts, we're taking a big step towards solidifying KEcoLab's stability and ensuring the accuracy of its software energy consumption measurements. This wouldn't be possible without the incredible support of the KDE community and my mentors @karan @joseph. Their dedication to open-source development is truly inspiring.

Want to See More? Head over to KEcoLab on invent.kde.org to explore the project, learn more about its development, and check out the merge request that sparked this advancement!

We're excited about this approach and would love to hear your thoughts! If you're interested in contributing to KEcoLab's development and helping make software development a more sustainable practice, you are always welcome. Together, we can make a real difference!

Friday, 12 April 2024

KDE today announces the release of KDE Frameworks 6.1.0.

KDE Frameworks are 83 addon libraries to Qt which provide a wide variety of commonly needed functionality in mature, peer reviewed and well tested libraries with friendly licensing terms. For an introduction see the KDE Frameworks release announcement.

This release is part of a series of planned monthly releases making improvements available to developers in a quick and predictable manner.

New in this version

Attica
  • Do not signal an error when a job was cancelled. Commit. Fixes bug #483117
Baloo
  • [Extractor] Explicitly abort the transaction on early exit. Commit.
  • [WorkerPipe] Verify inputEnd() is signaled when parent process exits. Commit.
  • Some indexers need non-slash trailed path. Commit. Fixes bug #478854
  • Skip indexing KDE FS volumes unless user included. Commit. Fixes bug #460509. See bug #390830
  • [tests/engine/singledbtest] Allow testing multiple databases. Commit.
  • Ci: download .clang-format during CI runs. Commit.
  • [Extractor] Change to QCoreApplication. Commit.
  • Ci: check clang-format during CI. Commit.
Bluez Qt
  • Add support for manufacturer data in LE advertisements. Commit.
Breeze Icons
  • Temporarily add back kdenlive-*-video for compatibility. Commit.
  • Rename kdenlive--edit to timeline-mode-. Commit.
  • Remove kdenlive-select-tool. Commit.
  • Remove kdenlive-spacer-tool icon. Commit.
  • Fix duplicates. Commit.
  • Rename kdenlive-object-* to object-*. Commit.
  • Rename kdenlive--audiothumb to waveform-. Commit.
  • Remove kdenlive-show-videothumb icon. Commit.
  • Rename kdenlive--video to video-. Commit.
  • Rename kdenlive--audio to audio-. Commit.
  • Rename kdenlive-align-none to align-none. Commit.
  • Add Flatpak ID symlink for kwalletmanager. Commit.
  • Add system-suspend-inhibited, system-suspend-uninhibited. Commit.
  • Add rdns-style name symlink for kcolorchooser. Commit.
  • Use magnifying glass iconography for zoom icons. Commit. Fixes bug #435671
  • Remove 16px view-list-symbolic symlink. Commit.
  • Fix incorrect target icon for view-grid-symbolic. Commit.
  • Fix user-desktop-symbolic symlink. Commit.
  • Remove unsupported colorscheme entries from stylesheets. Commit.
  • Quassel_message: Replace ButtonFocus with Highlight. Commit.
  • Use Text color for konv_message icon. Commit. See bug #482645
  • Replace hardcoded blue with highlight color in OSD icons. Commit.
  • Remove unneeded dark applets icons. Commit. Fixes bug #477289
  • Software-updates-additional: Port away from ButtonFocus color. Commit.
  • Network-mobile-available: Replace ButtonFocus with Highlight. Commit.
  • Notification-progress-active: Replace ButtonFocus with Highlight. Commit.
  • Drop edit-hover and showinfo-hover icons. Commit.
  • Fix suyu color in dark theme. Commit.
  • Add suyu icon. Commit.
  • Add 48px elisa-symbolic icon used for the Android themed icon. Commit.
  • Update outdated url. Commit.
  • Fix incorrectly named network icon symlinks. Commit.
  • Make process-stop-symbolic a symlink to the base icon. Commit. Fixes bug #482556
  • Fix some 96px folder icons not using accent color. Commit. Fixes bug #478016
  • Add new icon for Skladnik. Commit. Fixes bug #458214
Extra CMake Modules
  • ECMAddQch: drop trying to set IMPORTED on targets with installed config. Commit.
  • Fix DATAROOTDIR documentation for Windows. Commit.
  • Update documentation favicon. Commit.
  • MacOS is the name of the Apple operating system. Commit.
  • Fix fetch translations tests in GitLab forks. Commit.
  • Docs: Correct escape sequence for Python 3.12 or later. Commit.
  • Map some more language codes to the IDs supported by Google Play. Commit.
  • [ECMQmlModule] Add option to enable verbose compiler output. Commit.
  • Remove extraneous docs-build CI job that is no longer needed following the switch of api.kde.org to Gitlab CI. Commit.
Framework Integration
  • Kns: Fix typo in yes / no action request. Commit.
KBookmarks
  • Fix KBookmarkManager::save triggering KDirWatch. Commit.
KCalendarCore
  • Fix check whether RRULE UNTIL datetime is UTC. Commit.
  • Fix conversion of date-only icaltimetype to UTC QDateTime. Commit. Fixes bug #483707
  • MemoryCalendar: log details about duplicate events before asserting. Commit. See bug #481031
KCMUtils
  • Better document KPluginModel. Commit.
  • Deprecate ContextualHelpButton in favor of the Kirigami version. Commit.
  • KCMLauncher: Fix up docs. Commit.
  • Port QML modules to declarative type registration. Commit.
  • ConfigModule: Fix imports and aliases in provided example. Commit.
  • SharedQmlEngine: Improve error reporting when loading main component. Commit.
  • SettingHighlighterPrivate: update highlight on target children changes. Commit.
  • Qml: set domain for i18n strings. Commit.
KConfig
  • Don't search for QtDBus on Windows/macOS/Android. Commit.
  • Register KConfigPropertyMap to QML. Commit.
  • Kconf_update: Also run .upd files if times match but done is empty. Commit. Fixes bug #483795
  • Add unittest that URL[$e] works, for bug 482889. Commit.
KConfigWidgets
  • Don't use DBus on Windows/macOS. Commit.
KCoreAddons
  • Don't search for QtDBus on Windows/macOS/Android. Commit.
  • KformatPrivate: fix deprecation enum arithmetic with float. Commit.
KCrash
KDBusAddons
  • Conditionalise Qt6::GuiPrivate on HAVE_X11. Commit.
KDeclarative
  • Remove redundant QML_ELEMENT in KDeclarativeMouseEvent and WheelEvent. Commit.
  • Don't use kwidgetsaddons on Android. Commit.
  • Refactor kglobalaccel check. Commit.
  • Don't use kglobalaccel on Android. Commit.
  • Mark Android as supported. Commit.
  • Add Android CI. Commit.
  • Add dependency to QML module. Commit.
  • Kquickcontrolsaddons: Drop QML import versions from doc example. Commit.
  • Kquickcontrols: Remove superfluous no-op assignment. Commit.
  • Kquickcontrols: Replace superfluous Text item and a semi-broken expression. Commit.
  • Kquickcontrols: Reduce superfluous ternary. Commit.
  • Kquickcontrols: Declare type of __previousSequence property as a string. Commit.
  • Kquickcontrols: Uplift previousSequence property to the root component. Commit.
  • Kquickcontrols: Drop QML import versions, fix up code style. Commit.
KDocTools
  • Fixes compile problem for projects which uses older cmake versions. Commit.
  • Kdoctools_create_handbook/manpage: check INSTALL_DESTINATION for empty value. Commit.
  • Replace user.entities. Commit.
  • Upload New File bg.xml. Commit.
  • Update user.entities in bg. Commit.
KFileMetaData
  • [PopplerExtractorTest] Verify multicolumn PDF content (currently broken). Commit.
  • [PopplerExtractorTest] Make tests data driven. Commit.
  • [PopplerExtractorTest] Move class declaration to source file. Commit.
  • Plaintextextractor: autodetect encoding for text. Commit.
  • [PlainTextExtractor] Add plain text test file to coverage test. Commit.
  • [IndexerExtractorTest] Make tests data driven. Commit.
  • Add support for .mod/.s3m/.xm/.it Module Tracker formats meta data. Commit. Fixes bug #448182
  • Plaintextextractor: Read file via QFile. Commit.
  • [PropertyInfo,TypeInfo] Move static data into scope of its class. Commit.
  • [PropertyInfo,TypeInfo] Avoid lookup from id during initilization. Commit.
  • [PropertyInfo,TypeInfo] Use QStringView for name in hash. Commit.
  • [TypeInfo] Use a hash table for faster fromName TypeInfo creation. Commit.
  • Move helper class for case-insensitive QHash lookup to separate file. Commit.
  • [TypeInfo] Make set of all types introspectable. Commit.
  • [TypeInfo] Improve performance and cleanup. Commit.
  • [TypeInfo] Add unit tests and benchmarks. Commit.
  • [TypeInfo] Extend documentation for KFileMetaData::TypeInfo. Commit.
  • [PlaintextExtractor] Fix possible truncation of last character. Commit.
  • [PlaintextExtractor] Verify handling files missing newline delimiters. Commit.
  • [PlaintextExtractor] Check countint of empty lines. Commit.
  • [IndexerExtractorTest] Actually verify content extraction is skipped. Commit.
  • [IndexerExtractorTest] Move class declaration to source file. Commit.
  • [CMake] Move mentions of KF Archive dependencies over to the extractors. Commit.
  • [CMake] Remove several leftover references to KF5. Commit.
  • Fix compilation error for krita extractor when KArchive isn't found. Commit.
KGlobalAccel
KGuiAddons
  • Recorder/KKeySequenceRecorderPrivate: support recording multi-key modifier-only shortcuts. Commit. See bug #470256
KHolidays
KI18n
  • Fix compilation with GCC 9. Commit.
  • Main: ensure current thread is main thread. Commit.
KIconThemes
  • Fix dbus disabling. Commit.
  • Don't hang if no session bus is around. Commit.
  • Don't search for QtDBus on Windows/macOS. Commit.
  • Eliminate a frequent "Invalid Context" warning for FileSystems. Commit.
  • KIconDialog: Add filter for symbolic icons. Commit.
  • Allow creating KIconEngine with colors and overlays. Commit.
  • Add breeze-icons dependency. Commit.
  • Mark index.theme config as SimpleConfig. Commit.
KIdletime
  • Guard against invalid timeout values in KIdleTime::addTimeout(). Commit. See bug #482077
KImageformats
  • Add KF_VERSION & KF_DEP_VERSION variables. Commit.
  • XCF: testcase update for fixed Qt. Commit.
  • TGA: added options support. Commit.
  • More header checks (CCBUG: 479612). Commit.
KIO
  • Improve cppcheck. Commit.
  • Fix a compiler warning. Commit.
  • Add cppcheck / codequality run for those who care. Commit.
  • Fix a few compiler warnings. Commit.
  • Make ScopedProcessRunner hold the child until we register with systemd. Commit.
  • PreviewJob: allow to display previews of fileitem having a local targetUrl. Commit.
  • Fix authentication prompt not being shown. Commit. Fixes bug #460944
  • [kdiroperator] Only write icon size settings if non-default. Commit.
  • [kdiroperator] Drop code for reading configured icon sizes. Commit.
  • [kfilewidget] Store recent files/URLs in state config. Commit.
  • [kfileitemactions] Remove dead code. Commit.
  • KCoreDirListerCache:: make sure not to reinsert an item twice. Commit. See bug #473488
  • [workers/http] Ask user to remember ignoring SSL errors. Commit. See bug #484241
  • [workers/http] Ignore already acknowledged SSL errors. Commit. See bug #484241
  • [workers/http] Don't ask to ignore non-ignorable SSL errors. Commit.
  • [sslerrortest] Print job results. Commit.
  • [widgtesaskuseractionhandler] Remove problematic Q_UNREACHABLE. Commit.
  • Fix warnings: implicit capture of ‘this’ via ‘[=]’. Commit.
  • Slim down sslerrortest. Commit.
  • Drop unused entries from defaults-kfile.h. Commit.
  • [kfileplacesmodel] Remove wrong assert. Commit. Fixes bug #484160
  • Openwith: restore preferredTerminal reading. Commit.
  • [kprocessrunner] Unexport checkStartupNotify. Commit.
  • KFileItem: when checking access use current user. Commit. Fixes bug #483436
  • Fix webshortcuts not giving searchprovider specific icon. Commit. Fixes bug #483164
  • KFileitem: Use internal permissions as best case scenario. Commit. Fixes bug #477526. Fixes bug #483436
  • Use KUrlRequester in previewtest. Commit.
  • Fix sprintf buffer leaks on 32-bit systems. Commit.
  • Connectionbackend: improve jumbo packet handling. Commit. Fixes bug #481311
  • Drop legacy keys for m_runOnDiscreteGpuBool. Commit. Fixes bug #481538
  • Explicitly defined HAVE_DBUS. Commit.
  • Make "Create New" dialogs use the same consistent title style. Commit.
  • [kopenwithdialog] Populate m_pService in checkAccept. Commit.
  • [knewfilemenu] Add window title for new file dialog. Commit. Fixes bug #482732
  • Fix hide service menu items in context menu. Commit. Fixes bug #482216
  • [kterminallauncherjob] Inherit default process environment from parent. Commit. Fixes bug #482107
  • [knewfilemenu] Fix error handling when creating a folder that already exists. Commit. Fixes bug #482145
  • Kioexec: Use categorised logging. Commit.
  • Kioexec: Remove temporary files after the main loop has completed. Commit.
  • Use symbolic icons on buttons. Commit.
  • Kioexecd: Use KUIT and button icons for the "Upload changes?" question. Commit.
  • Openwith: extract core logic from dialog. Commit.
Kirigami
  • PromptDialog: Demote wrapper item from Control to Padding. Commit.
  • ListSectionHeader: Clean up and expand docs, add import alias for Controls. Commit.
  • PlatformTheme: Note where the disabled text color comes from. Commit.
  • ImageColors: make sure QML attached object is fetched from main thread. Commit.
  • Clarify that the default alignment for ActionToolbar is AlignLeft. Commit.
  • Fix up qualified properties access and doc examples, use appropriate enum for TextEdit. Commit.
  • ContextualHelpButton: Fix up code style and qualified property access. Commit.
  • ContextualHelpButton: Use a specific and appropriate type for a property. Commit.
  • ContextualHelpButton: Sort out imports and improve docs. Commit.
  • Padding: make sure to polish on completion. Commit. Fixes bug #477978
  • PlaceholderMessage: remove bad example using it as a loading indicator. Commit.
  • ContextualHelpButton: fix translated string usage. Commit.
  • Adopt ContextualHelpButton. Commit.
  • ApplicationItem & ApplicationWindow: Don't reserve space for overlaid vkbd. Commit.
  • ColumnView: Disable invisible (out-of-viewport) pages. Commit.
  • Make global drawer item keyboard navigable. Commit.
  • Respect QT_NO_XDG_DESKTOP_PORTAL. Commit. Fixes bug #482730
  • ColumnView: Add check args to clamp. Commit. See bug #481531
  • ColumnView: Use OutExpo for page animation. Commit.
  • Fix separator of OverlayDrawer in the header bar. Commit.
  • ScrollablePage: Workaround Qt flickable inertia being really low. Commit.
  • Add Position paramenter for InlineMessage. Commit.
  • Handle URL inputs for pushDialogLayer. Commit. Fixes bug #481623
  • InlineMessage: Fix showing close button. Commit.
  • Handle null drawer as well. Commit.
  • Fix footer in layers. Commit. Fixes bug #480428
KItemModels
  • Trivial fix for crash in buddy() when sourceModel isn't set yet. Commit.
KItemViews
  • Add missing Q_OBJECT to KCategorizedSortFilterProxyModel. Commit.
KJobWidgets
  • Tests need dbus due to KUiServerJobTracker. Commit.
  • Kjobtrackerstest needs dbus. Commit.
  • TARGET Qt6::DBus doesn't work if dependencies export it. Commit.
  • Don't search for QtDBus on Windows/macOS/Android. Commit.
  • Simplify X11 check. Commit.
KNewStuff
  • Add extra ksnrc key to indicate the safety of installation. Commit.
  • Use Continue/Cancel style of question for overwrite dialog. Commit.
  • Change default sorting of entries to "Most Downloads". Commit.
  • Resultsstream: Delay the entry loading into the event look. Commit. Fixes bug #473472
  • Resultsstream: handle query results assertively. Commit.
  • Resultsstream: Allow for the members to be constant. Commit.
  • Unify default sizes. Commit. Fixes bug #482604
  • Fix the "working..." overlay for item installation. Commit. Fixes bug #483108
  • Remove the last uses of Qt5Compat.GraphicalEffects. Commit.
  • Refresh visible entry on uninstall. Commit. Fixes bug #476152
  • [qtquick/action] Add API to set transient parent for dialog. Commit. Fixes bug #479816
  • Fix link list dialog for installation button. Commit. Fixes bug #482349
  • Set questionAsker implicit sizes, set maxWidth to dialog width. Commit. Fixes bug #480338
KNotifications
  • Port QML module to declarative type registration. Commit.
KNotifyConfig
  • Don't use DBus on Windows/macOS. Commit.
KPackage
  • Testpackage: Add a website so that the tests succeed. Commit.
  • Fix: implicit capture of ‘this’ via ‘[=]’ is deprecated in C++20. Commit.
KQuickCharts
  • Declare QML module dependencies. Commit.
  • Generate default set of GLSL shaders. Commit. Fixes bug #482988
  • Examples: Remove separator from main page list items. Commit.
  • Piechartnode: Rename updateTriangles to updateSegments. Commit.
  • Piechartnode: Remove some unused stuff. Commit.
  • Examples: Change "smooth" to "interpolate". Commit.
  • Piechart: Use the right amount of thickness for the chart. Commit.
  • Linechart: Use fwidth of the point instead of sdf to avoid conditional fwidth. Commit. Fixes bug #434462
  • Sdf: Allow specifying fwidth() to sdf_render(). Commit.
KRunner
  • Add doxygen comment to ResultsModel class. Commit.
  • Give favorites a relative boost rather than absolute sorting position. Commit.
KService
  • Fix warning: mimeType "x-scheme-handler/file" not found. Commit. Fixes bug #442721
KStatusNotifieritem
  • Improve activating associated window on Wayland. Commit.
KSVG
  • Add test for loading svgs from qrc files. Commit.
  • Support loading svg from QRC files. Commit.
KTextEditor
  • Fix argument hint placement. Commit.
  • Dont use activeView as save dialog parent. Commit. Fixes bug #484466
  • Ensure only set stuff is saved. Commit.
  • Dont write useless entries to session config. Commit.
  • All tests work offscreen in the CI. Commit.
  • Try to avoid crash in destructor. Commit.
  • Try more offscreen. Commit.
  • Ensure we don't crash if no view is active. Commit.
  • Kateviewinternal: accept surrogate category character. Commit. Fixes bug #482864
  • Use test mode with e.g. own temporary config files. Commit.
  • Avoid using QChar constructor for key codes. Commit. Fixes bug #483631
  • Remove obsolete option code. Commit.
  • Remove focus frame option. Commit. Fixes bug #483218
  • Fix duplicate folds occuring. Commit.
  • Fix support for folding in vi normal mode. Commit.
  • Adapt test to hinting change. Commit.
  • Set full hinting instead to ensure the letters are aligned properly. Commit. Fixes bug #482659
  • Try to save changes. Commit. See bug #459093
  • Optimize a mark-restoring condition after document reload. Commit.
KUnitConversion
  • Binary_data: add match strings with {upper/lower}case k for kilo- and kibi-{bits/bytes}. Commit. Fixes bug #483815
KUserFeedback
  • Flatpatk: Use actual 6.6 runtime. Commit.
KWallet
  • [kwallet-query] Create QApplication before using i18n. Commit. Fixes bug #482017
  • Ensure correct exit status by adding returns after exits in QueryDriver. Commit.
KWindowSystem
  • Port QML module to declarative type registration. Commit.
  • Kkeyserver: allow shift to modify modifier keys. Commit.
  • Kkeyserver: add support for modifier keys. Commit.
KXMLGUI
  • Kkeysequencewidget: expose modifierOnlyAllowed. Commit. See bug #470257
  • Don't search for QtDBus on Windows/macOS. Commit.
  • Make sure that actions just added to the toolbar show up in the edit dialog. Commit.
Prison
  • Add dependency to QML module. Commit.
QQC2 Desktop Style
  • CheckIndicator: use Theme.View color, dont inherit parent. Commit.
  • Delegates: Unify alignment and horizontal stretching of labels. Commit.
  • KQuickStyleItem: Replace manual loop with C++20 std::accumulate. Commit.
  • Remove unneeded CMake stuff. Commit.
  • Port away from deprecated ECMQMLModules. Commit.
  • Add type annotations to functions. Commit.
  • Qualify property lookups. Commit.
  • Use local Label component directly. Commit.
  • Use local property directly. Commit.
  • Avoid looking up non-Item properties via Item-based properties. Commit.
  • Avoid looking up non-Item properties via parent. Commit.
  • Remove unused import statements. Commit.
  • Declare dependencies on other QML modules. Commit.
  • [ToolTip] Use local Label instead of importing QQC2. Commit.
  • Completely disable animations when animations are globally disabled. Commit.
  • Localization support. Commit.
  • Add support for custom fonts in ToolButtons. Commit.
  • Autotests: test TextFieldContextMenu. Commit. See bug #481293
  • Always use values from Kirigami.Theme as control palette. Commit. Fixes bug #479015
Solid
  • Udisks2: Read CleartextDevice instead of introspection. Commit.
Sonnet
  • Improve spell check config design. Commit.
  • Remove leftover files. Commit.
Syndication
Syntax Highlighting
  • Cmake-generator: refactor XML optimizations. Commit.
  • Cmake.xml: has-target-names-after-kw could be a list. Commit.
  • Cmake.xml: updates for the recently released CMake 3.29. Commit.
  • Cpp: Update Qt classes for Qt 6. Commit.
  • Initial gprbuild references. Commit.
  • Gprbuild: add license info. Commit.
  • Add small GPR test file. Commit.
  • Add GPRbuild syntax. Commit.
  • Add common alternative names used in various markdown parsers for languages. Commit.
  • Fix refs for stan. Commit.
  • Update 2 files. Commit.
  • Use (?:sub){0,2} to work with all pcre versions. Commit.
  • Alternate Names for Definitions. Commit.
  • Fix implicit size -> int conversion. Commit.
Threadweaver
  • Examples: Do not use Qt module includes. Commit.

Thursday, 11 April 2024

Qt for MCUs 2.5.3 LTS (Long-Term Support) has been released and is available for download. As a patch release, Qt for MCUs 2.5.3 LTS provides bug fixes and other improvements, and maintains source compatibility with Qt for MCUs 2.5.x. It does not add any new functionality.

Recently I was tasked to come up with an architecture for remote real time instantiation and updating of arbitrary QML components.

This entry shows how you can use a simple variation of the factory method pattern in QML for instantiating arbitrary components. I’ve split my findings into 3 blog entries, each one covering a slightly different topic. Part 1 focuses on the software design pattern used to dynamically instantiate components. Part 2 shows how to layout these dynamic components by incorporating QML’ s positioning and layout APIs. The last entry, consisting of Parts 3 and 4, addresses the anchors API and important safety aspects.

This is Part 1: Recursive Instantiation with Qt Quick and JSON.

The original factory method pattern made use of static methods to programmatically instantiate objects of different classes, instead of having to call their constructors. It achieved that by having the classes share a common ancestor. Our variation of the popular pattern uses a Loader to choose which component to load, and a Repeater to dynamically instantiate arbitrary instances of this loader using a model.

Here we specify which components with a JSON array and use a Repeater to load them.

    id: root
    // A JSON representation of a QML layout:
    property var factoryModel: [
        {
            "component": "Button",
        },
        {
            "component": "Button",
        }
    ]
    // Root of our component factory
    Repeater {
        model: root.factoryModel
        delegate: loaderComp
    }

To be able to instantiate any kind of item, you can use a Component with a Loader inside, as the Repeater’s delegate. This allows you to load a different component based on the Repeater’s model data.

    // Root component of the factory and nodes
    Component {
        id: loaderComp
        Loader {
            id: instantiator
            required property var modelData
            sourceComponent: switch (modelData.component) {
                case "Button":
                return buttonComp;
                case "RowLayout":
                return rowLayoutComp;
                case "Item":
                default: return itemComp;
            }
        }
    }

To assign values from the model to the component, add a method that gets called when the Loader’s onItemChanged event is triggered. I use this method to take care of anything that involves the component’s properties:

    // Root component of the factory and nodes
    Component {
        id: loaderComp
        Loader {
            id: instantiator
            required property var modelData
            sourceComponent: switch (modelData.component) {
                case "Button":
                return buttonComp;
                case "RowLayout":
                return rowLayoutComp;
                case "Item":
                default: return itemComp;
            }
            onItemChanged: {
                // Pass children (see explanation below)
                if (typeof(modelData.children) === "object")
                    item.model = modelData.children;

                // Button properties
                switch (modelData.component) {
                    case "Button":
                    // If the model contains certain value, we may assign it:
                    if (typeof(modelData.text) !== "undefined")
                        item.text = modelData.text;
                    break;
                }

                // Item properties
                // Since Item is the parent of all repeatable, we don't need to check
                // if the component supports Item properties before we assign them:
                if (typeof(modelData.x) !== "undefined")
                    loaderComp.x = Number(modelData.x);
                if (typeof(modelData.y) !== "undefined")
                    loaderComp.y = Number(modelData.y);
                // ...
            }
        }
    }

Examples of components that loaderComp could load are defined below. To enable recursion, these components must contain a Repeater that instantiates children components, with loaderComp set as the delegate:

    Component {
        id: itemComp
        Item {
            property alias children: itemRepeater.model
            children: Repeater {
                id: itemRepeater
                delegate: loaderComp
            }
        }
    }
    Component {
        id: buttonComp
        Button {
            property alias children: itemRepeater.model
            children: Repeater {
                id: itemRepeater
                delegate: loaderComp
            }
        }
    }
    Component {
        id: rowLayoutComp
        RowLayout {
            property alias children: itemRepeater.model
            children: Repeater {
                id: itemRepeater
                delegate: loaderComp
            }
        }
    }

The Repeater inside of the components allows us to instantiate components recursively, by having a branch or more of children components in the model, like so:

    // This model lays out buttons vertically
    property var factoryModel: [
        {
            "component": "RowLayout",
            "children": [
                {
                    "component": "Button",
                    "text": "Button 1"
                },
                {
                    "component": "Button",
                    "text": "Button 2"
                }
            ]
        }
    ]

Here we’ve seen how we can use a Repeater, a JSON model, a Loader delegate, and simple recursive definition to instantiate arbitrary QML objects from a JSON description. In my next entry I will focus on how you can lay out these arbitrarily instantiated objects on your screen.

Thanks to Kevin Krammer and Jan Marker whose insights helped improve the code you’ve seen here.

I hope you’ve found this useful! Part 2 may be found already or later by following this link.

Reference

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 Recursive Instantiation with Qt Quick and JSON appeared first on KDAB.

Logo of the KDE Eco initiative. (Image from KDE published under a <a href="https://spdx.org/licenses/CC-BY-SA-4.0.html">CC-BY-SA-4.0</a> license. Design by Lana Lutz.)
Figure : Logo of the KDE Eco initiative. (Image from KDE published under a CC-BY-SA-4.0 license. Design by Lana Lutz.)

What Is Sustainability And Why This Project?

In a general sense, sustainability refers to "the ability to maintain or support a process continuously over time". But what does it mean in terms of software?

With a rise in new technologies over the past half a century, the energy consumption of digital technology has greatly increased as well. Take, for example, large LLM models and cryptocurrency technology: both of these have heavy energy requirements. Software directly or indirectly consumes natural resources. The way software is written has a significant influence on resource consumption, such as with software-induced hardware obsolescence, when hardware vendors drive sales of new hardware through software updates that are incompatible with older hardware. The result is electronic waste and the unnecessary consumption of resources and energy in producing and transporting new hardware.

Sustainability in software means minimizing this waste. How? By designing software to limit energy consumption and have a smaller environmental impact. For this, we need tools to measure how much energy our software — and the hardware which runs it — needs. Without measurements, we cannot compare and we cannot improve!

KDE Eco has been working on KEcoLab, a project from Karanjot Singh to make KDE's measurement laboratory accessible to contributors from all over the world. KEcoLab needed a tool to easily playback usage scenarios for energy consumption data, and this is exactly what Selenium does by running automatic functional testing! But that's not all. Selenium also helps achieve the "KDE For All" goal by enabling accessibility improvements for everyone. It helps achieve the "Automate & Systematize Internal Processes" goal by creating functional tests to ensure the high quality of new code. In this way, Selenium helps achieve all three of KDE's goals!

Writing Tests In Selenium

Selenium AT-SPI is a Selenium-based tool used in KDE for automated tests of GUI applications. It works by identifying accessibility elements for a particular action. To know more about how Selenium AT-SPI functions internally, you can check out this blog post.

Writing a Selenium test is comprised of the following steps:

  • Identifying QML elements where the action needs to be performed.
  • Add accessibility code to QML elements. Accessibility code is basically a locator which will help Selenium identify that element and interact with it.
  • Get elements by its locator. Once we are done with the previous step, we can now access those elements.
  • Perform events on the elements. Once we are able to access elements, we can write code to interact with them.

You can follow this guide to setup Selenium AT-SPI and start writing basic tests. You can also check out this blog post for an in-depth overview.

Video &quot;Selenium AT-SPI: How Selenium Helps Achieve KDE's Goals&quot; (screenshot from Pradyot Ranjan published under a <a href="https://spdx.org/licenses/CC-BY-4.0.html">CC-BY-4.0</a> license).
Figure : Video "Selenium AT-SPI: How Selenium Helps Achieve KDE's Goals" (screenshot from Pradyot Ranjan published under a CC-BY-4.0 license).

Introducing Selenium To More KDE Contributors

This project was done under SoK'24 with these deliverables in mind:

  • Improve the setup process of Selenium.
  • Create video guides to introduce Selenium-based GUI testing to more KDE contributors.

I am achieving this by:

  • Enhancing the Selenium setup guide. You can find the updated Setup and Getting Started guides here. It includes all of the latest packages and info about distro-specific packages and dependencies required to setup Selenium. I've also updated the Writing Tests section to account for deprecated function arguments.
  • Creating slides and videos. I have created video presentations for newcomers to Selenium so that it is a smooth transition. For this I'm using KDE's Kdenlive software for video editing. Once the videos are published online, I will update this blog post with links. The videos broadly cover these topics:
  1. An intro video about what Selenium is and how it is useful in achieving KDE's goals.

  2. Setting up Selenium.

  3. Using the accerciser utility to discover accessibility elements.

  4. Writing accessibility code and tests to show how to access elements.

Using Kdenlive to edit the Selenium videos (screenshot from Pradyot Ranjan published under a <a href="https://spdx.org/licenses/CC-BY-4.0.html">CC-BY-4.0</a> license).
Figure : Using Kdenlive to edit the Selenium videos (screenshot from Pradyot Ranjan published under a CC-BY-4.0 license).

Challenges Faced And Looking Forward

Some challenges that I faced were:

  • Updating the setup guide so it is relevant with the latest changes. Selenium-AT-SPI is a moving target with a lot of internal changes and developements. Tracking down distro specific packages and making a list of deprecated/missing dependencies was time-consuming. The latest version of the setup guide can be found here.
  • Making videos for using Selenium. With no prior experience, this was a challenge for me. I am proud to have done it!

As we move ahead, we have some plans for this project. Some of them are:

  • We will be creating support rooms in Matrix to provide further support for KDE developers.
  • We will use Selenium to adapt usage scenario scripts originally written with xdotool so we can compare the energy profiles of the emulation tools themselves.

Interested In Contributing?

If you are interested in contributing to Selenium-AT-SPI, you can join the Matrix channels KDE Energy Efficiency and Automation & Systematization Goal and introduce yourself. Selenium-AT-SPI is hosted here. Thank you to Emmanuel, Rishi, Nitin, and Joseph as well as the whole KDE e.V. and the wonderful KDE community for supporting this project and for all the help along the way. You can also reach out to me via email or on Matrix: @pradyotranjan:gitter.im.

Over 180 individual programs plus dozens of programmer libraries and feature plugins are released simultaneously as part of KDE Gear.

Today they all get new bugfix source releases with updated translations, including:

  • kcachegrind: Fix crash when opening history menu (Commit, fixes bug #483973)
  • gwenview: No longer inhibit suspend when viewing an image (Commit, fixes bug #481481)
  • elisa: Fix broken volume slider with Qt Multimedia backend (Commit, fixes bug #392501)

Distro and app store packagers should update their application packages.

Wednesday, 10 April 2024

So this person, let's call them Jo, was hungry and had no money. Walking the streets, they come across a square where a group of people are working in a communal open kitchen, serving delicious hot meals free of charge.

Akademy 2024 will be a hybrid event held simultaneously in Würzburg, Germany, and online. The Call for Participation is open! Send us your talk ideas and abstracts.

Why talk at #Akademy2024

Akademy attracts artists, designers, developers, translators, users, writers, companies, public institutions and many other KDE friends and contributors. We celebrate the achievements and help determine the direction for the next year. We all meet together to discuss and plan the future of the Community and the technology we build. You will meet people who are receptive to your ideas and can help you with their skills and experience. You will get an opportunity to present your application, share ideas and best practices, or gain new contributors. These sessions offer the opportunity for gaining support, and making your plans for your project become a reality.

How to get started

Do not worry about details or slides right now. Just think of an idea and submit some basic details about your talk. You can edit your abstract after the initial submission. All topics relevant to the KDE Community are welcome. Here are a few ideas to get you started on your proposal:

  • New people and organisations that are discovering KDE,
  • Work towards KDE's goals: KDE For All, Sustainable Software, and Automate And Systematize Internal Processes,
  • Giving people more digital freedom and autonomy with KDE,
  • New technological developments,
  • Guides on how to participate for new users, intermediates and experts,
  • What's new after porting KDE Frameworks, Plasma and applications to Qt6
  • Anything else that might interest the audience?

To get an idea of talks that were accepted, check out the program from previous years: 2023, 2022, 2021, 2020, 2019, 2018, and 2017.

For more details and information, visit our Call for Participation.

Tuesday, 9 April 2024

We are thrilled to announce the winners of the Kubuntu Brand Graphic Design contest and the Wallpaper Contest! These competitions brought out the best in creativity, innovation, and passion from the Kubuntu community, and we couldn’t be more pleased with the results.

Kubuntu Brand Graphic Design Contest Winners

The Kubuntu Council is excited to reveal that after much deliberation and awe at the sheer talent on display, the winner
of the Kubuntu Brand Graphic Design contest is Fabio Maricato! Fabio’s entry captivated us with its innovative
approach and deep understanding of the Kubuntu brand essence. Coming in a close second is Desodi, whose creative flair and original design impressed us all. In third place, we have John Tolorunlojo, whose submission showcased exceptional creativity and skill.

Wallpaper Contest Honours

For the Wallpaper Contest, we had the pleasure of selecting three outstanding entries that will grace the screens of Kubuntu 24.04 LTS users worldwide. Congratulations to Gregorio, Dilip, and Jack Sharp for their stunning wallpaper contributions. Each design brings a unique flavor to the Kubuntu desktop experience, embodying the spirit of our community.

A Heartfelt Thank You

We extend our deepest gratitude to every participant who shared their artistry and vision with us. The number and quality of the submissions were truly beyond our expectations, reflecting the vibrant and creative spirit of the Kubuntu community. It’s your passion and engagement that make Kubuntu not just a powerful operating system, but a canvas for creativity.

Looking Ahead

The Kubuntu Council is thrilled with the success of these contests, and we are already looking forward to future opportunities to showcase the talents within our community. We believe that these winning designs not only celebrate the individuals behind them but also symbolise the collective creativity and innovation that Kubuntu stands for.

Stay tuned for the official inclusion of the winning wallpaper designs in Kubuntu 24.04 LTS, and keep an eye on our website for future contests and community events.

Once again, congratulations to our winners and a massive thank you to all who participated. Your contributions continue to shape and enrich the Kubuntu experience for users around the globe.

Celebrate with Us!

Check out our special banner commemorating the announcement and join us in celebrating the creativity and dedication of our winners and participants alike. Your efforts have truly made this contest a memorable one.

Here’s to many more years of innovation, creativity, and community in the world of Kubuntu.

The results of our contest, our proudly displayed in our Github Repository

Cheers!