Difference between revisions of "Development/Tutorials/Plasma2/QML2/Basic ListView"

(Created page with "{{Note|1=This is very much a work in progress. I only have so much free time each day. Keep checking back.}} ==Welcome!== This tutorial will take you through the process of c...")
(Blanked the page)
Line 1: Line 1:
{{Note|1=This is very much a work in progress. I only have so much free time each day. Keep checking back.}}
This tutorial will take you through the process of creating a simple "Hello World"-style plasmoid. It is written primarily in QML2 and intended for the Plasma 5.10+ desktop. There will also be a bit of Javascript mixed in, and it will be called out when used. An explanation of the various plasmoid testing and installation tools will be covered as well.
===Tools and Prerequisites===
You're going to need a text editor, preferably one that can highlight QML syntax. The [https://atom.io/ Atom] editor is free and has a QML syntax plugin. The ultimate in Qt/QML development is Qt Creator, which is the integrated development environment (IDE) that ships with the Qt framework, which powers the entire Plasma interface. It's overkill for our purposes, so it's recommended you stick with a fairly basic text editor for now.
You '''will not''' have to spend hours downloading and compiling source code in order to develop plasmoids. Everything you'll need is probably already included in your KDE-based distribution.
===File Structure===
The plasmoid system relies on a common file structure, so open up a terminal and create the following directories. The example shows the highest level as <code>~/projects</code>, but feel free to create an empty folder anywhere in your personal workspace. That root directory will be omitted during the rest of the tutorial - it's just a convenient place for you to store your code.
There are also two important configuration files. First off is '''CMakeLists.txt''', which defines some of the underlying dependencies to turn your plasmoid source code into a runnable program.
Create a new file in your editor and use the following template:
# set minimum CMake version (req'd for CMake 3.0 or later)
cmake_minimum_required(VERSION 2.8.12)
# use Extra CMake Modules (ECM) for common functionality
# needed by find_package(KF5Plasma) below.
# Locate plasma_install_package macro
find_package(KF5Plasma REQUIRED)
# Add installation target ("make install")
Save this file as <code>hellomoid/CMakeLists.txt</code>. At least for the sake of this tutorial, you probably won't need to touch it again. So just create it and file it away.
Next up is '''metadata.desktop''', which contains many more configurable options. We'll start with the template, then explain which options are safe to change while keeping your plasmoid running.
[Desktop Entry]
Comment=Hello World example plasmoid
X-KDE-PluginInfo-Author=Your Name
X-KDE-PluginInfo-Category=Windows and Tasks
Feel free to change the PluginInfo-Author and PluginInfo-Email definitions with your own information. Go ahead and change the Comment line if you'd like a different tag line for your example. Please don't change the Name or PluginIn-Name fields. The rest of the tutorial depends on these remaining the same as the example.
Save this file as <code>hellomoid/plasmoid/metadata.desktop</code>
===Your First QML Code===
We're done with the boilerplate setup for now. It's time to start creating something interesting.

Revision as of 19:03, 5 February 2018

This page was last edited on 5 February 2018, at 19:03. Content is available under Creative Commons License SA 4.0 unless otherwise noted.