### Example Installed Files Source: https://develop.kde.org/docs/plasma/widget/c-api Illustrates the typical installation paths for the compiled plugin library and QML directory file on OpenSUSE. Use 'locate qmldir' to find paths on other distributions. ```text /usr/lib64/qt5/qml/com/github/zren/widgetname/libwidgetnameplugin.so /usr/lib64/qt5/qml/com/github/zren/widgetname/qmldir ``` -------------------------------- ### Download and run kde-builder initial setup script Source: https://develop.kde.org/docs/getting-started/building/kde-builder-setup This script downloads and executes the initial setup for kde-builder, which installs necessary tools like git and adds the kde-builder executable to your PATH. ```bash cd ~ curl 'https://invent.kde.org/sdk/kde-builder/-/raw/master/scripts/initial_setup.sh' > initial_setup.sh bash initial_setup.sh ``` -------------------------------- ### Build and Run D-Bus Chat Example Source: https://develop.kde.org/docs/features/d-bus/using_custom_types_with_dbus Instructions to build and run the D-Bus chat example. Ensure you have the necessary build tools and dependencies installed. ```bash mkdir build pushd build cmake ../ -G Ninja ninja ./dbuschat ``` -------------------------------- ### Example of Install Prefix in Desktop File Source: https://develop.kde.org/docs/getting-started/building/cmake-build Illustrates how the install prefix is embedded in a desktop entry file during the configuration step. Changes to the install prefix during installation may not affect this file. ```ini Exec=@CMAKE_INSTALL_PREFIX/bin/myapp@ ``` -------------------------------- ### Build, Install, and Run Application with CMake Source: https://develop.kde.org/docs/getting-started/rust/rust-app Steps to configure CMake with a custom installation prefix, build the project, and then run the installed application. Assumes an out-of-tree build. ```bash cmake -B build --install-prefix ~/.local cmake --build build/ ./build/simplemdviewer ``` -------------------------------- ### Desktop Configuration Example Source: https://develop.kde.org/docs/plasma/scripting/api Example of how to set the wallpaper plugin, configuration group, and write wallpaper configuration for a desktop. ```APIDOC ## Desktop Configuration ### Description This example demonstrates how to configure the wallpaper for a desktop instance. ### Usage ```javascript let desktop = desktops()[0] desktop.wallpaperPlugin = "org.kde.image" desktop.currentConfigGroup = Array("Wallpaper", "org.kde.image", "General") desktop.writeConfig("Image", "file:///usr/share/wallpapers/Next/contents/images/1920x1080.png") ``` ``` -------------------------------- ### Install Qt6 using aqtinstall Source: https://develop.kde.org/docs/getting-started/building/kde-builder-qt6 Use aqtinstall to download and install all available Qt modules for a specific version on Linux. This command installs Qt into the specified output directory. ```bash aqt install-qt linux desktop 6.9 linux_gcc_64 --outputdir ~/Qt --modules all ``` -------------------------------- ### Basic Kirigami Application Window with a Label Source: https://develop.kde.org/docs/getting-started/kirigami/introduction-pages This snippet shows a basic Kirigami application window setup. It includes necessary imports and defines an initial page with a centered label displaying 'Hello World!'. Use this for simple applications or as a starting point. ```QML import QtQuick import QtQuick.Layouts import QtQuick.Controls as Controls import org.kde.kirigami as Kirigami Kirigami.ApplicationWindow { // Unique identifier to reference this object id: root width: 400 height: 300 // Window title // i18nc() makes a string translatable // and provides additional context for the translators title: i18nc("@title:window", "Hello World") // Set the first page that will be loaded when the app opens // This can also be set to an id of a Kirigami.Page pageStack.initialPage: Kirigami.Page { Controls.Label { // Center label horizontally and vertically within parent object anchors.centerIn: parent text: i18n("Hello World!") } } } ``` -------------------------------- ### Compile and Install Kirigami Application Source: https://develop.kde.org/docs/getting-started/kirigami/setup-rust Use these CMake commands to build, install, and set up your Kirigami application. The first command configures the installation prefix, the second builds the project, and the third installs the application files. ```bash cmake -B build --install-prefix ~/.local cmake --build build/ cmake --install build/ ``` -------------------------------- ### Test Package Installation Source: https://develop.kde.org/docs/getting-started/python/python-package Sets up a clean virtual environment, activates it, and installs the built package from the 'dist/' directory for testing. ```bash deactivate python3 -m venv --system-site-packages clean-env/ source clean-env/bin/activate python3 -m pip install dist/org.kde.simplemdviewer-0.1-py3-none-any.whl ``` -------------------------------- ### Build and Install Plugin (CMake) Source: https://develop.kde.org/docs/apps/kate/plugin Commands to configure, build, and install the plugin using CMake. It specifies a custom installation prefix for testing. ```bash cmake -B build/ -D CMAKE_INSTALL_PREFIX=$HOME/kde/usr cmake --build build/ cmake --install build/ ``` -------------------------------- ### Install aqtinstall using pipx Source: https://develop.kde.org/docs/getting-started/building/kde-builder-qt6 Install the unofficial aqtinstall tool, which allows downloading Qt from official sources without a Qt account. This is a prerequisite for using aqtinstall to manage Qt installations. ```bash pipx install aqtinstall ``` -------------------------------- ### Run Example Test Script with kde-builder Source: https://develop.kde.org/docs/apps/tests/appium Execute the example test script for selenium-webdriver-at-spi using kde-builder. ```bash kde-builder --run selenium-webdriver-at-spi-run ~/kde/src/selenium-webdriver-at-spi/examples/calculatortest.py ``` -------------------------------- ### Create and Install .plasmalayout Package Source: https://develop.kde.org/docs/plasma/scripting/templates Create a .plasmalayout package from a template directory using zip, then install it with kpackagetool5. ```bash (cd ~/Code/mytemplate && zip -r ../mytemplate.plasmalayout *) kpackagetool5 --type=Plasma/LayoutTemplate -i ~/Code/mytemplate.plasmalayout ``` -------------------------------- ### Install Qt Creator (Arch Linux) Source: https://develop.kde.org/docs/getting-started/building/ide/qt-creator Use this command to install Qt Creator on Arch Linux. ```bash sudo pacman -S qtcreator ``` -------------------------------- ### Install Qt Creator (Debian/Ubuntu) Source: https://develop.kde.org/docs/getting-started/building/ide/qt-creator Use this command to install Qt Creator on Debian-based systems like Ubuntu. ```bash sudo apt install qtcreator ``` -------------------------------- ### Install Accerciser and Orca (openSUSE) Source: https://develop.kde.org/docs/apps/tests/appium Install Accerciser and Orca for accessibility testing on openSUSE. ```bash sudo zypper install accerciser orca ``` -------------------------------- ### Install pkg-provides plugin on FreeBSD Source: https://develop.kde.org/docs/getting-started/building/help-dependencies Install the pkg-provides plugin to enable querying for file providers on FreeBSD. ```bash sudo pkg install pkg-provides ``` -------------------------------- ### Install Flatpak Runtimes Source: https://develop.kde.org/docs/getting-started/rust/rust-flatpak Installs the necessary KDE Platform and SDK runtimes for building and running the Flatpak application. ```bash flatpak install org.kde.Platform/x86_64/6.9 org.kde.Sdk/x86_64/6.9 ``` -------------------------------- ### Main Application Entry Point Source: https://develop.kde.org/docs/getting-started/kxmlgui/main_window Sets up the QApplication, KLocalizedString, KAboutData, and QCommandLineParser. Creates and shows the MainWindow instance, then starts the application event loop. ```cpp #include #include #include #include #include "mainwindow.h" int main (int argc, char *argv[]) { using namespace Qt::Literals::StringLiterals; QApplication app(argc, argv); KLocalizedString::setApplicationDomain("mainwindow"); KAboutData aboutData( u"mainwindow"_s, i18n("Main Window"), u"1.0"_s, i18n("A simple text area"), KAboutLicense::GPL, i18n("(c) 2024"), i18n("Educational application..."), u"https://apps.kde.org/someappname/"_s, u"submit@bugs.kde.org"_s); aboutData.addAuthor( i18n("John Doe"), i18n("Tutorial learner"), u"john.doe@example.com"_s, u"https://john-doe.example.com"_s, u"johndoe"_s); KAboutData::setApplicationData(aboutData); QCommandLineParser parser; aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); MainWindow *window = new MainWindow(); window->show(); return app.exec(); } ``` -------------------------------- ### Basic PlasmoidItem Setup Source: https://develop.kde.org/docs/plasma/widget/setup This is the most basic setup for a Plasma widget, displaying 'Hello World!' using `PlasmoidItem` and `PlasmaComponents.Label`. ```qml import QtQuick import org.kde.plasma.plasmoid import org.kde.plasma.components as PlasmaComponents PlasmoidItem{ PlasmaComponents.Label { text: "Hello World!" } } ``` -------------------------------- ### Clone Plasma Widget Example Source: https://develop.kde.org/docs/plasma/widget/c-api Clone the example project from GitHub to start developing a Plasma widget. ```bash mkdir -p ~/Code cd ~/Code git clone https://github.com/Zren/plasmoid-helloworldplugin plasmoid-widgetname cd ~/Code/plasmoid-widgetname ``` -------------------------------- ### Main Application Entry Point Source: https://develop.kde.org/docs/getting-started/kxmlgui/saving_and_loading Sets up the QApplication, KLocalizedString, and KAboutData. It also parses command-line arguments and initializes the main window. ```cpp #include #include #include #include #include "mainwindow.h" int main (int argc, char *argv[]) { using namespace Qt::Literals::StringLiterals; QApplication app(argc, argv); KLocalizedString::setApplicationDomain("texteditor"); KAboutData aboutData( u"texteditor"_s, i18n("Text Editor"), u"1.0"_s, i18n("A simple editor capable of saving and loading"), KAboutLicense::GPL, i18n("(c) 2024"), i18n("Educational application..."), u"https://apps.kde.org/someappname/"_s, u"submit@bugs.kde.org"_s); aboutData.addAuthor( i18n("John Doe"), i18n("Tutorial learner"), u"john.doe@example.com"_s, u"https://john-doe.example.com"_s, u"johndoe"_s); KAboutData::setApplicationData(aboutData); QCommandLineParser parser; aboutData.setupCommandLine(&parser); parser.process(app); aboutData.processCommandLine(&parser); MainWindow *window = new MainWindow(); window->show(); return app.exec(); } ``` -------------------------------- ### GetText PO File Example Source: https://develop.kde.org/docs/getting-started/building/ide/clion This is an example of a GetText PO file stanza. Installing the GetText plugin makes source file references clickable. ```po #: part/part.cpp:132 #, kde-format msgid "Comment has been modified." msgstr "Комментарий был изменен." ``` -------------------------------- ### Configure, Compile, and Install KCM Project Source: https://develop.kde.org/docs/features/configuration/kcm Commands to configure the CMake project, compile the KCM, and install it to a specified prefix. This setup is useful for testing in isolated environments. ```bash // Configure our project in an out-of-tree build/ folder cmake -B build/ -DCMAKE_INSTALL_PREFIX=~/kde/usr // Compile the project inside the build/ folder cmake --build build/ // Install the files compiled in build/ into the ~/kde/usr prefix cmake --install build/ ``` -------------------------------- ### Setting up Actions in MainWindow Source: https://develop.kde.org/docs/getting-started/kxmlgui/using_actions Initializes the UI, sets up custom actions like 'Clear', connects them to slots, configures shortcuts, and integrates standard actions like 'Quit'. It also calls setupGUI to load the UI definition. ```cpp #include #include #include #include #include #include #include "mainwindow.h" MainWindow::MainWindow(QWidget *parent) : KXmlGuiWindow(parent) { textArea = new KTextEdit(); setCentralWidget(textArea); setupActions(); } void MainWindow::setupActions() { using namespace Qt::Literals::StringLiterals; QAction *clearAction = new QAction(this); clearAction->setText(i18n("&Clear")); clearAction->setIcon(QIcon::fromTheme(u"document-new-symbolic"_s)); actionCollection()->addAction(u"clear"_s, clearAction); actionCollection()->setDefaultShortcut(clearAction, Qt::CTRL | Qt::Key_L); connect(clearAction, &QAction::triggered, textArea, &KTextEdit::clear); KStandardAction::quit(qApp, &QCoreApplication::quit, actionCollection()); setupGUI(Default, u"texteditorui.rc"_s); } ``` -------------------------------- ### PyQt6 Application Entry Point Source: https://develop.kde.org/docs/getting-started/python/python-app Set up the main application file for a PyQt6 application. This includes initializing the QGuiApplication, QQmlApplicationEngine, and loading the QML file. ```python #!/usr/bin/env python3 import os import sys import signal from PyQt6.QtGui import QGuiApplication from PyQt6.QtCore import QUrl from PyQt6.QtQml import QQmlApplicationEngine, qmlRegisterType from md_converter import MdConverter def main(): """Initializes and manages the application execution""" app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() """Needed to close the app with Ctrl+C""" signal.signal(signal.SIGINT, signal.SIG_DFL) """Needed to get proper KDE style outside of Plasma""" if not os.environ.get("QT_QUICK_CONTROLS_STYLE"): os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop" ``` -------------------------------- ### Initialize Rust Application with Qt Source: https://develop.kde.org/docs/getting-started/rust/rust-app Sets up the Qt application, associates it with a desktop file name, configures the style, and loads the main QML file. Ensure the `cxx_qt_lib` and `cxx_qt_lib_extras` crates are added as dependencies. ```rust use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QQuickStyle, QString, QUrl}; use cxx_qt_lib_extras::QApplication; use std::env; fn main() { let mut app = QApplication::new(); // To associate the executable to the installed desktop file QGuiApplication::set_desktop_file_name(&QString::from("org.kde.simplemdviewer")); // To ensure the style is set correctly if env::var("QT_QUICK_CONTROLS_STYLE").is_err() { QQuickStyle::set_style(&QString::from("org.kde.desktop")); } let mut engine = QQmlApplicationEngine::new(); if let Some(engine) = engine.as_mut() { engine.load(&QUrl::from( "qrc:/qt/qml/org/kde/simplemdviewer/src/qml/Main.qml", )); } if let Some(app) = app.as_mut() { app.exec(); } } ``` -------------------------------- ### Define Application Shortcuts in Craft Blueprint Source: https://develop.kde.org/docs/getting-started/building/craft Configure application shortcuts within a Craft blueprint file. This example sets the application name and defines a Start menu shortcut for the Kirigami tutorial. ```python from Package.CMakePackageBase import CMakePackageBase class Package(CMakePackageBase): def createPackage(self): self.defines["appname"] = "kirigami-hello" self.defines["shortcuts"] = [{"name": "Kirigami Tutorial", "target": "bin/kirigami-hello.exe"}] return super().createPackage() ``` -------------------------------- ### CMakeLists.txt for Kirigami Project Setup Source: https://develop.kde.org/docs/getting-started/kirigami/advanced-connect_models Configures the CMake build system for a Kirigami project. It finds necessary Qt6 and KF6 modules, sets up QML module discovery, and defines installation rules. ```CMake cmake_minimum_required(VERSION 3.20) project(kirigami-tutorial) find_package(ECM 6.0.0 REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) include(ECMFindQmlModule) include(ECMQmlModule) remove_definitions(-DQT_NO_CAST_FROM_ASCII) find_package(Qt6 REQUIRED COMPONENTS Core Quick Test Gui QuickControls2 Widgets ) find_package(KF6 REQUIRED COMPONENTS Kirigami I18n CoreAddons QQC2DesktopStyle IconThemes ) ecm_find_qmlmodule(org.kde.kirigami REQUIRED) add_subdirectory(src) install(PROGRAMS org.kde.tutorial.desktop DESTINATION ${KDE_INSTALL_APPDIR}) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) ``` -------------------------------- ### Kirigami Application Setup in main.cpp Source: https://develop.kde.org/docs/getting-started/kirigami/advanced-maincpp This snippet initializes the application, sets metadata, configures styling, and loads the QML engine. It's essential for any Kirigami application's backend. ```cpp #include #include #include #include #include #include #include #include int main(int argc, char *argv[]) { KIconTheme::initTheme(); QApplication app(argc, argv); KLocalizedString::setApplicationDomain("tutorial"); QApplication::setOrganizationName(QStringLiteral("KDE")); QApplication::setOrganizationDomain(QStringLiteral("kde.org")); QApplication::setApplicationName(QStringLiteral("Kirigami Tutorial")); QApplication::setDesktopFileName(QStringLiteral("org.kde.tutorial")); QApplication::setStyle(QStringLiteral("breeze")); if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) { QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); } QQmlApplicationEngine engine; engine.rootContext()->setContextObject(new KLocalizedContext(&engine)); engine.loadFromModule("org.kde.tutorial", "Main"); if (engine.rootObjects().isEmpty()) { return -1; } return app.exec(); } ``` -------------------------------- ### Page Row with Global Toolbar and Initial Page Source: https://develop.kde.org/docs/getting-started/kirigami/components-pagerow_pagestack Enhances a Kirigami PageRow by configuring a global toolbar style and setting an initial page. This example demonstrates how to integrate application-wide headers and define the starting view. ```javascript import QtQuick import org.kde.kirigami as Kirigami Kirigami.ApplicationWindow { title: "With globalToolBar and initialPage" width: 500 height: 200 Kirigami.PageRow { anchors.fill: parent globalToolBar.style: Kirigami.ApplicationHeaderStyle.Auto initialPage: Kirigami.Page { Rectangle { anchors.fill: parent color: "lightblue" } } } } ``` -------------------------------- ### Install Craft Source: https://develop.kde.org/docs/getting-started/building/craft This command downloads and executes the Craft installation script from GitHub. Follow the prompts, accepting defaults by pressing Enter. ```powershell iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/KDE/craft/master/setup/install_craft.ps1')) ``` -------------------------------- ### Configure Project with Build Directory Source: https://develop.kde.org/docs/getting-started/building/cmake-build Prepares the project by finding build dependencies and creating a build directory. The `build/` directory is automatically created if it doesn't exist. ```bash cmake -B build/ ``` -------------------------------- ### Install Project with CMake Source: https://develop.kde.org/docs/getting-started/building/cmake-build Installs the built project to a specified prefix. This requires setting the install prefix during configuration and then executing the install step. ```bash cmake -B build/ --install-prefix /place/to/install cmake --build build/ cmake --install build/ ``` -------------------------------- ### Rust Application Entry Point Source: https://develop.kde.org/docs/getting-started/kirigami/setup-rust Initializes the Qt application, sets the desktop file name, configures the QML style, and loads the main QML file. Ensure the QT_QUICK_CONTROLS_STYLE environment variable is set if a custom style is desired. ```rust #[cxx_qt::bridge] mod ffi { extern "RustQt" { #[qobject] type DummyQObject = super::DummyRustStruct; } } #[derive(Default)] pub struct DummyRustStruct; use cxx_qt_lib::{QGuiApplication, QQmlApplicationEngine, QQuickStyle, QString, QUrl}; use cxx_qt_lib_extras::QApplication; use std::env; fn main() { let mut app = QApplication::new(); let mut engine = QQmlApplicationEngine::new(); // To associate the executable to the installed desktop file QGuiApplication::set_desktop_file_name(&QString::from("org.kde.kirigami_rust")); // To ensure the style is set correctly let style = env::var("QT_QUICK_CONTROLS_STYLE"); if style.is_err() { QQuickStyle::set_style(&QString::from("org.kde.desktop")); } if let Some(engine) = engine.as_mut() { engine.load(&QUrl::from("qrc:/qt/qml/org/kde/tutorial/src/qml/Main.qml")); } if let Some(app) = app.as_mut() { app.exec(); } } ``` -------------------------------- ### Install Plasma Comic Plugin Source: https://develop.kde.org/docs/plasma/comic-plugin/debugging Use kpackagetool5 to install the plugin. The plugin will be installed to ~/.local/share/plasma/comics/my_comic. ```bash kpackagetool5 -t Plasma/Comic -i my_comic.comic ``` -------------------------------- ### Clean install with kde-builder Source: https://develop.kde.org/docs/getting-started/building/kde-builder-failure Use the `--use-clean-install` flag to ensure previously installed files are uninstalled before new ones are installed. This helps resolve issues caused by changes in installed files. ```bash kde-builder --use-clean-install ``` -------------------------------- ### Installing Desktop File Source: https://develop.kde.org/docs/getting-started/kirigami/advanced-understanding_cmakelists Installs the application's desktop file to the appropriate directory based on the KDE installation conventions. ```cmake install(PROGRAMS org.kde.tutorial.desktop DESTINATION ${KDE_INSTALL_APPDIR}) ``` -------------------------------- ### KDE Global Settings Example Source: https://develop.kde.org/docs/administration/kiosk/introduction Shows a basic KDE global configuration file with mouse and widget style settings. ```ini [KDE] SingleClick=true DoubleClickInterval=400 widgetStyle=breeze ``` -------------------------------- ### CMakeLists.txt: Project Setup Source: https://develop.kde.org/docs/getting-started/kirigami/advanced-add_about_page Configures the project, finds necessary Qt6 and KF6 components, including Kirigami2, I18n, and CoreAddons, which is required for KAboutData. ```cmake cmake_minimum_required(VERSION 3.16) project(helloworld) find_package(ECM REQUIRED NO_MODULE) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) include(KDEInstallDirs) include(KDECMakeSettings) include(KDECompilerSettings NO_POLICY_SCOPE) find_package(Qt6 REQUIRED NO_MODULE COMPONENTS Core Quick Test Gui QuickControls2 Widgets ) find_package(KF6 REQUIRED COMPONENTS Kirigami2 I18n CoreAddons ) add_subdirectory(src) feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES) ``` -------------------------------- ### Install Kirigami Application with pipx Source: https://develop.kde.org/docs/getting-started/kirigami/introduction-getting_started Installs a Kirigami application globally using pipx. The `--force` flag overwrites an existing installation. This command installs the package to `~/.local/share/pipx/venvs/kirigami-python` and creates an executable script at `~/.local/bin/kirigami_hello`. ```bash pipx install --force --system-site-packages . ``` -------------------------------- ### Install Rust and Cargo using rustup Source: https://develop.kde.org/docs/getting-started/rust/rust-app Installs Rust and Cargo using the recommended rustup script. Ensure you have curl installed. ```bash curl https://sh.rustup.rs -sSf | sh ``` -------------------------------- ### Build, Install, and Run Application Source: https://develop.kde.org/docs/getting-started/rust/rust-mixed Commands to build the project, install it to a local directory, and then run the application. This is the final step to test the integrated C++/Rust application. ```bash cmake -B build/ --install-prefix ~/.local cmake --build build/ cmake --install build/ simplemdviewer ``` -------------------------------- ### C++ Application Entrypoint Source: https://develop.kde.org/docs/getting-started/rust/rust-mixed Set up a C++ `main.cpp` file to initialize the Qt application, load QML, and manage the application's event loop. ```cpp #include #include #include #include #include int main(int argc, char *argv[]) { QApplication app(argc, argv); QGuiApplication::setDesktopFileName(QStringLiteral("org.kde.simplemdviewer")); QApplication::setStyle(QStringLiteral("breeze")); if (qEnvironmentVariableIsEmpty("QT_QUICK_CONTROLS_STYLE")) { QQuickStyle::setStyle(QStringLiteral("org.kde.desktop")); } QQmlApplicationEngine engine; engine.load("qrc:/qt/qml/org/kde/simplemdviewer/src/qml/Main.qml"); return app.exec(); } ``` -------------------------------- ### PySide6 Application Entry Point Source: https://develop.kde.org/docs/getting-started/python/python-app Set up the main application file for a PySide6 application. This includes initializing the QGuiApplication, QQmlApplicationEngine, and loading the QML file. ```python #!/usr/bin/env python3 import os import sys import signal from PySide6.QtGui import QGuiApplication from PySide6.QtCore import QUrl from PySide6.QtQml import QQmlApplicationEngine from md_converter import MdConverter # noqa: F401 def main(): """Initializes and manages the application execution""" app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() """Needed to close the app with Ctrl+C""" signal.signal(signal.SIGINT, signal.SIG_DFL) """Needed to get proper KDE style outside of Plasma""" if not os.environ.get("QT_QUICK_CONTROLS_STYLE"): os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop" base_path = os.path.abspath(os.path.dirname(__file__)) url = QUrl(f"file://{base_path}/qml/main.qml") engine.load(url) if len(engine.rootObjects()) == 0: quit() app.exec() if __name__ == "__main__": main() ``` -------------------------------- ### Build and Install Flatpak Application Source: https://develop.kde.org/docs/packaging/flatpak/packaging Command to build and install a Flatpak application locally. It uses flatpak-builder, installs dependencies from Flathub, and cleans the build directory. ```bash flatpak-builder build --user --install-deps-from=flathub --force-clean --ccache --install org.kde.kate.json ``` -------------------------------- ### Main Application Window with List View Source: https://develop.kde.org/docs/getting-started/kirigami/advanced-connect_backend Sets up the main application window, including a global drawer, a list model for countdown items, and a page stack displaying a cards list view of countdowns. ```qml import QtQuick import QtQuick.Layouts import QtQuick.Controls as Controls import org.kde.kirigami as Kirigami import org.kde.tutorial.components Kirigami.ApplicationWindow { id: root width: 600 height: 400 title: i18nc("@title:window", "Day Kountdown") globalDrawer: Kirigami.GlobalDrawer { isMenu: true actions: [ Kirigami.Action { text: i18n("Exposing to QML") icon.name: "kde" onTriggered: pageStack.push(Qt.createComponent("org.kde.tutorial.components", "ExposePage")) }, Kirigami.Action { text: i18n("Quit") icon.name: "application-exit-symbolic" shortcut: StandardKey.Quit onTriggered: Qt.quit() } ] } ListModel { id: kountdownModel } AddDialog { id: addDialog } pageStack.initialPage: Kirigami.ScrollablePage { title: i18nc("@title", "Kountdown") actions: [ Kirigami.Action { id: addAction icon.name: "list-add-symbolic" text: i18nc("@action:button", "Add kountdown") onTriggered: addDialog.open() } ] Kirigami.CardsListView { id: cardsView model: kountdownModel delegate: KountdownDelegate {} } } } ``` -------------------------------- ### Install KAuth Helper Files with CMake Source: https://develop.kde.org/docs/features/kauth/using_kauth Configures CMake to build and install a KAuth helper executable, linking necessary libraries and defining installation paths. ```cmake add_executable( your sources...) target_link_libraries( your libraries...) install(TARGETS DESTINATION ${KAUTH_HELPER_INSTALL_DIR}) kauth_install_helper_files( ) ``` -------------------------------- ### Build an Application with Craft Source: https://develop.kde.org/docs/packaging/android/building_applications Use the 'craft' command followed by the application name to build it and its dependencies. For example, to build KDE Itinerary. ```bash craft itinerary ``` -------------------------------- ### Basic Kirigami Application Window Setup Source: https://develop.kde.org/docs/getting-started/kirigami/addons-introduction Sets up a basic Kirigami ApplicationWindow with an initial ScrollablePage and a ColumnLayout. This serves as the foundation for adding components. ```qml import QtQuick import QtQuick.Layouts import org.kde.kirigami as Kirigami import org.kde.kirigamiaddons.formcard as FormCard import org.kde.about 1.0 Kirigami.ApplicationWindow { id: root width: 600 height: 700 pageStack.initialPage: Kirigami.ScrollablePage { ColumnLayout { // Our code will go here } } } ``` -------------------------------- ### Install VS Code on openSUSE Source: https://develop.kde.org/docs/getting-started/building/ide/visual-studio-code Installs Visual Studio Code using the official Microsoft RPM repository. This command adds the repository and then installs the code package. ```bash sudo rpm --import https://packages.microsoft.com/keys/microsoft.asc echo -e "[code]\nname=Visual Studio Code\nbaseurl=https://packages.microsoft.com/yumrepos/vscode\nenabled=1\ntype=rpm-md\ngpgcheck=1\ngpgkey=https://packages.microsoft.com/keys/microsoft.asc" | sudo tee /etc/zypp/repos.d/vscode.repo > /dev/null sudo zypper refresh sudo zypper install code ``` -------------------------------- ### Python Application Entry Point (PySide6) Source: https://develop.kde.org/docs/getting-started/python/python-app This Python script initializes the QGuiApplication and QQmlApplicationEngine, loads the main QML file, and sets up basic signal handling and styling. ```python #!/usr/bin/env python3 import os import sys import signal from PySide6.QtGui import QGuiApplication from PySide6.QtCore import QUrl from PySide6.QtQml import QQmlApplicationEngine def main(): """Initializes and manages the application execution""" app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() """Needed to close the app with Ctrl+C""" signal.signal(signal.SIGINT, signal.SIG_DFL) """Needed to get proper KDE style outside of Plasma""" if not os.environ.get("QT_QUICK_CONTROLS_STYLE"): os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop" base_path = os.path.abspath(os.path.dirname(__file__)) url = QUrl(f"file://{base_path}/qml/main.qml") engine.load(url) if len(engine.rootObjects()) == 0: quit() app.exec() if __name__ == "__main__": main() ``` -------------------------------- ### Install VS Code on Debian/Ubuntu/KDE neon Source: https://develop.kde.org/docs/getting-started/building/ide/visual-studio-code Installs Visual Studio Code using the official Microsoft APT repository. Ensure wget and gpg are installed first. ```bash sudo apt-get install wget gpg wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" | sudo tee /etc/apt/sources.list.d/vscode.list > /dev/null rm -f packages.microsoft.gpg sudo apt install apt-transport-https sudo apt update sudo apt install code ``` -------------------------------- ### init() Method for Runner Initialization (C++) Source: https://develop.kde.org/docs/plasma/krunner Performs one-time setup for the runner, including reloading configuration and connecting prepare/teardown signals for match session management. Avoid loading large data here to prevent blocking the main thread. ```cpp void HomeFilesRunner::init() { reloadConfiguration(); connect(this, &Plasma::AbstractRunner::prepare, this, []() { // Initialize data for the match session. This gets called from the main thread }); connect(this, &Plasma::AbstractRunner::teardown, this, []() { // Cleanup data from the match session. This gets called from the main thread }); } ``` -------------------------------- ### Complete Service Menu File Example Source: https://develop.kde.org/docs/apps/dolphin/service-menus This is a complete example of a service menu file, including the main desktop entry and the definition for a custom action. ```ini [Desktop Entry] Type=Service MimeType=image/*; Actions=setAsWallpaper [Desktop Action setAsWallpaper] Name=Use As Wallpaper Icon=background Exec=qdbus org.kde.plasmashell /PlasmaShell org.kde.PlasmaShell.evaluateScript 'var allDesktops = desktops();print (allDesktops);for (i=0;i /dev/null dnf check-update sudo dnf install code ``` -------------------------------- ### Install Kirigami on Fedora Source: https://develop.kde.org/docs/getting-started/kirigami/setup-cpp Installs necessary packages for Kirigami development on Fedora. ```bash sudo dnf install @development-tools @development-libs cmake extra-cmake-modules kf6-kirigami2-devel kf6-ki18n-devel kf6-kcoreaddons-devel kf6-kiconthemes-devel qt6-qtbase-devel qt6-qtdeclarative-devel qt6-qtquickcontrols2-devel kf6-qqc2-desktop-style ``` -------------------------------- ### D-Bus Service and Interface Setup Source: https://develop.kde.org/docs/features/d-bus/using_custom_types_with_dbus This code demonstrates the basic setup for a D-Bus service, including creating a service object, exporting it, and creating an interface for communication. It also shows how to register custom meta-types. ```cpp #include #include #include #include "Chat.hpp" #include "ChatAdaptor.h" #include "ChatInterface.h" #include "ChatWindow.hpp" ``` -------------------------------- ### Python Application Entry Point (PyQt6) Source: https://develop.kde.org/docs/getting-started/python/python-app This Python script initializes the QGuiApplication and QQmlApplicationEngine, loads the main QML file, and sets up basic signal handling and styling. This version uses PyQt6. ```python #!/usr/bin/env python3 import os import sys import signal from PyQt6.QtGui import QGuiApplication from PyQt6.QtCore import QUrl from PyQt6.QtQml import QQmlApplicationEngine def main(): """Initializes and manages the application execution""" app = QGuiApplication(sys.argv) engine = QQmlApplicationEngine() """Needed to close the app with Ctrl+C""" signal.signal(signal.SIGINT, signal.SIG_DFL) """Needed to get proper KDE style outside of Plasma""" if not os.environ.get("QT_QUICK_CONTROLS_STYLE"): os.environ["QT_QUICK_CONTROLS_STYLE"] = "org.kde.desktop" base_path = os.path.abspath(os.path.dirname(__file__)) url = QUrl(f"file://{base_path}/qml/main.qml") engine.load(url) if len(engine.rootObjects()) == 0: quit() app.exec() if __name__ == "__main__": main() ``` -------------------------------- ### Install Kirigami on openSUSE Source: https://develop.kde.org/docs/getting-started/kirigami/setup-cpp Installs necessary packages for Kirigami development on openSUSE. ```bash sudo zypper install cmake kf6-extra-cmake-modules kf6-kirigami-devel kf6-ki18n-devel kf6-kcoreaddons-devel kf6-kiconthemes-devel qt6-base-devel qt6-declarative-devel qt6-quickcontrols2-devel kf6-qqc2-desktop-style ``` -------------------------------- ### Hello World KMessageBox Example Source: https://develop.kde.org/docs/getting-started/kxmlgui/hello_world This C++ code snippet demonstrates how to create a simple 'Hello World' application using KMessageBox. It initializes a QApplication, defines a custom primary action using KGuiItem, and displays a question dialog with 'Hello' as the primary action and 'Cancel' as the secondary action. Use this for basic message box interactions. ```cpp #include #include int main (int argc, char *argv[]) { QApplication app(argc, argv); KGuiItem primaryAction( // Content text, Icon QStringLiteral("Hello"), QString(), // Tooltip text QStringLiteral("This is a tooltip"), // WhatsThis text QStringLiteral("This is a WhatsThis help text.")); auto messageBox = KMessageBox::questionTwoActions( // Parent nullptr, // MessageBox contents QStringLiteral("Hello World"), // MessageBox title QStringLiteral("Hello Title"), // Primary action, Secondary action primaryAction, KStandardGuiItem::cancel()); if (messageBox == KMessageBox::PrimaryAction) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } } ``` -------------------------------- ### Install KDevelop and Dependencies Source: https://develop.kde.org/docs/getting-started/building/ide/kdevelop Install KDevelop, clazy, and heaptrack on Kubuntu 25.04. ```bash apt install kdevelop clazy heaptrack ``` -------------------------------- ### Manually start Plasma shell Source: https://develop.kde.org/docs/packaging/plasma-mobile/running-apps Launches the Plasma phone shell by first starting a D-Bus session and then executing the plasmashell with the phone shell profile. This is useful for manually starting the shell environment. ```bash export $(dbus-launch) exec /usr/bin/plasmashell -p org.kde.plasma.phoneshell ``` -------------------------------- ### KRunner Plugin Installation Source: https://develop.kde.org/docs/plasma/krunner Installs a KRunner KCModule plugin using the kcoreaddons_add_plugin macro. ```cmake kcoreaddons_add_plugin(kcm_homefilesrunner SOURCES kcm_homefilesrunner.cpp INSTALL_NAMESPACE kf5/krunner/kcms) ``` -------------------------------- ### Setup Project Version (Binary) Source: https://develop.kde.org/docs/getting-started/add-project/release Use this CMake command to set up versioning for binary applications. It defines project version, prefix, shared library version, and the output header file. ```cmake ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX KGRAPHVIEWER SOVERSION ${PROJECT_VERSION_MAJOR} VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/config-kgraphviewer.h" ) ``` -------------------------------- ### Hello World Application with KXMLGUI Source: https://develop.kde.org/docs/getting-started/kxmlgui/hello_world This C++ code snippet demonstrates a basic KDE application structure. It includes internationalization setup using KLocalizedString and displays an 'About' dialog using KAboutData. The application also shows a KMessageBox with two actions. ```cpp #include #include #include #include int main (int argc, char *argv[]) { using namespace Qt::Literals::StringLiterals; QApplication app(argc, argv); KLocalizedString::setApplicationDomain("tutorial1"); KAboutData aboutData( // The program name used internally. (componentName) u"helloworld"_s, // A displayable program name string. (displayName) i18n("Hello World tutorial"), // The program version string. (version) u"1.0"_s, // Short description of what the app does. (shortDescription) i18n("Displays a KMessageBox popup"), // The license this code is released under KAboutLicense::GPL, // Copyright Statement (copyrightStatement = QString()) i18n("(c) 2024"), // Optional text shown in the About box. // Can contain any information desired. (otherText) i18n("Educational application..."), // The program homepage string. (homePageAddress = QString()) u"https://apps.kde.org/someappname/"_s, // The bug report email address // (bugsEmailAddress = QLatin1String("submit@bugs.kde.org") u"submit@bugs.kde.org"_s); aboutData.addAuthor( // Author full name i18n("John Doe"), // Author role i18n("Tutorial learner"), // Author email u"john.doe@example.com"_s, // Author website u"https://john-doe.example.com"_s, // Username in store.kde.org (for avatar image) u"johndoe"_s); KAboutData::setApplicationData(aboutData); KGuiItem primaryAction( i18n("Hello"), QString(), i18n("This is a tooltip"), i18n("This is a WhatsThis help text.")); auto messageBox = KMessageBox::questionTwoActions( nullptr, i18n("Hello World"), i18n("Hello Title"), primaryAction, KStandardGuiItem::cancel()); if (messageBox == KMessageBox::PrimaryAction) { return EXIT_SUCCESS; } else { return EXIT_FAILURE; } } ``` -------------------------------- ### Install Kirigami on Debian/Ubuntu Source: https://develop.kde.org/docs/getting-started/kirigami/setup-cpp Installs necessary packages for Kirigami development on Debian-based systems. ```bash sudo apt install build-essential cmake extra-cmake-modules libkirigami-dev libkf6i18n-dev libkf6coreaddons-dev libkf6iconthemes-dev qt6-base-dev qt6-declarative-dev libkf6qqc2desktopstyle-dev ``` -------------------------------- ### Download and Install libconfig Components Source: https://develop.kde.org/docs/plasma/widget/configuration This command sequence downloads the libconfig library from GitHub and installs its components into the local project's ui directory. ```bash cd ~/Code/plasmoid-helloworld/package/contents/ui mkdir -p ./libconfig cd ./libconfig wget https://github.com/Zren/plasma-applet-lib/archive/master.zip unzip -j master.zip plasma-applet-lib-master/package/contents/ui/libconfig/* rm master.zip ```