This is a folder of various reuseable files for developing a Plasma Widget.
I recommend downloading the zip over cloning this repo, as you might not need everything in this project. It will also give your repo a clean git history.
sh ./installto install the widget (and restartplasmashellif already installed) to test your widget in the panel.sh ./buildto generate a zip file with the extension.plasmoidwhich you can upload to the KDE Store.project.sublime-projectNormally you shouldn't commit your IDE project files, but I did so to give you an example of my various build commands.- You can hit
Ctrl+Bto test the widget withplasmoidviewer - Open
Ctrl+Shift+Pto open the command palette for other commands like:2x dpito test if your widget properly scales for HiDPI monitors.locale deto test the German locale using.../translate/plasmoidlocaletest.install widgetto install the widget and restartplasmashellto test your widget in the panel.
- You can hit
package/translate/contains various scripts for translating a widget.sh ./mergewill find alli18n("Messages")in your widget, then generate atemplate.potfor you. You can then copy and raname the template file tofr.poto translate themsgstr ""in order to translate your widget into French. If you runsh ./mergeagain, it will also merge new messages added to the widget intotemplate.potandfr.po.sh ./buildwill convert thefr.pofiles into the smaller binaryfr.mofiles. It places those inpackage/contents/localewhich is where they need to be for Plasma to recognize the translations.sh ./plasmoidlocaletestwill run the./buildscript, then runplasmoidviewerwithLANGUAGE="fr_CA:fr",LANG="fr_CA.UTF-8", andLC_TIME="fr_CA.UTF-8"so you can test the translations.
package/contents/ui/libcontains a number of reuseable QML/JS files.Logger.qmlis useful if you want to log pretty JSON formatting, but only when debugging. Add aLogger { id: logger; name: "widgetname"; }in yourmain.qml. You can then use logger.logJSON('obj', obj) to always log the object. You can also uselogger.debugJSON('obj', obj)to only show the log statement if you setLogger { showDebug: true }which can easily be commented out when preparing for release.ExecUtil.qmlis aPlasmaCore.DataSource { engine: "executable" }with aexec(cmd, callback)function added.
package/contents/ui/libconfigcontains a number of reuseable QML form controls for editing config values. They are designed so the user does not need to click Apply. You can easily bind one of these controls to the config by setting theconfigKeyproperty.- libconfig/CheckBox.qml for on/off booleans values.
- libconfig/ColorField.qml for use with a
StringorColorconfig data type. If you use use aStringdata type, you can treat an empty string as a certain color theme color. Eg:import "./libconfig" as LibConfig LibConfig.ColorField { configKey: 'labelColor' defaultColor: PlasmaCore.ColorScope.textColor }
- libconfig/ComboBox.qml is useful for creating enums using the
Stringconfig data type. KConfig comes with a enum datatype as well, but you have to either use hardcoded integers (with comments), or declare the enum in your QML code and keep it in sync. String comparison is less efficient but is easier to program with.import "./libconfig" as LibConfig LibConfig.ComboBox { configKey: "variableName" model: [ { value: "a", text: i18n("A") }, { value: "b", text: i18n("B") }, { value: "c", text: i18n("C") }, ] }
- FontFamily.qml inherits
libconfig/ComboBox.qmland is populated with all available fonts.
- FontFamily.qml inherits
- libconfig/IconField.qml based on the Application Launcher icon selector.
- libconfig/RadioButtonGroup.qml takes a similar model as
libconfig/ComboBox.qmlbut will display the options asRadioButton. - libconfig/SpinBox.qml for Integer or Real numbers.
- libconfig/TextAlign.qml for use with an
Intconfig data type. It has your typical 4 buttons for left/center/right/justify alignment. It serializes theText.AlignHCenterenum.- TextFormat.qml is used to toggle bold, italic, underline, and embeds the text alignment. For use with 3
Boolconfig keys and 1Intconfig key (used for the embededTextAlign.qml).
- TextFormat.qml is used to toggle bold, italic, underline, and embeds the text alignment. For use with 3
- libconfig/TextArea.qml for a string with multiple lines of text.
- TextAreaStringList.qml overloads
TextArea.qml'svalueToText(value)andtextToValue(text)functions to treat a new line as the seperator in theStringList.
- TextAreaStringList.qml overloads
- libconfig/TextField.qml for a single line of text.
Changelog.mdis for listing your new features for users. The KDE Store has a changelog feature which you can paste your feature lists into.mv ReadMe-widget.md ReadMe.mdyou should always have a ReadMe for your project, overwrite this library readme with the one designed for your widget.
If you ship your widget on the KDE Store, you should try to support the latest LTS distros.
Ubuntu 20.04 only uses Qt 5.12 and KDE Framework 5.68.
Ubuntu 18.04 LTS: Qt 5.9 / Plasma 5.12 / KDE Framework 5.44(Not supported since 21.04)- Debian 10 (2019-July): Qt 5.11 / Plasma 5.14 / KDE Framework 5.54
- Ubuntu 20.04 LTS: Qt 5.12 (2018-Nov) / Plasma 5.18 (2020-Feb) / KDE Framework 5.68 (2020-Mar)
- Debian 11 (2021-Aug): Qt 5.15 / Plasma 5.20 / KDE Framework 5.78
- https://zren.github.io/kde/versions/ has more distros+versions and is kept up to date.